Skip to content
  1. Feb 26, 2009
  2. Feb 25, 2009
    • Douglas Gregor's avatar
      Perform additional semantic checking of class template · f47b911f
      Douglas Gregor authored
      specializations. In particular:
      
        - Make sure class template specializations have a "template<>"
          header, and complain if they don't.
        - Make sure class template specializations are declared/defined
          within a valid context. (e.g., you can't declare a specialization
          std::vector<MyType> in the global namespace).
      
      llvm-svn: 65476
      f47b911f
    • Douglas Gregor's avatar
      Implement parsing of nested-name-specifiers that involve template-ids, e.g., · 7f741127
      Douglas Gregor authored
        std::vector<int>::allocator_type
      
      When we parse a template-id that names a type, it will become either a
      template-id annotation (which is a parsed representation of a
      template-id that has not yet been through semantic analysis) or a
      typename annotation (where semantic analysis has resolved the
      template-id to an actual type), depending on the context. We only
      produce a type in contexts where we know that we only need type
      information, e.g., in a type specifier. Otherwise, we create a
      template-id annotation that can later be "upgraded" by transforming it
      into a typename annotation when the parser needs a type. This occurs,
      for example, when we've parsed "std::vector<int>" above and then see
      the '::' after it. However, it means that when writing something like
      this:
      
        template<> class Outer::Inner<int> { ... };
      
      We have two tokens to represent Outer::Inner<int>: one token for the
      nested name specifier Outer::, and one template-id annotation token
      for Inner<int>, which will be passed to semantic analysis to define
      the class template specialization.
      
      Most of the churn in the template tests in this patch come from an
      improvement in our error recovery from ill-formed template-ids.
      
      llvm-svn: 65467
      7f741127
  3. Feb 24, 2009
  4. Feb 19, 2009
  5. Feb 18, 2009
    • Chris Lattner's avatar
      rip out __builtin_overload · d7cfc246
      Chris Lattner authored
      llvm-svn: 64961
      d7cfc246
    • Douglas Gregor's avatar
      Downgrade complaints about calling unavailable functions to a warning · 171c45ab
      Douglas Gregor authored
      (as GCC does), except when we've performed overload resolution and
      found an unavailable function: in this case, we actually error.
      
      Merge the checking of unavailable functions with the checking for
      deprecated functions. This unifies a bit of code, and makes sure that
      we're checking for unavailable functions in the right places. Also,
      this check can cause an error. We may, eventually, want an option to
      make "unavailable" warnings into errors.
      
      Implement much of the logic needed for C++0x deleted functions, which
      are effectively the same as "unavailable" functions (but always cause
      an error when referenced). However, we don't have the syntax to
      specify deleted functions yet :)
      
      llvm-svn: 64955
      171c45ab
    • 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
      1fa74d95
    • Chris Lattner's avatar
      rename CheckBuiltinCFStringArgument -> CheckObjCString · 6436fb6a
      Chris Lattner authored
      llvm-svn: 64894
      6436fb6a
    • Douglas Gregor's avatar
      Implement basic parsing and semantic analysis for explicit · 67a65640
      Douglas Gregor authored
      specialization of class templates, e.g.,
      
        template<typename T> class X;
      
        template<> class X<int> { /* blah */ };
      
      Each specialization is a different *Decl node (naturally), and can
      have different members. We keep track of forward declarations and
      definitions as for other class/struct/union types.
      
      This is only the basic framework: we still have to deal with checking
      the template headers properly, improving recovery when there are
      failures, handling nested name specifiers, etc.
      
      llvm-svn: 64848
      67a65640
  6. Feb 17, 2009
    • Chris Lattner's avatar
      emit: · 709322b8
      Chris Lattner authored
      t.c:4:9: error: invalid type 'short *' to __real operator
                               __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)), 
                                            ^
      instead of:
      t.c:4:9: error: invalid type 'short *' to __real or __imag operator
                               __tg_choose (__real__(z), C##f(z), (C)(z), C##l(z)),
                                            ^
      
      fixing a fixme.  It would be even fancier to get the spelling of the token, but I
      don't care *that* much :)
      
      llvm-svn: 64759
      709322b8
    • Chris Lattner's avatar
      Make PragmaPackStack be a private class in SemaAttr and make its · 31180bbf
      Chris Lattner authored
      instance in Sema be a pimpl.
      
      llvm-svn: 64718
      31180bbf
    • Douglas Gregor's avatar
      Added ClassTemplateSpecializationDecl, which is a subclass of · 264ec4f2
      Douglas Gregor authored
      CXXRecordDecl that is used to represent class template
      specializations. These are canonical declarations that can refer to
      either an actual class template specialization in the code, e.g.,
      
        template<> class vector<bool> { };
      
      or to a template instantiation. However, neither of these features is
      actually implemented yet, so really we're just using (and uniqing) the
      declarations to make sure that, e.g., A<int> is a different type from
      A<float>. Note that we carefully distinguish between what the user
      wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
      represents (e.g., "A<float, int>"); the former is in the sugared Type,
      the latter is an actual Decl.
      
      llvm-svn: 64716
      264ec4f2
    • Chris Lattner's avatar
      copying and assignment of sema seem unwise :) · 01c3d238
      Chris Lattner authored
      llvm-svn: 64712
      01c3d238
  7. Feb 16, 2009
    • Douglas Gregor's avatar
      Adopt a more principled approach to invalid declarations: · 75a45ba2
      Douglas Gregor authored
        - If a declaration is an invalid redeclaration of an existing name,
          complain about the invalid redeclaration then avoid adding it to
          the AST (we can still parse the definition or initializer, if any).
        - If the declaration is invalid but there is no prior declaration
          with that name, introduce the invalid declaration into the AST
          (for later error recovery).
        - If the declaration is an invalid redeclaration of a builtin that
          starts with __builtin_, we produce an error and drop the
          redeclaration. If it is an invalid redeclaration of a library
          builtin (e.g., malloc, printf), warn (don't error!) and drop the
          redeclaration.
      
      If a user attempts to define a builtin, produce an error and (if it's
      a library builtin like malloc) suggest -ffreestanding.
      
      This addresses <rdar://problem/6097585> and PR2892. However, PR3588 is
      still going to cause some problems when builtins are redeclared
      without a prototype.
      
      llvm-svn: 64639
      75a45ba2
  8. Feb 15, 2009
    • Chris Lattner's avatar
      Refactor the deprecated and unavailable checks into a new · 4bf74fdd
      Chris Lattner authored
      DiagnoseUseOfDeprecatedDecl method.  This ensures that they
      are treated consistently.  This gets us 'unavailable' support
      on a few new types of decls, and makes sure we consistently
      silence deprecated when the caller is also deprecated.
      
      llvm-svn: 64612
      4bf74fdd
  9. 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
    • Anders Carlsson's avatar
    • 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
  10. Feb 12, 2009
    • 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
  11. Feb 11, 2009
  12. Feb 10, 2009
  13. Feb 09, 2009
    • Douglas Gregor's avatar
      Eliminate TemplateArg so that we only have a single kind of · 67b556a0
      Douglas Gregor authored
      representation for template arguments. Also simplifies the interface
      for ActOnClassTemplateSpecialization and eliminates some annoying
      allocations of TemplateArgs.
      
      My attempt at smart pointers for template arguments lists is
      relatively lame. We can improve it once we're sure that we have the
      right representation for template arguments.
      
      llvm-svn: 64154
      67b556a0
    • Douglas Gregor's avatar
      Start processing template-ids as types when the template-name refers · 8bf4205c
      Douglas Gregor authored
      to a class template. For example, the template-id 'vector<int>' now
      has a nice, sugary type in the type system. What we can do now:
      
        - Parse template-ids like 'vector<int>' (where 'vector' names a
          class template) and form proper types for them in the type system.
        - Parse icky template-ids like 'A<5>' and 'A<(5 > 0)>' properly,
          using (sadly) a bool in the parser to tell it whether '>' should
          be treated as an operator or not.
      
      This is a baby-step, with major problems and limitations:
        - There are currently two ways that we handle template arguments
        (whether they are types or expressions). These will be merged, and,
        most likely, TemplateArg will disappear.
        - We don't have any notion of the declaration of class template
        specializations or of template instantiations, so all template-ids
        are fancy names for 'int' :)
      
      llvm-svn: 64153
      8bf4205c
    • Sebastian Redl's avatar
      Update new expression to make use of Declarator::getSourceRange(). · 1df2bbe7
      Sebastian Redl authored
      References are not objects; implement this in Type::isObjectType().
      
      llvm-svn: 64152
      1df2bbe7
Loading