Skip to content
  1. Mar 10, 2009
    • Douglas Gregor's avatar
      Implement template instantiation for ClassTemplateSpecializationTypes, · c40290e4
      Douglas Gregor authored
      such as replacing 'T' in vector<T>. There are a few aspects to this:
      
        - Extend TemplateArgument to allow arbitrary expressions (an
          Expr*), and switch ClassTemplateSpecializationType to store
          TemplateArguments rather than it's own type-or-expression
          representation.
      
        - ClassTemplateSpecializationType can now store dependent types. In
          that case, the canonical type is another
          ClassTemplateSpecializationType (with default template arguments
          expanded) rather than a declaration (we don't build Decls for
          dependent types).
      
        - Split ActOnClassTemplateId into ActOnClassTemplateId (called from
          the parser) and CheckClassTemplateId (called from
          ActOnClassTemplateId and InstantiateType). They're smart enough to
          handle dependent types, now.
      
      llvm-svn: 66509
      c40290e4
  2. Mar 09, 2009
  3. Mar 06, 2009
  4. Mar 05, 2009
  5. Mar 03, 2009
    • Douglas Gregor's avatar
      Implement the basics of implicit instantiation of class templates, in · 463421de
      Douglas Gregor authored
      response to attempts to diagnose an "incomplete" type. This will force
      us to use DiagnoseIncompleteType more regularly (rather than looking at
      isIncompleteType), but that's also a good thing.
      
      Implicit instantiation is still very simplistic, and will create a new
      definition for the class template specialization (as it should) but it
      only actually instantiates the base classes and attaches
      those. Actually instantiating class members will follow. 
      
      Also, instantiate the types of non-type template parameters before
      checking them,  allowing, e.g., 
      
        template<typename T, T Value> struct Constant; 
       
      to work properly.
      
      llvm-svn: 65924
      463421de
  6. 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
  7. 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
  8. Feb 17, 2009
  9. 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
  10. Feb 09, 2009
    • Douglas Gregor's avatar
      Make Sema::getTypeName return the opaque pointer of a QualType rather · 9817f4a7
      Douglas Gregor authored
      than a Decl, which gives us some more flexibility to express the
      results with the type system. There are no clients using this
      flexibility yet, but it's meant to be able to describe qualified names
      as written in the source (e.g., "foo::type") or template-ids that name
      a class template specialization (e.g., "std::vector<INT>").
      
      DeclSpec's TST_typedef has become TST_typename, to reflect its use to
      describe types found by name (that may or may not be typedefs). The
      type representation of a DeclSpec with TST_typename is an opaque
      QualType pointer. All users of TST_typedef, both direct and indirect,
      have been updated for these changes.
      
      llvm-svn: 64141
      9817f4a7
  11. 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
  12. Feb 04, 2009
  13. Feb 03, 2009
  14. Feb 02, 2009
  15. 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
  16. 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
  17. Jan 29, 2009
  18. Jan 28, 2009
  19. Jan 27, 2009
  20. Jan 20, 2009
    • Chris Lattner's avatar
      Fix a crash Anders' was seeing due to free'ing an invalid pointer · 5742c1ed
      Chris Lattner authored
      caused by my previous commit.
      
      llvm-svn: 62613
      5742c1ed
    • 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
  21. Jan 19, 2009
  22. Jan 14, 2009
    • Douglas Gregor's avatar
      Refactor name lookup. · 34074326
      Douglas Gregor authored
      This change refactors and cleans up our handling of name lookup with
      LookupDecl. There are several aspects to this refactoring:
      
        - The criteria for name lookup is now encapsulated into the class
        LookupCriteria, which replaces the hideous set of boolean values
        that LookupDecl currently has.
      
        - The results of name lookup are returned in a new class
        LookupResult, which can lazily build OverloadedFunctionDecls for
        overloaded function sets (and, eventually, eliminate the need to
        allocate member for OverloadedFunctionDecls) and contains a
        placeholder for handling ambiguous name lookup (for C++).
      
        - The primary entry points for name lookup are now LookupName (for
          unqualified name lookup) and LookupQualifiedName (for qualified
          name lookup). There is also a convenience function
          LookupParsedName that handles qualified/unqualified name lookup
          when given a scope specifier. Together, these routines are meant
          to gradually replace the kludgy LookupDecl, but this won't happen
          until after we have base class lookup (which forces us to cope
          with ambiguities).
      
        - Documented the heck out of name lookup. Experimenting a little
          with using Doxygen's member groups to make some sense of the Sema
          class. Feedback welcome!
      
        - Fixes some lingering issues with name lookup for
        nested-name-specifiers, which now goes through
        LookupName/LookupQualifiedName. 
      
      llvm-svn: 62245
      34074326
    • Douglas Gregor's avatar
      Introduce support for C++0x explicit conversion operators (N2437) · 5fb53972
      Douglas Gregor authored
      Small cleanup in the handling of user-defined conversions. 
      
      Also, implement an optimization when constructing a call. We avoid
      recomputing implicit conversion sequences and instead use those
      conversion sequences that we computed as part of overload resolution.
      
      llvm-svn: 62231
      5fb53972
    • Ted Kremenek's avatar
      FunctionDecl::setParams() now uses the allocator associated with ASTContext to... · 4ba36fcc
      Ted Kremenek authored
      FunctionDecl::setParams() now uses the allocator associated with ASTContext to allocate the array of ParmVarDecl*'s.
      
      llvm-svn: 62203
      4ba36fcc
  23. Jan 13, 2009
  24. Jan 09, 2009
  25. Jan 08, 2009
    • Douglas Gregor's avatar
      Unify the code for defining tags in C and C++, so that we always · 82ac25e4
      Douglas Gregor authored
      introduce a Scope for the body of a tag. This reduces the number of
      semantic differences between C and C++ structs and unions, and will
      help with other features (e.g., anonymous unions) in C. Some important
      points:
      
        - Fields are now in the "member" namespace (IDNS_Member), to keep
          them separate from tags and ordinary names in C. See the new test
          in Sema/member-reference.c for an example of why this matters. In
          C++, ordinary and member name lookup will find members in both the
          ordinary and member namespace, so the difference between
          IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but
          only in C++!). 
        - We always introduce a Scope and push a DeclContext when we're
          defining a tag, in both C and C++. Previously, we had different
          actions and different Scope/CurContext behavior for enums, C
          structs/unions, and C++ structs/unions/classes. Now, it's one pair
          of actions. (Yay!)
      
      There's still some fuzziness in the handling of struct/union/enum
      definitions within other struct/union/enum definitions in C. We'll
      need to do some more cleanup to eliminate some reliance on CurContext
      before we can solve this issue for real. What we want is for something
      like this:
      
        struct X {
          struct T { int x; } t;
        };
      
      to introduce T into translation unit scope (placing it at the
      appropriate point in the IdentifierResolver chain, too), but it should
      still have struct X as its lexical declaration
      context. PushOnScopeChains isn't smart enough to do that yet, though,
      so there's a FIXME test in nested-redef.c
      
      llvm-svn: 61940
      82ac25e4
    • Steve Naroff's avatar
      This is a large/messy diff that unifies the ObjC AST's with DeclContext. · 35c62ae6
      Steve Naroff authored
      - ObjCContainerDecl's (ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl), ObjCCategoryImpl, & ObjCImplementation are all DeclContexts.
      - ObjCMethodDecl is now a ScopedDecl (so it can play nicely with DeclContext).
      - ObjCContainerDecl now does iteration/lookup using DeclContext infrastructure (no more linear search:-)
      - Removed ASTContext argument to DeclContext::lookup(). It wasn't being used and complicated it's use from an ObjC AST perspective.
      - Added Sema::ProcessPropertyDecl() and removed Sema::diagnosePropertySetterGetterMismatch().
      - Simplified Sema::ActOnAtEnd() considerably. Still more work to do.
      - Fixed an incorrect casting assumption in Sema::getCurFunctionOrMethodDecl(), now that ObjCMethodDecl is a ScopedDecl.
      - Removed addPropertyMethods from ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl.
      
      This passes all the tests on my machine. Since many of the changes are central to the way ObjC finds it's methods, I expect some fallout (and there are still a handful of FIXME's). Nevertheless, this should be a step in the right direction.
      
      llvm-svn: 61929
      35c62ae6
  26. Jan 07, 2009
    • Douglas Gregor's avatar
      Finished semantic analysis of anonymous unions in C++. · f4d33279
      Douglas Gregor authored
      Duplicate-member checking within classes is still a little messy, and
      anonymous unions are still completely broken in C. We'll need to unify
      the handling of fields in C and C++ to make this code applicable in
      both languages.
      
      llvm-svn: 61878
      f4d33279
  27. Jan 06, 2009
  28. Jan 05, 2009
    • Sebastian Redl's avatar
      PODness and Type Traits · baad4e76
      Sebastian Redl authored
      Make C++ classes track the POD property (C++ [class]p4)
      Track the existence of a copy assignment operator.
      Implicitly declare the copy assignment operator if none is provided.
      Implement most of the parsing job for the G++ type traits extension.
      Fully implement the low-hanging fruit of the type traits:
      __is_pod: Whether a type is a POD.
      __is_class: Whether a type is a (non-union) class.
      __is_union: Whether a type is a union.
      __is_enum: Whether a type is an enum.
      __is_polymorphic: Whether a type is polymorphic (C++ [class.virtual]p1).
      
      llvm-svn: 61746
      baad4e76
    • Douglas Gregor's avatar
      Introduce support for "transparent" DeclContexts, which are · 07665a69
      Douglas Gregor authored
      DeclContexts whose members are visible from enclosing DeclContexts up
      to (and including) the innermost enclosing non-transparent
      DeclContexts. Transparent DeclContexts unify the mechanism to be used
      for various language features, including C enumerations, anonymous
      unions, C++0x inline namespaces, and C++ linkage
      specifications. Please refer to the documentation in the Clang
      internals manual for more information.
      
      Only enumerations and linkage specifications currently use transparent
      DeclContexts.
      
      Still to do: use transparent DeclContexts to implement anonymous
      unions and GCC's anonymous structs extension, and, later, the C++0x
      features. We also need to tighten up the DeclContext/ScopedDecl link
      to ensure that every ScopedDecl is in a single DeclContext, which
      will ensure that we can then enforce ownership and reduce the memory
      footprint of DeclContext.
      
      llvm-svn: 61735
      07665a69
  29. Dec 30, 2008
Loading