Skip to content
  1. Apr 12, 2009
  2. Apr 09, 2009
  3. Mar 30, 2009
  4. Mar 29, 2009
  5. Mar 28, 2009
    • Chris Lattner's avatar
      Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for a · 83f095cc
      Chris Lattner authored
      pointer.  Its purpose in life is to be a glorified void*, but which does not
      implicitly convert to void* or other OpaquePtr's with a different UID.
      
      Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>.  Change the 
      entire parser/sema interface to use DeclPtrTy instead of DeclTy*.  This
      makes the C++ compiler enforce that these aren't convertible to other opaque
      types.
      
      We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc,
      but I don't plan to do that in the short term.
      
      The one outstanding known problem with this patch is that we lose the 
      bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to
      bitmangle the success bit into the low bit of DeclPtrTy.  I will rectify
      this with a subsequent patch.
      
      llvm-svn: 67952
      83f095cc
    • Anders Carlsson's avatar
      Revert Sebastian's rvalue patch (r67870) since it caused test failures in · 72f307a2
      Anders Carlsson authored
      SemaCXX//overload-member-call.cpp
      SemaCXX//overloaded-operator.cpp
      SemaTemplate//instantiate-method.cpp
      
      llvm-svn: 67912
      72f307a2
  6. Mar 27, 2009
  7. Mar 24, 2009
    • Douglas Gregor's avatar
      Type::isObjectType now implements the (more sensible) C++ definition · 64259f51
      Douglas Gregor authored
      of "object type" rather than the C definition of "object type". The
      difference is that C's "object type" excludes incomplete types such as
      
        struct X;
      
      However, C's definition also makes it far too easy to use isObjectType
      as a means to detect incomplete types when in fact we should use other
      means (e.g., Sema::RequireCompleteType) that cope with C++ semantics,
      including template instantiation.
      
      I've already audited every use of isObjectType and isIncompleteType to
      ensure that they are doing the right thing for both C and C++, so this
      is patch does not change any functionality.
      
      llvm-svn: 67648
      64259f51
  8. Mar 23, 2009
  9. Mar 17, 2009
  10. Mar 14, 2009
  11. Mar 13, 2009
    • Douglas Gregor's avatar
      Refactor the way we handle operator overloading and template · 1baf54e1
      Douglas Gregor authored
      instantiation for binary operators. This change moves most of the
      operator-overloading code from the parser action ActOnBinOp to a new,
      parser-independent semantic checking routine CreateOverloadedBinOp. 
      
      Of particular importance is the fact that CreateOverloadedBinOp does
      *not* perform any name lookup based on the current parsing context (it
      doesn't take a Scope*), since it has to be usable during template
      instantiation, when there is no scope information. Rather, it takes a
      pre-computed set of functions that are visible from the context or via
      argument-dependent lookup, and adds to that set any member operators
      and built-in operator candidates. The set of functions is computed in
      the parser action ActOnBinOp based on the current context (both
      operator name lookup and argument-dependent lookup). Within a
      template, the set computed by ActOnBinOp is saved within the
      type-dependent AST node and is augmented with the results of
      argument-dependent name lookup at instantiation time (see
      TemplateExprInstantiator::VisitCXXOperatorCallExpr).
      
      Sadly, we can't fully test this yet. I'll follow up with template
      instantiation for sizeof so that the real fun can begin.
      
      llvm-svn: 66923
      1baf54e1
    • Douglas Gregor's avatar
      Improve the representation of operator expressions like "x + y" within · d2b7ef6e
      Douglas Gregor authored
      C++ templates. In particular, keep track of the overloaded operators
      that are visible from the template definition, so that they can be
      merged with those operators visible via argument-dependent lookup at
      instantiation time. 
      
      Refactored the lookup routines for argument-dependent lookup and for
      operator name lookup, so they can be called without immediately adding
      the results to an overload set.
      
      Instantiation of these expressions is completely wrong. I'll work on
      that next.
      
      llvm-svn: 66851
      d2b7ef6e
  12. Feb 28, 2009
  13. Feb 27, 2009
    • 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
  14. Feb 26, 2009
  15. Feb 19, 2009
  16. Feb 18, 2009
    • 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
  17. Feb 17, 2009
  18. Feb 12, 2009
    • 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
    • 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
    • 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
  19. Feb 11, 2009
    • Douglas Gregor's avatar
      Add semantic checking for template arguments that correspond to · 6f233ef1
      Douglas Gregor authored
      non-type template parameters that are references to functions or
      pointers to member functions. Did a little bit of refactoring so that
      these two cases, along with the handling of non-type template
      parameters that are pointers to functions, are handled by the same
      path. 
      
      Also, tweaked FixOverloadedFunctionReference to cope with member
      function pointers. This is a necessary step for getting all of the fun
      member pointer conversions working outside of template arguments, too.
      
      llvm-svn: 64277
      6f233ef1
    • Douglas Gregor's avatar
      Add partial semantic checking of template arguments that are meant for · 3a7796bc
      Douglas Gregor authored
      non-type template parameters of pointer-to-object and
      pointer-to-function type. The most fun part of this is the use of
      overload resolution to pick a function from the set of overloaded
      functions that comes in as a template argument.
      
      Also, fixed two minor bugs in this area:
        - We were allowing non-type template parameters of type pointer to
        void.
        - We weren't patching up an expression that refers to an overloaded
        function set via "&f" properly.
      
      We're still not performing complete checking of the expression to be
      sure that it is referring to an object or function with external
      linkage (C++ [temp.arg.nontype]p1).
      
      llvm-svn: 64266
      3a7796bc
  20. Feb 09, 2009
  21. 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
  22. Feb 05, 2009
  23. Feb 04, 2009
    • Sebastian Redl's avatar
      18f8ff62
    • Douglas Gregor's avatar
      Bring operator name lookup (as required for C++ operator overloading) · 94eabf33
      Douglas Gregor authored
      into the general name-lookup fold. This cleans up some ugly,
      not-quite-working code in the handling of operator overloading.
      
      llvm-svn: 63735
      94eabf33
    • Douglas Gregor's avatar
      Fix our semantic analysis of · b8a9a41d
      Douglas Gregor authored
        unqualified-id '('
      
      in C++. The unqualified-id might not refer to any declaration in our
      current scope, but declarations by that name might be found via
      argument-dependent lookup. We now do so properly.
      
      As part of this change, CXXDependentNameExpr, which was previously
      designed to express the unqualified-id in the above constructor within
      templates, has become UnresolvedFunctionNameExpr, which does
      effectively the same thing but will work for both templates and
      non-templates.
      
      Additionally, we cope with all unqualified-ids, since ADL also applies
      in cases like
      
        operator+(x, y)
      
      llvm-svn: 63733
      b8a9a41d
    • Douglas Gregor's avatar
      Initial implementation of argument dependent lookup (a.k.a. ADL, · e254f90d
      Douglas Gregor authored
      a.k.a. Koenig lookup) in C++. Most of the pieces are in place, but for
      two:
      
        - In an unqualified call g(x), even if the name does not refer to
          anything in the current scope, we can still find functions named
          "g" based on ADL. We don't yet have this ability.
        - ADL will need updating for friend functions and templates.
      
      llvm-svn: 63692
      e254f90d
  24. Feb 02, 2009
    • Douglas Gregor's avatar
      Steve set me straight on this one. GCC was right, EDG was wrong: the · bb2e6883
      Douglas Gregor authored
      direct-initialization following a user-defined conversion can select
      any constructor; it just can't employ any user-defined
      conversions. So we ban those conversions and classify the constructor
      call based on the relationship between the "from" and "to" types in
      the conversion.
      
      llvm-svn: 63554
      bb2e6883
  25. Jan 31, 2009
    • Douglas Gregor's avatar
      Improve our handling of the second step in a user-defined conversion · 576e98cc
      Douglas Gregor authored
      sequence. Previously, we weren't permitting the second step to call
      copy constructors, which left user-defined conversion sequences
      surprisingly broken.
      
      Now, we perform overload resolution among all of the constructors, but
      only accept the result if it makes the conversion a standard
      conversion. Note that this behavior is different from both GCC and EDG
      (which don't agree with each other, either); I've submitted a core
      issue on the matter.
      
      llvm-svn: 63450
      576e98cc
  26. Jan 30, 2009
    • Douglas Gregor's avatar
      Eliminated LookupCriteria, whose creation was causing a bottleneck for · ed8f2887
      Douglas Gregor authored
      LookupName et al. Instead, use an enum and a bool to describe its
      contents.
      
      Optimized the C/Objective-C path through LookupName, eliminating any
      unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing
      some code and arguments that are no longer used.
      
      Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers
      over to LookupName, LookupQualifiedName, or LookupParsedName, as
      appropriate.
      
      All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and
      -disable-free. Plus, we're down to three name-lookup routines.
      
      llvm-svn: 63354
      ed8f2887
  27. Jan 28, 2009
  28. Jan 25, 2009
  29. Jan 20, 2009
    • Douglas Gregor's avatar
      Remove ScopedDecl, collapsing all of its functionality into Decl, so · 6e6ad602
      Douglas Gregor authored
      that every declaration lives inside a DeclContext.
      
      Moved several things that don't have names but were ScopedDecls (and,
      therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
      including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
      store empty DeclarationNames for these things, nor do we try to insert
      them into DeclContext's lookup structure.
      
      The serialization tests are temporarily disabled. We'll re-enable them
      once we've sorted out the remaining ownership/serialiazation issues
      between DeclContexts and TranslationUnion, DeclGroups, etc.
      
      llvm-svn: 62562
      6e6ad602
Loading