Skip to content
  1. May 25, 2009
    • Chris Lattner's avatar
      tweak non-null check to put the caret on the function, but underline the · 23464b8f
      Chris Lattner authored
      argument.  This avoids the argument from being silenced when the argument is
      the NULL macro, which is defined in a system header.  This also makes the output
      a bit nicer, e.g.:
      
      t.c:8:3: warning: null passed to a callee which requires a non-null argument
        func1(NULL, cp2, i1);
        ^     ~~~~
      
      vs something like:
      
      t.c:8:10: warning: argument is null where non-null is required
        func1(NULL, cp2, i1);
              ^
      
      llvm-svn: 72393
      23464b8f
  2. May 21, 2009
  3. May 20, 2009
  4. May 18, 2009
  5. May 13, 2009
  6. May 08, 2009
  7. May 03, 2009
  8. Apr 29, 2009
  9. Apr 17, 2009
  10. Apr 15, 2009
  11. Apr 13, 2009
  12. Apr 01, 2009
    • Steve Naroff's avatar
      CodeGenModule::GetAddrOfConstantCFString(): · 8d816d6c
      Steve Naroff authored
      - Finish up support for converting UTF8->UTF16 to support ObjC @"string" constants.
      
      Remove warning from CheckObjCString.
      
      As the FIXME in the test case indicates, I still have a bug to work out (apparently with \u handling).
      
      llvm-svn: 68245
      8d816d6c
  13. Mar 20, 2009
  14. Feb 27, 2009
    • Ted Kremenek's avatar
      When checking printf-arguments for functions with '__attribute__ ((format (printf, X, Y)))' · 9723bcf6
      Ted Kremenek authored
      set HasVAListArg to true when 'Y' is 0 (i.e., ignore the data arguments).
      
      This fixes <rdar://problem/6623513>.
      
      llvm-svn: 65642
      9723bcf6
    • Douglas Gregor's avatar
      Create a new TypeNodes.def file that enumerates all of the types, · deaad8cc
      Douglas Gregor authored
      giving them rough classifications (normal types, never-canonical
      types, always-dependent types, abstract type representations) and
      making it far easier to make sure that we've hit all of the cases when
      decoding types. 
      
      Switched some switch() statements on the type class over to using this
      mechanism, and filtering out those things we don't care about. For
      example, CodeGen should never see always-dependent or non-canonical
      types, while debug info generation should never see always-dependent
      types. More switch() statements on the type class need to be moved 
      over to using this approach, so that we'll get warnings when we add a
      new type then fail to account for it somewhere in the compiler.
      
      As part of this, some types have been renamed:
      
        TypeOfExpr -> TypeOfExprType
        FunctionTypeProto -> FunctionProtoType
        FunctionTypeNoProto -> FunctionNoProtoType
      
      There shouldn't be any functionality change...
      
      llvm-svn: 65591
      deaad8cc
  15. Feb 19, 2009
  16. Feb 18, 2009
    • Chris Lattner's avatar
      final string diagnostic issue (that I know about): · 3dd56f96
      Chris Lattner authored
      we used to not account for escapes in strings with
      string concat.  Before:
      
      t.m:5:20: warning: field width should have type 'int', but argument has type 'unsigned int'
        printf("\n\n" "\n\n%*d", (unsigned) 1, 1);
                         ^       ~~~~~~~~~~~~
      
      after:
      
      t.m:5:23: warning: field width should have type 'int', but argument has type 'unsigned int'
        printf("\n\n" "\n\n%*d", (unsigned) 1, 1);
                            ^    ~~~~~~~~~~~~
      
      llvm-svn: 64941
      3dd56f96
    • Chris Lattner's avatar
      Next step toward making string diagnostics correct: handle · ddb71919
      Chris Lattner authored
      escapes in the string for subtoken positioning.  This gives
      us working examples like:
      
      t.m:5:16: warning: field width should have type 'int', but argument has type 'unsigned int'
        printf("\n\n%*d", (unsigned) 1, 1);
                     ^    ~~~~~~~~~~~~
      
      where before the caret pointed two spaces to the left.
      
      llvm-svn: 64940
      ddb71919
    • Chris Lattner's avatar
      Fix some issues handling sub-token locations that come from macro expansions. · ec396b51
      Chris Lattner authored
      We now emit:
      
      t.m:6:15: warning: field width should have type 'int', but argument has type 'unsigned int'
        printf(STR, (unsigned) 1, 1);
               ^    ~~~~~~~~~~~~
      t.m:3:18: note: instantiated from:
      #define STR "abc%*ddef"
                       ^
      
      which has the correct location in the string literal in the note line.
      
      llvm-svn: 64936
      ec396b51
    • Chris Lattner's avatar
      only get the spelling of a token to get its length if · 25997143
      Chris Lattner authored
      it needs cleaning.
      
      llvm-svn: 64932
      25997143
    • Chris Lattner's avatar
      use the full spelling of a string literal token so that trigraphs · f638b97f
      Chris Lattner authored
      and escaped newlines don't throw off the offset computation.
      
      On this testcase:
        printf("abc\
      def"
               "%*d", (unsigned) 1, 1);
      
      Before:
      t.m:5:5: warning: field width should have type 'int', but argument has type 'unsigned int'
      def"
          ^
      
      after:
      t.m:6:12: warning: field width should have type 'int', but argument has type 'unsigned int'
               "%*d", (unsigned) 1, 1);
                 ^    ~~~~~~~~~~~~
      
      llvm-svn: 64930
      f638b97f
    • Chris Lattner's avatar
      Start improving diagnostics that relate to subcharacters of string literals. · a26fb347
      Chris Lattner authored
      First step, handle diagnostics in StringLiteral's that are due to token pasting.
      
      For example, we now handle:
        id str2 = @"foo" 
                  "bar"
                 @"baz"
                 " b\0larg";  // expected-warning {{literal contains NUL character}}
      
      Correctly:
      
      test/SemaObjC/exprs.m:17:15: warning: CFString literal contains NUL character
                 " b\0larg";  // expected-warning {{literal contains NUL character}}
                 ~~~^~~~~~~
      
      There are several other related issues still to be done.
      
      llvm-svn: 64924
      a26fb347
    • Chris Lattner's avatar
      rename CheckBuiltinCFStringArgument -> CheckObjCString · 6436fb6a
      Chris Lattner authored
      llvm-svn: 64894
      6436fb6a
  17. Feb 14, 2009
    • Douglas Gregor's avatar
      Add hook to add attributes to function declarations that we know · e711f705
      Douglas Gregor authored
      about, whether they are builtins or not. Use this to add the
      appropriate "format" attribute to NSLog, NSLogv, asprintf, and
      vasprintf, and to translate builtin attributes (from Builtins.def)
      into actual attributes on the function declaration.
      
      Use the "printf" format attribute on function declarations to
      determine whether we should do format string checking, rather than
      looking at an ad hoc list of builtins and "known" function names.
      
      Be a bit more careful about when we consider a function a "builtin" in
      C++.
      
      llvm-svn: 64561
      e711f705
    • Douglas Gregor's avatar
      Make it possible for builtins to expression FILE* arguments, so that · 538c3d84
      Douglas Gregor authored
      we can define builtins such as fprintf, vfprintf, and
      __builtin___fprintf_chk. Give a nice error message when we need to
      implicitly declare a function like fprintf.
      
      llvm-svn: 64526
      538c3d84
    • Douglas Gregor's avatar
      Extend builtin "attribute" syntax to include a notation for · ac5d4c5f
      Douglas Gregor authored
      printf-like functions, both builtin functions and those in the
      C library. The function-call checker now queries this attribute do
      determine if we have a printf-like function, rather than scanning
      through the list of "known functions IDs". However, there are 5
      functions they are not yet "builtins", so the function-call checker
      handles them specifically still:
      
        - fprintf and vfprintf: the builtins mechanism cannot (yet)
          express FILE* arguments, so these can't be encoded.
        - NSLog: the builtins mechanism cannot (yet) express NSString*
          arguments, so this (and NSLogv) can't be encoded.
        - asprintf and vasprintf: these aren't part of the C99 standard
          library, so we really shouldn't be defining them as builtins in
          the general case (and we don't seem to have the machinery to make
          them builtins only on certain targets and depending on whether
          extensions are enabled).
      
      llvm-svn: 64512
      ac5d4c5f
    • Douglas Gregor's avatar
      Implicitly declare certain C library functions (malloc, strcpy, memmove, · b9063fc1
      Douglas Gregor authored
      etc.) when we perform name lookup on them. This ensures that we
      produce the correct signature for these functions, which has two
      practical impacts:
      
        1) When we're supporting the "implicit function declaration" feature
        of C99, these functions will be implicitly declared with the right
        signature rather than as a function returning "int" with no
        prototype. See PR3541 for the reason why this is important (hint:
        GCC always predeclares these functions).
       
        2) If users attempt to redeclare one of these library functions with
        an incompatible signature, we produce a hard error.
      
      This patch does a little bit of work to give reasonable error
      messages. For example, when we hit case #1 we complain that we're
      implicitly declaring this function with a specific signature, and then
      we give a note that asks the user to include the appropriate header
      (e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In
      case #2, we show the type of the implicit builtin that was incorrectly
      declared, so the user can see the problem. We could do better here:
      for example, when displaying this latter error message we say
      something like:
      
        'strcpy' was implicitly declared here with type 'char *(char *, char
        const *)'
      
      but we should really print out a fake code line showing the
      declaration, like this:
      
        'strcpy' was implicitly declared here as:
      
          char *strcpy(char *, char const *)
      
      This would also be good for printing built-in candidates with C++
      operator overloading.
      
      The set of C library functions supported by this patch includes all
      functions from the C99 specification's <stdlib.h> and <string.h> that
      (a) are predefined by GCC and (b) have signatures that could cause
      codegen issues if they are treated as functions with no prototype
      returning and int. Future work could extend this set of functions to
      other C library functions that we know about.
      
      llvm-svn: 64504
      b9063fc1
  18. Feb 07, 2009
    • Ted Kremenek's avatar
      Overhaul of Stmt allocation: · 5a201951
      Ted Kremenek authored
      - Made allocation of Stmt objects using vanilla new/delete a *compiler
        error* by making this new/delete "protected" within class Stmt.
      - Now the only way to allocate Stmt objects is by using the new
        operator that takes ASTContext& as an argument.  This ensures that
        all Stmt nodes are allocated from the same (pool) allocator.
      - Naturally, these two changes required that *all* creation sites for
        AST nodes use new (ASTContext&).  This is a large patch, but the
        majority of the changes are just this mechanical adjustment.
      - The above changes also mean that AST nodes can no longer be
        deallocated using 'delete'.  Instead, one most do
        StmtObject->Destroy(ASTContext&) or do
        ASTContextObject.Deallocate(StmtObject) (the latter not running the
        'Destroy' method).
      
      Along the way I also...
      - Made CompoundStmt allocate its array of Stmt* using the allocator in
        ASTContext (previously it used std::vector).  There are a whole
        bunch of other Stmt classes that need to be similarly changed to
        ensure that all memory allocated for ASTs comes from the allocator
        in ASTContext.
      - Added a new smart pointer ExprOwningPtr to Sema.h.  This replaces
        the uses of llvm::OwningPtr within Sema, as llvm::OwningPtr used
        'delete' to free memory instead of a Stmt's 'Destroy' method.
      
      Big thanks to Doug Gregor for helping with the acrobatics of making
      'new/delete' private and the new smart pointer ExprOwningPtr!
      
      llvm-svn: 63997
      5a201951
  19. Jan 29, 2009
  20. Jan 27, 2009
  21. Jan 19, 2009
  22. Jan 13, 2009
  23. Jan 06, 2009
    • Douglas Gregor's avatar
      Add QualifiedDeclRefExpr, which retains additional source-location · c7acfdfe
      Douglas Gregor authored
      information for declarations that were referenced via a qualified-id,
      e.g., N::C::value. We keep track of the location of the start of the
      nested-name-specifier. Note that the difference between
      QualifiedDeclRefExpr and DeclRefExpr does have an effect on the
      semantics of function calls in two ways:
        1) The use of a qualified-id instead of an unqualified-id suppresses
           argument-dependent lookup
        2) If the name refers to a virtual function, the qualified-id
        version will call the function determined statically while the
        unqualified-id version will call the function determined dynamically
        (by looking up the appropriate function in the vtable).
      
      Neither of these features is implemented yet, but we do print out
      qualified names for QualifiedDeclRefExprs as part of the AST printing.
      
      llvm-svn: 61789
      c7acfdfe
  24. Dec 15, 2008
Loading