Skip to content
  1. 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
  2. Feb 04, 2009
  3. Feb 03, 2009
  4. Feb 02, 2009
  5. 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
  6. 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
  7. Jan 29, 2009
  8. Jan 28, 2009
  9. Jan 27, 2009
  10. 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
  11. Jan 19, 2009
  12. 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
  13. Jan 13, 2009
  14. Jan 09, 2009
  15. 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
  16. 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
  17. Jan 06, 2009
  18. 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
  19. Dec 30, 2008
  20. Dec 26, 2008
  21. Dec 24, 2008
    • Douglas Gregor's avatar
      Correct the order in which we cope with end-of-class-definition · 58354036
      Douglas Gregor authored
      semantics and improve our handling of default arguments. Specifically,
      we follow this order:
      
        - As soon as the see the '}' in the class definition, the class is
        complete and we add any implicit declarations (default constructor,
        copy constructor, etc.) to the class.
        - If there are any default function arguments, parse them
        - If there were any inline member function definitions, parse them
      
      As part of this change, we now keep track of the the fact that we've
      seen unparsed default function arguments within the AST. See the new
      ParmVarDecl::hasUnparsedDefaultArg member. This allows us to properly
      cope with calls inside default function arguments to other functions
      where we're making use of the default arguments.
      
      Made some C++ error messages regarding failed initializations more
      specific. 
      
      llvm-svn: 61406
      58354036
  22. Dec 23, 2008
    • Douglas Gregor's avatar
      Don't explicitly represent OverloadedFunctionDecls within · 55297ac4
      Douglas Gregor authored
      DeclContext. Instead, just keep the list of currently-active
      declarations and only build the OverloadedFunctionDecl when we
      absolutely need it.
      
      This is a half-step toward eliminating the need to explicitly build
      OverloadedFunctionDecls that store sets of overloaded
      functions. This was suggested by Argiris a while back, and it's a good
      thing for several reasons: first, it eliminates the messy logic that
      currently tries to keep the OverloadedFunctionDecl in sync with the 
      declarations that are being added. Second, it will (eventually)
      eliminate the need to allocate memory for overload sets, which could
      help performance. Finally, it helps set us up for when name lookup can
      return multiple (possibly ambiguous) results, as can happen with
      lookup of class members in C++.
      
      Next steps: make the IdentifierResolver store overloads as separate
      entries in its list rather than replacing them with an
      OverloadedFunctionDecl now, then see how far we can go toward
      eliminating OverloadedFunctionDecl entirely.
      
      llvm-svn: 61357
      55297ac4
  23. Dec 22, 2008
  24. Dec 19, 2008
  25. Dec 17, 2008
  26. Dec 16, 2008
  27. Dec 15, 2008
    • Douglas Gregor's avatar
      Place constructors and destructors into the DeclContext of the class, · 1349b457
      Douglas Gregor authored
      just like all other members, and remove the special variables in
      CXXRecordDecl to store them. This eliminates a lot of special-case
      code for constructors and destructors, including
      ActOnConstructor/ActOnDeclarator and special lookup rules in
      LookupDecl. The result is far more uniform and manageable.
      
      Diagnose the redeclaration of member functions.
      
      llvm-svn: 61048
      1349b457
Loading