summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Currently all DeclContexts are Decls as well; use cast<Decl> instead of ↵Argyrios Kyrtzidis2009-02-171-8/+2
| | | | | | dyn_cast. llvm-svn: 64805
* DeclContext had its "casting machinery" inside the class definition so that ↵Argyrios Kyrtzidis2009-02-161-2/+46
| | | | | | | | if a new declaration context Decl appeared, the necessary changes would be in one place. Since, now, only DeclNodes.def needs to be modified, move things out-of-line and simplify the DeclContext class. llvm-svn: 64630
* Make DeclContexts maintenance a bit easier.Argyrios Kyrtzidis2009-02-161-1/+1
| | | | | | | | | -In DeclNodes.def, only mark as DeclContexts the top classes that directly derive from DeclContext. If the Decl has subclasses, it should be marked with DECL_CONTEXT_BASE. -Use DeclNodes.def to automate the DeclContext::classof and DeclContext::CastTo definitions. llvm-svn: 64629
* Basic representation of C++ class templates, from Andrew Sutton.Douglas Gregor2009-02-041-1/+2
| | | | llvm-svn: 63750
* Semantic analysis, ASTs, and unqualified name lookup support for C++Douglas Gregor2009-02-031-3/+15
| | | | | | using directives, from Piotr Rak! llvm-svn: 63646
* Add a macro-based enumeration of all of the Decl nodes (like we doDouglas Gregor2009-02-021-225/+27
| | | | | | | with Stmt/Expr nodes), and convert some of the more mundane switch-on-all-decl-kinds uses over to use this new file. llvm-svn: 63570
* Remove many references to ASTContext::getAllocator(), replacing them with ↵Steve Naroff2009-01-271-1/+1
| | | | | | | | calls to the recently added placement new (which uses ASTContext's allocator for memory). Also added ASTContext::Deallocate(). This will simplify runtime replacement of ASTContext's allocator. Keeping the allocator private (and removing getAllocator() entirely) is also goodness. llvm-svn: 63135
* Allocate expresssions through ASTContext (still more work to do).Steve Naroff2009-01-201-0/+29
| | | | | | Add debug hook to DeclContext. llvm-svn: 62605
* Rename DeclContext::insert to DeclContext::makeDeclVisibleInContext and ↵Douglas Gregor2009-01-201-8/+8
| | | | | | document both it and DeclContext::addDecl properly llvm-svn: 62581
* Remove the TopLevelDecls from TranslationUnit, since all of those decls are ↵Douglas Gregor2009-01-201-15/+10
| | | | | | owned by the ASTContext's TranslationUnitDecl. There are definitely some leaking Decls now that I'll tackle tomorrow llvm-svn: 62568
* Remove ScopedDecl, collapsing all of its functionality into Decl, soDouglas Gregor2009-01-201-35/+59
| | | | | | | | | | | | | | | | 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
* Teach DeclContext how to find the primary declaration for any TagDeclDouglas Gregor2009-01-171-29/+7
| | | | | | | | | | | | | even when we are still defining the TagDecl. This is required so that qualified name lookup of a class name within its definition works (see the new bits in test/SemaCXX/qualified-id-lookup.cpp). As part of this, move the nested redefinition checking code into ActOnTag. This gives us diagnostics earlier (when we try to perform the nested redefinition, rather than when we try to complete the 2nd definition) and removes some code duplication. llvm-svn: 62386
* Fix a subtle bug in DeclContext::DestroyDecls().Steve Naroff2009-01-141-4/+8
| | | | llvm-svn: 62205
* Turn off some Destroy calls that are currenly causing double-destruction of ↵Douglas Gregor2009-01-131-1/+5
| | | | | | ScopedDecls. We will re-enable this later, when we have time to fully solve the ownership issue. llvm-svn: 62175
* Cleanup DeclContext::addDecl and DeclContext::insert interface, from Piotr RakDouglas Gregor2009-01-121-6/+5
| | | | llvm-svn: 62122
* Replace DeclContext's vector of ScopedDecl pointers with a linked listDouglas Gregor2009-01-091-2/+11
| | | | | | | | | | | | | | | | | | of ScopedDecls (using the new ScopedDecl::NextDeclInScope pointer). Performance-wise: - It's a net win in memory utilization, since DeclContext is now one pointer smaller than it used to be (std::vectors are typically 3 pointers; we now use 2 pointers) and - Parsing Cocoa.h with -fsyntax-only (with a Release-Asserts Clang) is about 1.9% faster than before, most likely because we no longer have the memory allocations and copying associated with the std::vector. I'll re-enable serialization of DeclContexts once I've sorted out the NextDeclarator/NextDeclInScope question. llvm-svn: 62001
* Make sure that ScopedDecls passed to DeclContext::addDecl are added into ↵Douglas Gregor2009-01-091-1/+1
| | | | | | their lexical context llvm-svn: 61998
* Move property API's up to ObjCContainerDecl (removing a lot of duplicate code).Steve Naroff2009-01-091-0/+1
| | | | | | | | | Add isa/cast/dyncast support for ObjCContainerDecl. Renamed classprop_iterator/begin/end to prop_iterator/begin/end (the class prefix was confusing). More simplifications to Sema::ActOnAtEnd()... Added/changed some FIXME's as a result of the above work. llvm-svn: 61988
* Unify the code for defining tags in C and C++, so that we alwaysDouglas Gregor2009-01-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* This is a large/messy diff that unifies the ObjC AST's with DeclContext.Steve Naroff2009-01-081-10/+20
| | | | | | | | | | | | | | | - 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
* When determining whether a variable is a file-scoped variable, checkDouglas Gregor2009-01-071-2/+2
| | | | | | | out its lookup context (to see through linkage specifications). Addresses <rdar://problem/6477142>. llvm-svn: 61848
* Initial implementation of anonymous unions (and, as a GNU extension,Douglas Gregor2009-01-071-1/+1
| | | | | | | | | | | | structures and classes) in C++. Covers name lookup and the synthesis and member access for the unnamed objects/fields associated with anonymous unions. Some C++ semantic checks are still missing (anonymous unions can't have function members, static data members, etc.), and there is no support for anonymous structs or unions in C. llvm-svn: 61840
* Allow Objective-C entities to be declared within a transparent contextDouglas Gregor2009-01-061-0/+7
| | | | | | nested in the translation unit. This fixes <rdar://problem/6476070>. llvm-svn: 61832
* Minor tweaks to the transparent declcontext patchDouglas Gregor2009-01-061-1/+2
| | | | llvm-svn: 61798
* Introduce support for "transparent" DeclContexts, which areDouglas Gregor2009-01-051-7/+52
| | | | | | | | | | | | | | | | | | | | | | 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
* Don't push OverloadedFunctionDecls onto the chain of declarationsDouglas Gregor2008-12-231-23/+10
| | | | | | | | attached to an identifier. Instead, all overloaded functions will be pushed into scope, and we'll synthesize an OverloadedFunctionDecl on the fly when we need it. llvm-svn: 61386
* Don't explicitly represent OverloadedFunctionDecls withinDouglas Gregor2008-12-231-68/+95
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Add case for the new AST node.Fariborz Jahanian2008-12-201-1/+8
| | | | llvm-svn: 61287
* Don't double-destroy constructors defined out-of-line. This is aDouglas Gregor2008-12-151-1/+0
| | | | | | | half-solution; the real solution is coming when constructors and destructors are treated like all other functions by ActOnDeclarator. llvm-svn: 61037
* Address some comments on the name lookup/DeclContext patch from ChrisDouglas Gregor2008-12-111-10/+8
| | | | llvm-svn: 60897
* Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor2008-12-111-7/+269
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and separates lexical name lookup from qualified name lookup. In particular: * Make DeclContext the central data structure for storing and looking up declarations within existing declarations, e.g., members of structs/unions/classes, enumerators in C++0x enums, members of C++ namespaces, and (later) members of Objective-C interfaces/implementations. DeclContext uses a lazily-constructed data structure optimized for fast lookup (array for small contexts, hash table for larger contexts). * Implement C++ qualified name lookup in terms of lookup into DeclContext. * Implement C++ unqualified name lookup in terms of qualified+unqualified name lookup (since unqualified lookup is not purely lexical in C++!) * Limit the use of the chains of declarations stored in IdentifierInfo to those names declared lexically. * Eliminate CXXFieldDecl, collapsing its behavior into FieldDecl. (FieldDecl is now a ScopedDecl). * Make RecordDecl into a DeclContext and eliminates its Members/NumMembers fields (since one can just iterate through the DeclContext to get the fields). llvm-svn: 60878
* Representation of template type parameters and non-type templateDouglas Gregor2008-12-051-0/+2
| | | | | | | | | | | | | | | parameters, with some semantic analysis: - Template parameters are introduced into template parameter scope - Complain about template parameter shadowing (except in Microsoft mode) Note that we leak template parameter declarations like crazy, a problem we'll remedy once we actually create proper declarations for templates. Next up: dependent types and value-dependent/type-dependent expressions. llvm-svn: 60597
* -Add several ObjC types to Decl::getDeclKindName(), a useful debug hook.Steve Naroff2008-12-011-0/+3
| | | | | | -Start adding support for rewriting @synthesize. llvm-svn: 60368
* Make DeclContext::getLexicalParent reuse DeclContext::getParent.Argyrios Kyrtzidis2008-11-191-4/+1
| | | | llvm-svn: 59651
* Take care another assert:Argyrios Kyrtzidis2008-11-191-0/+9
| | | | | | | | | | | | | | | | | | | | struct A { struct B; }; struct A::B { void m() {} // Assertion failed: getContainingDC(DC) == CurContext && "The next DeclContext should be lexically contained in the current one." }; Introduce DeclContext::getLexicalParent which may be different from DeclContext::getParent when nested-names are involved, e.g: namespace A { struct S; } struct A::S {}; // getParent() == namespace 'A' // getLexicalParent() == translation unit llvm-svn: 59650
* Make the non-const DeclContext::getParent call the const version, instead of ↵Argyrios Kyrtzidis2008-11-191-3/+3
| | | | | | the other way around. llvm-svn: 59646
* Parsing, ASTs, and semantic analysis for the declaration of conversionDouglas Gregor2008-11-071-0/+1
| | | | | | | | | | | | | functions in C++, e.g., struct X { operator bool() const; }; Note that these conversions don't actually do anything, since we don't yet have the ability to use them for implicit or explicit conversions. llvm-svn: 58860
* Parsing, representation, and preliminary semantic analysis of destructors.Douglas Gregor2008-11-051-0/+1
| | | | | | | | | | | Implicit declaration of destructors (when necessary). Extended Declarator to store information about parsed constructors and destructors; this will be extended to deal with declarators that name overloaded operators (e.g., "operator +") and user-defined conversion operators (e.g., "operator int"). llvm-svn: 58767
* Add support for parsing and representing C++ constructor declarations.Douglas Gregor2008-10-311-0/+1
| | | | | | | | | | | | | | | Notes: - Constructors are never found by name lookup, so they'll never get pushed into any scope. Instead, they are stored as an OverloadedFunctionDecl in CXXRecordDecl for easy overloading. - There's a new action isCurrentClassName that determines whether an identifier is the name of the innermost class currently being defined; we use this to identify the declarator-id grammar rule that refers to a type-name. - MinimalAction does *not* support parsing constructors. - We now handle virtual and explicit function specifiers. llvm-svn: 58499
* Preliminary support for function overloadingDouglas Gregor2008-10-211-2/+9
| | | | llvm-svn: 57909
* Simplify handling of struct/union/class tags.Argyrios Kyrtzidis2008-10-151-5/+4
| | | | | | | Instead of using two sets of Decl kinds (Struct/Union/Class and CXXStruct/CXXUnion/CXXClass), use one 'Record' and one 'CXXRecord' Decl kind and make tag kind a property of TagDecl. Cleans up the code a bit and better reflects that Decl class structure. llvm-svn: 57541
* Improve the const-ness of a few methods.Argyrios Kyrtzidis2008-10-121-3/+3
| | | | | | No functionality change. llvm-svn: 57417
* Implement more efficient Decl <-> DeclContext conversions.Argyrios Kyrtzidis2008-10-121-10/+10
| | | | | | | | When the static type on the Decl side is a subclass of DeclContext the compiler will use a "inlinable" static_cast, instead of always using an out-of-line function call. Note, though, that the isa<> check still uses an out-of-line function call. llvm-svn: 57415
* Final phase of converting BlockDecls over to DeclContext. This is ↵Steve Naroff2008-10-101-0/+2
| | | | | | unfortunately a largish/complex diff, however it was necessry to pass all the current block tests. llvm-svn: 57337
* - Add BlockDecl AST node.Steve Naroff2008-10-081-0/+3
| | | | | | | | | | - Modify BlockExpr to reference the BlockDecl. This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?). Still some follow-up work to finish this (forthcoming). llvm-svn: 57298
* Added ObjCAtDefsFieldDecl to represent FieldDecls created by @defs.Ted Kremenek2008-08-201-1/+6
| | | | | | This fixes an ownership issue where FieldDecls could be owned both by an ObjCInterfaceDecl and a RecordDecl. llvm-svn: 55037
* More #include cleaningDaniel Dunbar2008-08-111-0/+1
| | | | | | | | - Drop Expr.h,RecordLayout.h from ASTContext.h (for DeclBase.h and SourceLocation.h) - Move ASTContext constructor into implementation llvm-svn: 54627
* Add some C++ Decl statistics.Argyrios Kyrtzidis2008-08-101-3/+12
| | | | llvm-svn: 54604
* Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.Chris Lattner2008-06-171-0/+1
| | | | | | Patch by David Chisnall! llvm-svn: 52422
* Added new C++ AST Decl subclasses.Argyrios Kyrtzidis2008-06-091-0/+8
| | | | llvm-svn: 52155
OpenPOWER on IntegriCloud