Skip to content
  1. Aug 25, 2007
    • Chris Lattner's avatar
      Fix the regression on test/Sema/cfstring.c · 9449fd7b
      Chris Lattner authored
      llvm-svn: 41396
      9449fd7b
    • Steve Naroff's avatar
      · 0c1c7ed5
      Steve Naroff authored
      This modest change insures ImplicitCastExpr's get generated for all "assignments",
      while includes init decls, assignment exprs, call exprs, and return statements.
      
      Here are a few examples with the correct AST's...
      
      [dylan:~/llvm/tools/clang] admin% cat impcomp.c
      
      _Complex double X;
      void test2(int c) {
        X = 5;
      }
      void foo() {
        int i;
        double d = i;
        double _Complex a = 5;
      
        test2(a);
        a = 5;
        d = i;
      }
      
      
      [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang impcomp.c -parse-ast-dump
      Read top-level variable decl: 'X'
      
      void test2(int c)
      (CompoundStmt 0x2605ce0
        (BinaryOperator 0x2605cc0 '_Complex double' '='
          (DeclRefExpr 0x2605c70 '_Complex double' Decl='X' 0x2605af0)
          (ImplicitCastExpr 0x2605cb0 '_Complex double'
            (IntegerLiteral 0x2605c90 'int' 5))))
      
      
      void foo()
      (CompoundStmt 0x2606030
        (DeclStmt 0x2605bd0
          0x2605d90 "int i")
        (DeclStmt 0x2605e20
          0x2605de0 "double d =
            (ImplicitCastExpr 0x2605e10 'double'
              (DeclRefExpr 0x2605dc0 'int' Decl='i' 0x2605d90))")
        (DeclStmt 0x2605e90
          0x2605e50 "_Complex double a =
            (ImplicitCastExpr 0x2605e80 '_Complex double'
              (IntegerLiteral 0x2605e30 'int' 5))")
        (CallExpr 0x2605f20 'void'
          (ImplicitCastExpr 0x2605f00 'void (*)(int)'
            (DeclRefExpr 0x2605ea0 'void (int)' Decl='test2' 0x2605c00))
          (ImplicitCastExpr 0x2605f10 'int'
            (DeclRefExpr 0x2605ec0 '_Complex double' Decl='a' 0x2605e50)))
        (BinaryOperator 0x2605fa0 '_Complex double' '='
          (DeclRefExpr 0x2605f50 '_Complex double' Decl='a' 0x2605e50)
          (ImplicitCastExpr 0x2605f90 '_Complex double'
            (IntegerLiteral 0x2605f70 'int' 5)))
        (BinaryOperator 0x2606010 'double' '='
          (DeclRefExpr 0x2605fc0 'double' Decl='d' 0x2605de0)
          (ImplicitCastExpr 0x2606000 'double'
            (DeclRefExpr 0x2605fe0 'int' Decl='i' 0x2605d90))))
      
      llvm-svn: 41379
      0c1c7ed5
  2. Aug 24, 2007
    • Chris Lattner's avatar
      remove a dead argument · 74ed76bb
      Chris Lattner authored
      llvm-svn: 41377
      74ed76bb
    • Chris Lattner's avatar
      Implement sema support for __real/__imag nodes. · 30b5dd0b
      Chris Lattner authored
      llvm-svn: 41375
      30b5dd0b
    • Steve Naroff's avatar
      · be4c4d14
      Steve Naroff authored
      Surpress ImplicitCastExprs for compound assignment expressions. For compound assignments,
      it is o.k. for the LHS and RHS to have different types. Converting the type can cause
      errors like the one Chris noticed (below).
      
      This change required a fair number of diffs (since there is a lot of shared code
      between single and compound assignments). This makes the API's look a bit uglier,
      however I couldn't think of a better way to do it (without duplicating code).
      
      Fix the following (incorrect) error:
      
      int A;
      long long B;
      
      void foo() {
        A /= B;
      }
      
      $ clang ~/scalar.c -emit-llvm
      /Users/sabre/scalar.c:6:5: error: expression is not assignable
        A /= B;
        ~ ^
      
      Now it works properly...
      
      [dylan:~/llvm/tools/clang] admin% cat compound.c
      int A;
      long long B;
      
      void foo() {
        A /= B;
      }
      [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang compound.c -parse-ast-dump
      Read top-level variable decl: 'A'
      Read top-level variable decl: 'B'
      
      void foo()
      (CompoundStmt 0x2605c40
        (BinaryOperator 0x2605c20 'int' '/=' ComputeTy='long long'
          (DeclRefExpr 0x2605be0 'int' Decl='A' 0x2605a80)
          (DeclRefExpr 0x2605c00 'long long' Decl='B' 0x2605ab0)))
      
      llvm-svn: 41364
      be4c4d14
    • Steve Naroff's avatar
      · 9d13917c
      Steve Naroff authored
      Make sure we get extension diagnostics for GCC's complex extensions.
      
      Now we emit the following when -pedantic-errors is enabled...
      
      [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang complex.c -pedantic-errors
      complex.c:4:3: error: ISO C does not support '++'/'--' on complex integer types
        ++x;
        ^ ~
      complex.c:9:7: error: ISO C does not support '~' for complex conjugation
        X = ~Y;
            ^
      complex.c:10:7: error: ISO C does not support '~' for complex conjugation
        x = ~y;
            ^
      
      llvm-svn: 41362
      9d13917c
    • Chris Lattner's avatar
      in the truncation case, make sure to propagate the sign correctly, this · 247ef955
      Chris Lattner authored
      fixes an assertion on:
      void f (int z) { switch (z) { case ~0ULL: case -1: return; } }
      
      testcase from Neil.
      
      llvm-svn: 41343
      247ef955
    • Steve Naroff's avatar
      · 8ddb23a6
      Steve Naroff authored
      Support '~' for complex conjugation. This is a GCC extension.
      
      This following now compiles without error...
      
      _Complex unsigned X, Y;
      _Complex double x, y;
      void test2(int c) {
        X = ~Y;
        x = ~y;
      }
      
      llvm-svn: 41341
      8ddb23a6
  3. Aug 23, 2007
  4. Aug 22, 2007
  5. Aug 21, 2007
  6. Aug 20, 2007
    • Ted Kremenek's avatar
      Modified ArraySubscriptExpr to have accessors getLHS and getRHS in addition · c81614d5
      Ted Kremenek authored
      to getBase and getIdx.  getBase and getIdx now return a "normalized" view
      of the expression (e.g., always "A[4]" instead of possibly "4[A]").  getLHS
      and getRHS return the expressions with syntactic fidelity to the original
      source code.
      
      Also modified client code of ArraySubscriptExpr, including the AST dumper
      and pretty printer, the return-stack value checker, and the LLVM code
      generator.
      
      llvm-svn: 41180
      c81614d5
  7. Aug 17, 2007
  8. Aug 16, 2007
    • Steve Naroff's avatar
      · cdee44c1
      Steve Naroff authored
      Fixed Sema::CheckEqualityOperands() and Sema::CheckRelationalOperands() to deal more 
      thoughtfully with incompatible pointers. This includes:
      
      - Emit a diagnostic when two pointers aren't compatible!
      - Promote one of the pointers/integers so we maintain the invariant expected by the 
      code generator (i.e. that the left/right types match).
      - Upgrade the pointer/integer comparison diagnostic to include the types. 
      
      llvm-svn: 41127
      cdee44c1
  9. Aug 14, 2007
    • Ted Kremenek's avatar
      Removed dead variable "hadError" in ParseReturnStmt. · c48affb8
      Ted Kremenek authored
      llvm-svn: 41079
      c48affb8
    • Ted Kremenek's avatar
      Added support for additional format string checking for the printf · e68f1aad
      Ted Kremenek authored
      family of functions.  Previous functionality only included checking to
      see if the format string was a string literal.  Now we check parse the
      format string (if it is a literal) and perform the following checks:
      
      (1) Warn if: number conversions (e.g. "%d") != number data arguments.
      
      (2) Warn about missing format strings  (e.g., "printf()").
      
      (3) Warn if the format string is not a string literal.
      
      (4) Warn about the use se of '%n' conversion.  This conversion is
          discouraged for security reasons.
      
      (5) Warn about malformed conversions.  For example '%;', '%v'; these
          are not valid.
      
      (6) Warn about empty format strings; e.g. printf("").  Although these
          can be optimized away by the compiler, they can be indicative of
          broken programmer logic.  We may need to add additional support to
          see when such cases occur within macro expansion to avoid false
          positives.
      
      (7) Warn if the string literal is wide; e.g. L"%d".
      
      (8) Warn if we detect a '\0' character WITHIN the format string.
      
      Test cases are included.
      
      llvm-svn: 41076
      e68f1aad
  10. Aug 10, 2007
    • Ted Kremenek's avatar
      Added "id_idx" parameter to CheckPrintfArguments. This will be used · 56c864e3
      Ted Kremenek authored
      by CheckPrintfArguments to determine if a given printf function
      accepts a va_arg argument.
      
      llvm-svn: 41008
      56c864e3
    • Ted Kremenek's avatar
      Moved id_asprintf before id_vsnprintf in the enum used for indexing · cfc9419d
      Ted Kremenek authored
      KnownFunctionIDs.  This allows us to test for a printf-like function
      that accepts a va_arg argument using a range comparison.
      
      llvm-svn: 41006
      cfc9419d
    • Chris Lattner's avatar
      initial support for checking format strings, patch by Ted Kremenek: · b87b1b36
      Chris Lattner authored
      "I've coded up some support in clang to flag warnings for non-constant format strings used in calls to printf-like functions (all the functions listed in "man fprintf").  Non-constant format strings are a source of many security exploits in C/C++ programs, and I believe are currently detected by gcc using the flag -Wformat-nonliteral."
      
      llvm-svn: 41003
      b87b1b36
    • Steve Naroff's avatar
      · 47fea35e
      Steve Naroff authored
      Make sure the arithmetic conversion are done for relation and equality operators.
      
      This fixes the following...
      
      eypedef short S;
      int test(S X, long long Y) {
        return X < Y;
      }
      
      Before...
      
      (CompoundStmt 0x2905d00
        (ReturnStmt 0x2905cf0
          (BinaryOperator 0x2905cd0 'int' '<'
            (ImplicitCastExpr 0x2905cc0 'int'
              (DeclRefExpr 0x2905c80 'S':'short' Decl='X' 0x2905c20))
            (DeclRefExpr 0x2905ca0 'long long' Decl='Y' 0x2905c50))))
      
      After...
      
      (CompoundStmt 0x2b05c30
        (ReturnStmt 0x2b05c20
          (BinaryOperator 0x2b05c00 'int' '<'
            (ImplicitCastExpr 0x2b05bf0 'long long'
              (DeclRefExpr 0x2b05bb0 'S':'short' Decl='X' 0x2b05b50))
            (DeclRefExpr 0x2b05bd0 'long long' Decl='Y' 0x2b05b80))))
      
      llvm-svn: 40999
      47fea35e
  11. Aug 08, 2007
    • Steve Naroff's avatar
      · 773df5cf
      Steve Naroff authored
      Move the function/array conversion for ParmVarDecl's from Sema::ParseIdentifierExpr()
      to Sema::ParseParamDeclarator(). After discussing this with Chris, we decided this
      approach has more immediate benefit (though we loose some information in the AST). 
      The comment below should describe more (if interested).
      
      llvm-svn: 40907
      773df5cf
  12. Aug 05, 2007
    • Steve Naroff's avatar
      · 04e8bc8e
      Steve Naroff authored
      Remove a space from "typeof" printing. It was causing the following error...
      
      [dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check typeof.c 
      Warnings expected but not seen:
        Line 21: incompatible types assigning 'typeof(*pi) const' to 'int *'
      Warnings seen but not expected:
        Line 21: incompatible types assigning 'typeof(*pi)  const' to 'int *'
      
      Also corrected a typo from my previous commit.
      
      llvm-svn: 40832
      04e8bc8e
    • Steve Naroff's avatar
      · 8a4cf97a
      Steve Naroff authored
      Make sure the good old "function/array conversion" is done to function parameters.
      
      This resulted in the following error...
      
      [dylan:clang/test/Parser] admin% cat parmvardecl_conversion.c 
      // RUN: clang -parse-ast-check %s
      
      void f (int p[]) { p++; }
      
      [dylan:clang/test/Parser] admin% clang -parse-ast-check parmvardecl_conversion.c 
      Errors seen but not expected:
        Line 3: cannot modify value of type 'int []'
      
      With this fix, the test case above succeeds.
      
      llvm-svn: 40831
      8a4cf97a
  13. Aug 04, 2007
    • Steve Naroff's avatar
      Restrict vector component access (using "." and "[]") to variables. · 0104731e
      Steve Naroff authored
      Chris suggested this, since it simplifies the code generator.
      If this features is needed (and we don't think it is), we can revisit.
      
      The following test case now produces an error.
      [dylan:~/llvm/tools/clang] admin% cat t.c
      
      typedef __attribute__(( ocu_vector_type(4) )) float float4;
      
      static void test() {
          float4 vec4;
      
          vec4.rg.g;
          vec4.rg[1];
      }
      [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.c
      t.c:8:12: error: vector component access limited to variables
          vec4.rg.g;
                 ^~
      t.c:9:12: error: vector component access limited to variables
          vec4.rg[1];
                 ^~~
      2 diagnostics generated.
      
      llvm-svn: 40795
      0104731e
  14. Aug 03, 2007
  15. Aug 02, 2007
    • Steve Naroff's avatar
      · 788d864d
      Steve Naroff authored
      - Finish hooking up support for __builtin_types_compatible_p().
      - Fix type printing code for recently added TypeOfExpr/TypeOfType.
      
      llvm-svn: 40700
      788d864d
    • Steve Naroff's avatar
      · 7886467b
      Steve Naroff authored
      Add AST/Sema support for __builtin_types_compatible_p (a GNU extension).
      Todo...still need to call the action from the parser...
      
      llvm-svn: 40693
      7886467b
  16. Aug 01, 2007
    • Steve Naroff's avatar
      · 236becbb
      Steve Naroff authored
      Two typeof() related changes...
      
      - Changed the name of ASTContext::getTypeOfType(Expr*)->getTypeOfExpr().
      - Remove FIXME for TypeOfExpr::getAsStringInternal(). This will work fine for printing the AST. It isn't ideal
      for error diagnostics (since it's more natural to display the expressions type). 
      
      One "random" (or at least delayed:-) change...
      
      - Changed all "ext_typecheck_*" diagnostics from EXTENSION->WARNING. Reason: Since -pedantic is now
      off (by default), these diagnostics were never being emitted (which is bad). With this change, clang will
      emit the warning all the time. The only downside (wrt GCC compatibility) is -pedantic-errors will not turn
      this diagnostics into errors (a "feature" of making tagging them with EXTENSION). When/if this becomes
      an issue, we can revisit.
      
      llvm-svn: 40676
      236becbb
  17. Jul 31, 2007
Loading