Skip to content
  1. May 03, 2009
  2. Apr 29, 2009
  3. Apr 17, 2009
  4. Apr 15, 2009
  5. Apr 13, 2009
  6. 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
  7. Mar 20, 2009
  8. 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
  9. Feb 19, 2009
  10. 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
  11. 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
  12. 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
  13. Jan 29, 2009
  14. Jan 27, 2009
  15. Jan 19, 2009
  16. Jan 13, 2009
  17. 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
  18. Dec 15, 2008
  19. Dec 05, 2008
  20. Nov 24, 2008
  21. Nov 23, 2008
    • Chris Lattner's avatar
      Convert IdentifierInfo's to be printed the same as DeclarationNames · e3d20d95
      Chris Lattner authored
      with implicit quotes around them.  This has a bunch of follow-on 
      effects and requires tweaking to a whole lot of code.  This causes
      a regression in two tests (xfailed) by causing it to emit things like:
      
        Line 10: duplicate interface declaration for category 'MyClass1' ('Category1')
      
      instead of:
      
        Line 10: duplicate interface declaration for category 'MyClass1(Category1)'
      
      I will fix this in a follow-up commit.
      
      As part of this, I had to start switching stuff to use ->getDeclName() instead
      of Decl::getName() for consistency.  This is good, but I was planning to do this
      as an independent patch.  There will be several follow-on patches
      to clean up some of the mess, but this patch is already too big.
      
      llvm-svn: 59917
      e3d20d95
  22. Nov 21, 2008
  23. Nov 20, 2008
  24. Nov 19, 2008
  25. Nov 17, 2008
    • Douglas Gregor's avatar
      Updated IdentifierResolver to deal with DeclarationNames. The names of · ae2fbad3
      Douglas Gregor authored
      C++ constructors, destructors, and conversion functions now have a
      FETokenInfo field that IdentifierResolver can access, so that these
      special names are handled just like ordinary identifiers. A few other
      Sema routines now use DeclarationNames instead of IdentifierInfo*'s.
      
      To validate this design, this code also implements parsing and
      semantic analysis for id-expressions that name conversion functions,
      e.g.,
      
        return operator bool();
      
      The new parser action ActOnConversionFunctionExpr takes the result of
      parsing "operator type-id" and turning it into an expression, using
      the IdentifierResolver with the DeclarationName of the conversion
      function. ActOnDeclarator pushes those conversion function names into
      scope so that the IdentifierResolver can find them, of course.
      
      llvm-svn: 59462
      ae2fbad3
Loading