Skip to content
  1. Feb 14, 2009
    • Chris Lattner's avatar
      Several related changes: · 237f2757
      Chris Lattner authored
      1) implement parser and sema support for reading and verifying attribute(warnunusedresult).
      2) rename hasLocalSideEffect to isUnusedResultAWarning, inverting the sense
         of its result.
      3) extend isUnusedResultAWarning to directly return the loc and range 
         info that should be reported to the user.  Make it substantially more
         precise in some cases than what was previously reported.
      4) teach isUnusedResultAWarning about CallExpr to decls that are 
         pure/const/warnunusedresult, fixing a fixme.
      5) change warn_attribute_wrong_decl_type to not pass in english strings, instead,
         pass in integers and use %select.
      
      llvm-svn: 64543
      237f2757
    • Chris Lattner's avatar
      reduce nesting. · 3a230739
      Chris Lattner authored
      llvm-svn: 64542
      3a230739
    • 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
  2. Feb 13, 2009
    • Daniel Dunbar's avatar
      Warn about attribute used ignored on "extern int a · 311bf291
      Daniel Dunbar authored
      __attribute__((used))".
      
      llvm-svn: 64499
      311bf291
    • Chris Lattner's avatar
      If x is an invalid field decl, don't construct an expression for P->x, · 303284ac
      Chris Lattner authored
      just silently return an error to avoid bogus diagnostics.
      
      llvm-svn: 64491
      303284ac
    • Daniel Dunbar's avatar
    • Douglas Gregor's avatar
      Remove DeclGroupOwningRef, since we intend for declarations to be owned · 4feb36de
      Douglas Gregor authored
      by DeclContexts (always) rather than by statements. 
      
      DeclContext currently goes out of its way to avoid destroying any
      Decls that might be owned by a DeclGroupOwningRef. However, in an
      error-recovery situation, a failure in a declaration statement can
      cause all of the decls in a DeclGroupOwningRef to be destroyed after
      they've already be added into the DeclContext. Hence, DeclContext is
      left with already-destroyed declarations, and bad things happen. This
      problem was causing failures that showed up as assertions on x86 Linux
      in test/Parser/objc-forcollection-neg-2.m.
      
      llvm-svn: 64474
      4feb36de
    • Anders Carlsson's avatar
      Start warning about unknown attributes. · 6ee8a7da
      Anders Carlsson authored
      llvm-svn: 64447
      6ee8a7da
    • Anders Carlsson's avatar
      Add a new Ignored attribute type, and use it for may_alias. · b4f3134c
      Anders Carlsson authored
      llvm-svn: 64446
      b4f3134c
    • Anders Carlsson's avatar
      Add CodeGen support for the nodebug attribute. · 63784f4e
      Anders Carlsson authored
      llvm-svn: 64445
      63784f4e
    • Anders Carlsson's avatar
      Add sema support for the nodebug attribute. · 76187b4d
      Anders Carlsson authored
      llvm-svn: 64441
      76187b4d
    • Eli Friedman's avatar
      Initial implementation of arbitrary fixed-width integer types. · 1efaaeaa
      Eli Friedman authored
      Currently only used for 128-bit integers.
      
      Note that we can't use the fixed-width integer types for other integer 
      modes without other changes because glibc headers redefines (u)int*_t 
      and friends using the mode attribute.  For example, this means that uint64_t
      has to be compatible with unsigned __attribute((mode(DI))), and 
      uint64_t is currently defined to long long.  And I have a feeling we'll 
      run into issues if we try to define uint64_t as something which isn't 
      either long or long long.
      
      This doesn't get the alignment right in most cases, including 
      the 128-bit integer case; I'll file a PR shortly.  The gist of the issue 
      is that the targets don't really expose the information necessary to 
      figure out the alignment outside of the target description, so there's a 
      non-trivial amount of work involved in getting it working right.  That 
      said, the alignment used is conservative, so the only issue with the 
      current implementation is ABI compatibility.
      
      This makes it trivial to add some sort of "bitwidth" attribute to make 
      arbitrary-width integers; I'll do that in a followup.
      
      We could also use this for stuff like the following for compatibility 
      with gcc, but I have a feeling it would be a better idea for clang to be 
      consistent between C and C++ modes rather than follow gcc's example for 
      C mode.
      struct {unsigned long long x : 33;} x;
      unsigned long long a(void) {return x.x+1;}
      
      llvm-svn: 64434
      1efaaeaa
    • Douglas Gregor's avatar
      Tighten checking of the "overloadable" attribute. If any function by a · 633b7378
      Douglas Gregor authored
      given name in a given scope is marked as "overloadable", every
      function declaration and definition with that same name and in that
      same scope needs to have the "overloadable" attribute. Essentially,
      the "overloadable" attribute is not part of attribute merging, so it
      must be specified even for redeclarations. This keeps users from
      trying to be too sneaky for their own good:
      
        double sin(double) __attribute__((overloadable)); // too sneaky
        #include <math.h>
      
      Previously, this would have made "sin" overloadable, and therefore
      given it a mangled name. Now, we get an error inside math.h when we
      see a (re)declaration of "sin" that doesn't have the "overloadable"
      attribute.
      
      llvm-svn: 64414
      633b7378
  3. Feb 12, 2009
    • Steve Naroff's avatar
    • Douglas Gregor's avatar
      Fix a bug with designated initializers where we were stepping out of a · a9add4ea
      Douglas Gregor authored
      union subobject initialization before checking whether the next
      initiailizer was actually a designated initializer. This led to
      spurious "excess elements in union initializer" errors. Thanks to
      rdivacky for reporting the bug!
      
      llvm-svn: 64392
      a9add4ea
    • Steve Naroff's avatar
      c49b22a5
    • Steve Naroff's avatar
      Several cleanups: · b7605153
      Steve Naroff authored
      - rename isObjCIdType/isObjCClassType -> isObjCIdStructType/isObjCClassStructType. The previous name didn't do what you would expect.
      - add back isObjCIdType/isObjCClassType to do what you would expect. Not currently used, however many of the isObjCIdStructType/isObjCClassStructType clients could be converted over time.
      - move static Sema function areComparableObjCInterfaces to ASTContext (renamed to areComparableObjCPointerTypes, since it now operates on pointer types).
      
      llvm-svn: 64385
      b7605153
    • Daniel Dunbar's avatar
      Support __attribute__(section(<name>)) · 648bf783
      Daniel Dunbar authored
      llvm-svn: 64380
      648bf783
    • Steve Naroff's avatar
      Turn warning into error. Minor incompatibility with GCC (for scalar types, GCC... · 0fa412cc
      Steve Naroff authored
      Turn warning into error. Minor incompatibility with GCC (for scalar types, GCC only produces a warning).
      
      llvm-svn: 64375
      0fa412cc
    • Douglas Gregor's avatar
      Expand the definition of a complex promotion to include complex -> · 6752502b
      Douglas Gregor authored
      complex conversions where the conversion between the real types is an
      integral promotion. This is how G++ handles complex promotions for its
      complex integer extension.
      
      llvm-svn: 64344
      6752502b
    • Douglas Gregor's avatar
      Introduce _Complex conversions into the function overloading · 78ca74d8
      Douglas Gregor authored
      system. Since C99 doesn't have overloading and C++ doesn't have
      _Complex, there is no specification for    this. Here's what I think
      makes sense.
      
      Complex conversions come in several flavors:
      
        - Complex promotions:  a complex -> complex   conversion where the
          underlying real-type conversion is a floating-point promotion. GCC
          seems to call this a promotion, EDG does something else. This is
          given "promotion" rank for determining the best viable function.
        - Complex conversions: a complex -> complex conversion that is
          not a complex promotion. This is given "conversion" rank for
          determining the best viable   function.
        - Complex-real conversions: a real -> complex or complex -> real
          conversion. This is given "conversion" rank for determining the
          best viable function.
      
      These rules are the same for C99 (when using the "overloadable"
      attribute) and C++. However, there is one difference in the handling
      of floating-point promotions: in C99, float -> long double and double
      -> long double are considered promotions (so we give them "promotion" 
      rank), while C++ considers these conversions ("conversion" rank).
      
      llvm-svn: 64343
      78ca74d8
    • Mike Stump's avatar
      Fix comment. · c89c8e32
      Mike Stump authored
      llvm-svn: 64337
      c89c8e32
    • Douglas Gregor's avatar
      Initial implementation of function overloading in C. · 4e5cbdcb
      Douglas Gregor authored
      This commit adds a new attribute, "overloadable", that enables C++
      function overloading in C. The attribute can only be added to function
      declarations, e.g.,
      
        int *f(int) __attribute__((overloadable));
      
      If the "overloadable" attribute exists on a function with a given
      name, *all* functions with that name (and in that scope) must have the
      "overloadable" attribute. Sets of overloaded functions with the
      "overloadable" attribute then follow the normal C++ rules for
      overloaded functions, e.g., overloads must have different
      parameter-type-lists from each other.
      
      When calling an overloaded function in C, we follow the same
      overloading rules as C++, with three extensions to the set of standard
      conversions:
      
        - A value of a given struct or union type T can be converted to the
          type T. This is just the identity conversion. (In C++, this would
          go through a copy constructor).
        - A value of pointer type T* can be converted to a value of type U*
          if T and U are compatible types. This conversion has Conversion
          rank (it's considered a pointer conversion in C).
        - A value of type T can be converted to a value of type U if T and U
          are compatible (and are not both pointer types). This conversion
          has Conversion rank (it's considered to be a new kind of
          conversion unique to C, a "compatible" conversion).
      
      Known defects (and, therefore, next steps):
        1) The standard-conversion handling does not understand conversions
        involving _Complex or vector extensions, so it is likely to get
        these wrong. We need to add these conversions.
        2) All overloadable functions with the same name will have the same
        linkage name, which means we'll get a collision in the linker (if
        not sooner). We'll need to mangle the names of these functions.
      
      llvm-svn: 64336
      4e5cbdcb
  4. Feb 11, 2009
  5. Feb 10, 2009
Loading