summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor2008-12-111-35/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Extend DeclarationName to support C++ overloaded operators, e.g.,Douglas Gregor2008-11-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | operator+, directly, using the same mechanism as all other special names. Removed the "special" identifiers for the overloaded operators from the identifier table and IdentifierInfo data structure. IdentifierInfo is back to representing only real identifiers. Added a new Action, ActOnOperatorFunctionIdExpr, that builds an expression from an parsed operator-function-id (e.g., "operator +"). ActOnIdentifierExpr used to do this job, but operator-function-ids are no longer represented by IdentifierInfo's. Extended Declarator to store overloaded operator names. Sema::GetNameForDeclarator now knows how to turn the operator name into a DeclarationName for the overloaded operator. Except for (perhaps) consolidating the functionality of ActOnIdentifier, ActOnOperatorFunctionIdExpr, and ActOnConversionFunctionExpr into a common routine that builds an appropriate DeclRefExpr by looking up a DeclarationName, all of the work on normalizing declaration names should be complete with this commit. llvm-svn: 59526
* Eliminate all of the placeholder identifiers used for constructors,Douglas Gregor2008-11-171-50/+2
| | | | | | | | | destructors, and conversion functions. The placeholders were used to work around the fact that the parser and some of Sema really wanted declarators to have simple identifiers; now, the code that deals with declarators will use DeclarationNames. llvm-svn: 59469
* Introduction the DeclarationName class, as a single, general method ofDouglas Gregor2008-11-171-3/+41
| | | | | | | | representing the names of declarations in the C family of languages. DeclarationName is used in NamedDecl to store the name of the declaration (naturally), and ObjCMethodDecl is now a NamedDecl. llvm-svn: 59441
* Introduce ScopedDecl::getLexicalDeclContext() which is different from ↵Argyrios Kyrtzidis2008-11-091-0/+23
| | | | | | | | | | | | | ScopedDecl::getDeclContext() when there are nested-names. e.g.: namespace A { void f(); // SemanticDC (getDeclContext) == LexicalDC (getLexicalDeclContext) == 'namespace A' } void A::f(); // SemanticDC == namespace 'A' // LexicalDC == global namespace llvm-svn: 58948
* Parsing, ASTs, and semantic analysis for the declaration of overloadedDouglas Gregor2008-11-061-0/+9
| | | | | | | | | operators in C++. Overloaded operators can be called directly via their operator-function-ids, e.g., "operator+(foo, bar)", but we don't yet implement the semantics of operator overloading to handle, e.g., "foo + bar". llvm-svn: 58817
* LinkageSpecDecl is c++ specific, move it to DeclCXXChris Lattner2008-11-041-7/+0
| | | | llvm-svn: 58704
* Fix crash reported in PR2923 where a function declared using ↵Ted Kremenek2008-10-291-3/+13
| | | | | | typeof(another_function) would have FunctionDecl::getNumParams() return the number of parameters in the original function type and not the number of parameters in the actual FunctionDecl. llvm-svn: 58392
* Simplify handling of struct/union/class tags.Argyrios Kyrtzidis2008-10-151-12/+3
| | | | | | | 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
* Final phase of converting BlockDecls over to DeclContext. This is ↵Steve Naroff2008-10-101-3/+2
| | | | | | unfortunately a largish/complex diff, however it was necessry to pass all the current block tests. llvm-svn: 57337
* Instantiate the BlockDecl in ActOnBlockStart() so we can use it as a ↵Steve Naroff2008-10-081-3/+2
| | | | | | | | DeclContext. This required changes to attach the compound statement later on (like we do for functions). llvm-svn: 57304
* - Add BlockDecl AST node.Steve Naroff2008-10-081-0/+24
| | | | | | | | | | - 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
* Add getTypeSpecStartLoc() to VarDecls and FunctionDecls.Steve Naroff2008-10-031-4/+7
| | | | | | | This is a temporary solution to help with the block rewriter (though it certainly has general utility). Once DeclGroup's are implemented, this SourceLocation should be stored with it (since it applies to all the decls). llvm-svn: 56985
* Change struct forward declarations and definitions to use unique ↵Ted Kremenek2008-09-051-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RecordDecls, as opposed to creating a single RecordDecl and reusing it. This change effects both RecordDecls and CXXRecordDecls, but does not effect EnumDecls (yet). The motivation of this patch is as follows: - Capture more source information, necessary for refactoring/rewriting clients. - Pave the way to resolve ownership issues with RecordDecls with the forthcoming addition of DeclGroups. Current caveats: - Until DeclGroups are in place, we will leak RecordDecls not explicitly referenced by the AST. For example: typedef struct { ... } x; The RecordDecl for the struct will be leaked because the TypedefDecl doesn't refer to it. This will be solved with DeclGroups. - This patch also (temporarily) breaks CodeGen. More below. High-level changes: - As before, TagType still refers to a TagDecl, but it doesn't own it. When a struct/union/class is first referenced, a RecordType and RecordDecl are created for it, and the RecordType refers to that RecordDecl. Later, if a new RecordDecl is created, the pointer to a RecordDecl in RecordType is updated to point to the RecordDecl that defines the struct/union/class. - TagDecl and RecordDecl now how a method 'getDefinition()' to return the TagDecl*/RecordDecl* that refers to the TagDecl* that defines a particular enum/struct/class/union. This is useful from going from a RecordDecl* that defines a forward declaration to the RecordDecl* that provides the actual definition. Note that this also works for EnumDecls, except that in this case there is no distinction between forward declarations and definitions (yet). - Clients should no longer assume that 'isDefinition()' returns true from a RecordDecl if the corresponding struct/union/class has been defined. isDefinition() only returns true if a particular RecordDecl is the defining Decl. Use 'getDefinition()' instead to determine if a struct has been defined. - The main changes to Sema happen in ActOnTag. To make the changes more incremental, I split off the processing of enums and structs et al into two code paths. Enums use the original code path (which is in ActOnTag) and structs use the ActOnTagStruct. Eventually the two code paths will be merged, but the idea was to preserve the original logic both for comparison and not to change the logic for both enums and structs all at once. - There is NO CHAINING of RecordDecls for the same RecordType. All RecordDecls that correspond to the same type simply have a pointer to that type. If we need to figure out what are all the RecordDecls for a given type we can build a backmap. - The diff in CXXRecordDecl.[cpp,h] is actually very small; it just mimics the changes to RecordDecl. For some reason 'svn' marks the entire file as changed. Why is CodeGen broken: - Codegen assumes that there is an equivalence between RecordDecl* and RecordType*. This was true before because we only created one RecordDecl* for a given RecordType*, but it is no longer true. I believe this shouldn't be too hard to change, but the patch was big enough as it is. I have tested this patch on both the clang test suite, and by running the static analyzer over Postgresql and a large Apple-internal project (mix of Objective-C and C). llvm-svn: 55839
* Remove "NextDecl" from RecordDecl. This change touches many files that ↵Ted Kremenek2008-09-051-37/+6
| | | | | | | | where RecordDecl or CXXRecordDecl was constructed, always with an argument of 'NULL' for the previous declaration. The motivation behind this change is that chaining the RecordDecls is simply unnecessary. Once we create multiple RecordDecls for the same struct/union/class, clients that care about all the declarations of the same struct can build a back map by seeing which Decls refer to the same RecordType. llvm-svn: 55821
* RecordDecl:Ted Kremenek2008-09-021-60/+56
| | | | | | | | - Remove method 'isForwardDecl'; this functionality is already provided by 'isDefinition()' - Move method definitions to be co-located with other RecordDecl methods. llvm-svn: 55649
* RecordDecl:Ted Kremenek2008-09-021-0/+12
| | | | | | | | | - Added method 'isForwardDeclaration', a predicate method that returns true if a RecordDecl represents a forward declaration. - Added method 'getDefinitionDecl', a query method that returns a pointer to the RecordDecl that provides the actual definition of a struct/union. llvm-svn: 55642
* CXXRecordDecl and RecordDecl:Ted Kremenek2008-09-021-6/+37
| | | | | | | | | | | | | | | | | | | - Change constructor and create methods to accept a CXXRecordDecl* (RecordDecl*) instead of a ScopedDecl* for PrevDecl. This causes the type checking to be more tight and doesn't break any code. RecordDecl: - Don't use the NextDeclarator field in ScopedDecl to represent the previous declaration. This is a conflated use of the NextDeclarator field, which will be removed anyway when DeclGroups are fully implemented. - Instead, represent (a soon to be implemented) chain of RecordDecls using a NextDecl field. The last RecordDecl in the chain is always the 'defining' RecordDecl that owns the FieldDecls. The other RecordDecls in the chain are forward declarations. llvm-svn: 55640
* More #include cleaningDaniel Dunbar2008-08-111-0/+2
| | | | | | | | - Drop Expr.h,RecordLayout.h from ASTContext.h (for DeclBase.h and SourceLocation.h) - Move ASTContext constructor into implementation llvm-svn: 54627
* Destroy and delete the FieldDecl members of a RecordDecl.Argyrios Kyrtzidis2008-08-081-0/+13
| | | | llvm-svn: 54527
* Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.Chris Lattner2008-06-171-0/+6
| | | | | | Patch by David Chisnall! llvm-svn: 52422
* Silence uninitialized value warning during Release build.Ted Kremenek2008-06-161-4/+5
| | | | llvm-svn: 52375
* -Add DeclChain member to DeclContext.Argyrios Kyrtzidis2008-06-101-1/+1
| | | | | | | -ScopedDecls get chained to their DeclContext. -DeclContext's DeclChain replaces FunctionDecl's DeclChain and EnumDecl's ElementList. llvm-svn: 52164
* -Changes to TagDecl:Argyrios Kyrtzidis2008-06-091-1/+8
| | | | | | | | | Added TagKind enum. Added getTagKind() method. Added convenience methods: isEnum(), isStruct(), isUnion(), isClass(). -RecordDecl/CXXRecordDecl::Create() accept a TagKind enum instead of a DeclKind one. llvm-svn: 52160
* Added new C++ AST Decl subclasses.Argyrios Kyrtzidis2008-06-091-1/+1
| | | | llvm-svn: 52155
* Move Decl and DeclContext implementations into a new DeclBase.cpp file.Argyrios Kyrtzidis2008-06-041-312/+1
| | | | llvm-svn: 51936
* fix decl attributes cleaningNuno Lopes2008-06-011-8/+16
| | | | | | this plugs the leak of attributes and also fixes a crash in the test llvm-svn: 51862
* Don't swap function decls, and add them to the scope as they are Eli Friedman2008-05-271-57/+0
| | | | | | | | | | | | | encountered. Mixing up the decls is unintuitive, and confuses the AST destruction code. Fixes PR2360. Note that there is a need to look up the characteristics and declarations of a function associated with a particular name or decl, but the original swapping code doesn't solve it properly. http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001644.html is one suggestion for how to fix that. llvm-svn: 51584
* Call the correct destructor.Ted Kremenek2008-05-241-1/+1
| | | | llvm-svn: 51544
* Tweak AST dumper for ObjC ivars.Steve Naroff2008-05-231-0/+1
| | | | llvm-svn: 51463
* Reclaim memory from chains of ScopedDecls, and reclaim memory for the ↵Ted Kremenek2008-05-201-0/+37
| | | | | | initializers of EnumConstantDecls. llvm-svn: 51299
* Reclaim memory allocated for ParmVarDecl's in FunctionDecl::Destroy.Ted Kremenek2008-05-201-1/+6
| | | | | | | | Fixed a bug in ParmVarDecl::param_end(): Handle the case where there are no ParmVarDecls for a FunctionDecl, but its function prototype has formal arguments (can happen with typedefs). llvm-svn: 51297
* Remove unnecessary #include (introduced by a recent patch of mine).Ted Kremenek2008-05-201-1/+0
| | | | llvm-svn: 51288
* Try to plug some memory leaks...Ted Kremenek2008-05-201-41/+13
| | | | | | | | | | | | | | | | 1) Sema::ParseAST now constructs a TranslationUnit object to own the top-level Decls, which releases the top-level Decls upon exiting ParseAST. 2) Bug fix: TranslationUnit::~TranslationUnit handles the case where a Decl is added more than once as a top-level Decl. 3) Decl::Destroy is now a virtual method, obviating the need for a special dispatch based on DeclKind. 3) FunctionDecl::Destroy now releases its Body using its Destroy method. 4) Added Stmt::Destroy and Stmt::DestroyChildren, which recursively delete the child ASTs of a Stmt and call their dstors. We may need to special case dstor/Destroy methods for particular Stmt subclasses that own other dynamically allocated objects besides AST nodes. 5) REGRESSION: We temporarily are not deallocating attributes; a FIXME is provided. llvm-svn: 51286
* Simplify FunctionDecl::AddRedeclaration a bit by using std::swap.Chris Lattner2008-05-041-11/+28
| | | | | | | Fix 'swapping' of attributes to not insert null values into the DeclAttrs map. llvm-svn: 50612
* Parsing of namespaces:Argyrios Kyrtzidis2008-04-271-3/+18
| | | | | | | | | -NamespaceDecl for the AST -Checks for name clashes between namespaces and tag/normal declarations. This commit doesn't implement proper name lookup for namespaces. llvm-svn: 50321
* "This patch renames Chris Lattner2008-04-221-12/+12
| | | | | | | | | | | DeclContext *CtxDecl -> DeclContext *DeclCtx DeclContext *CD -> DeclContext *DC It makes the code more consistent." Patch by Zhongxing Xu! llvm-svn: 50105
* Clean up handling of function redeclarationsDouglas Gregor2008-04-211-0/+77
| | | | llvm-svn: 50021
* Addition of TranslationUnitDecl to the AST:Argyrios Kyrtzidis2008-04-171-1/+7
| | | | | | | | -Added TranslationUnitDecl class to serve as top declaration context -ASTContext gets a TUDecl member and a getTranslationUnitDecl() function -All ScopedDecls get the TUDecl as DeclContext when declared at global scope llvm-svn: 49855
* New AST class for property implementation declarations.Fariborz Jahanian2008-04-161-0/+7
| | | | llvm-svn: 49821
* Remove FileVarDecl and BlockVarDecl. They are replaced by ↵Steve Naroff2008-04-151-31/+16
| | | | | | | | VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl(). This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it). llvm-svn: 49748
* Use static_cast<> instead of cast<> in Decl::Destroy(). Suggestion by ArgirisSam Bishop2008-04-131-2/+5
| | | | | | Kirtzidis! llvm-svn: 49603
* Default argument cleanups and minor improvements, patch byChris Lattner2008-04-121-1/+1
| | | | | | Doug Gregor! llvm-svn: 49598
* Invoke destructors in Decl::Destroy().Sam Bishop2008-04-111-0/+33
| | | | llvm-svn: 49547
* Stub out and start using a Decl::Destroy() method.Sam Bishop2008-04-111-0/+4
| | | | llvm-svn: 49532
* Several improvements from Doug Gregor related to defaultChris Lattner2008-04-101-0/+13
| | | | | | argument handling. I'll fix up the c89 (void) thing next. llvm-svn: 49459
* Changed the Decl::Kind enum of the ObjCPropertyDecl class, so that it followsSam Bishop2008-04-081-1/+1
| | | | | | the pattern of the other Decl classes. llvm-svn: 49399
* Add support for C++ default arguments, and rework Parse-Sema Chris Lattner2008-04-081-2/+2
| | | | | | | | interaction for function parameters, fixing PR2046. Patch by Doug Gregor! llvm-svn: 49369
* remove a use of getCanonicalType.Chris Lattner2008-04-061-2/+3
| | | | llvm-svn: 49294
* This patch contains these changes:Chris Lattner2008-04-061-15/+15
| | | | | | | | | | -Renamed ContextDecl -> DeclContext -Removed DeclContext pointer from FieldDecl -EnumDecl inherits from DeclContext, instead of TagDecl Patch by Argiris Kirtzidis! llvm-svn: 49261
OpenPOWER on IntegriCloud