summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add VarDecl::getStorageClassSpecifierString (StorageClass -> const char*).Daniel Dunbar2009-04-141-0/+14
| | | | | | - No functionality change. llvm-svn: 69019
* Implement -Wmissing-prototypes. Fixes PR3911.Douglas Gregor2009-03-311-0/+20
| | | | llvm-svn: 68110
* Predicate to detect when a RecordDecl is really the injected-class-nameDouglas Gregor2009-03-251-0/+5
| | | | llvm-svn: 67687
* Fix <rdar://problem/6704086> by allowing the format string checking in Sema toTed Kremenek2009-03-201-1/+1
| | | | | | | | allow non-literal format strings that are variables that (a) permanently bind to a string constant and (b) whose string constants are resolvable within the same translation unit. llvm-svn: 67404
* BlockDecl::Destroy now deallocates BlockDecl's array of ParmVarDecl*.Ted Kremenek2009-03-131-1/+2
| | | | llvm-svn: 66979
* Fix <rdar://problem/6675489> BlockDecl should not use llvm::smallvector.Steve Naroff2009-03-131-0/+17
| | | | | | Also changed BlockDecl API to be more consistent (wrt FunctionDecl). llvm-svn: 66904
* API fix: All "bodies" for functions, Objective-C methods, blocks, are assumed toTed Kremenek2009-03-121-2/+2
| | | | | | | | be CompoundStmts. I think this is a valid assumption, and felt that the API should reflect it. Others please validate this assumption to make sure I didn't break anything. llvm-svn: 66814
* Add type checking for tentative definitions at the end of theDouglas Gregor2009-03-101-0/+16
| | | | | | | | | translation unit. Thread the various declarations of variables via VarDecl::getPreviousDeclaration. llvm-svn: 66601
* Switch attributes to be allocated from the declcontext bump pointer just likeChris Lattner2009-03-041-0/+11
| | | | | | | decls. This reduces the number of calls to malloc on cocoa.h with pth and -disable-free from 15958 to 12444 times (down ~3500). llvm-svn: 66023
* Rework the way we find locally-scoped external declarations when weDouglas Gregor2009-03-021-0/+41
| | | | | | | | | | | need them to evaluate redeclarations or call a function that hasn't already been declared. We now keep a DenseMap of these locally-scoped declarations so that they are not visible but can be quickly found, e.g., when we're looking for previous declarations or before we go ahead and implicitly declare a function that's being called. Fixes PR3672. llvm-svn: 65792
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make the type associated with a ClassTemplateSpecializationDecl be aDouglas Gregor2009-02-261-6/+8
| | | | | | | | nicely sugared type that shows how the user wrote the actual specialization. This sugared type won't actually show up until we start doing instantiations. llvm-svn: 65577
* C99 DR #316 implies that the function parameter types that are knownDouglas Gregor2009-02-251-2/+6
| | | | | | | | | | only from a function definition (that does not have a prototype) are only used to determine the compatible with other declarations of that same function. In particular, when referencing the function we pretend as if it does not have a prototype. Implement this behavior, which fixes PR3626. llvm-svn: 65460
* When we're declaring an object or function with linkage, teach nameDouglas Gregor2009-02-241-0/+9
| | | | | | | lookup to skip over names without linkage. This finishes <rdar://problem/6127293>. llvm-svn: 65386
* Improve merging of function declarations. Specifically:Douglas Gregor2009-02-241-0/+5
| | | | | | | | | | | | | | | | - When we are declaring a function in local scope, we can merge with a visible declaration from an outer scope if that declaration refers to an entity with linkage. This behavior now works in C++ and properly ignores entities without linkage. - Diagnose the use of "static" on a function declaration in local scope. - Diagnose the declaration of a static function after a non-static declaration of the same function. - Propagate the storage specifier to a function declaration from a prior declaration (PR3425) - Don't name-mangle "main" llvm-svn: 65360
* Contains the following (related to problems found while investigting ↵Steve Naroff2009-02-221-0/+5
| | | | | | | | | | <rdar://problem/6497631> Message lookup is sometimes different than gcc's). - Implement instance/class overloading in ObjCContainerDecl (removing a FIXME). This involved hacking NamedDecl::declarationReplaces(), which took awhile to figure out (didn't realize replace was the default). - Changed Sema::ActOnInstanceMessage() to remove redundant warnings when dealing with protocols. For now, I've omitted the "protocol" term in the diagnostic. It simplifies the code flow and wan't always 100% accurate (e.g. "Foo<Prot>" looks in the class interface, not just the protocol). - Changed several test cases to jive with the above changes. llvm-svn: 65292
* Static variables and functions won't collide with standard libraryDouglas Gregor2009-02-171-0/+4
| | | | | | | functions, so if we're declaring a static we should implicitly declare a library function by the same name (e.g., malloc, strdup). Fixes PR3592. llvm-svn: 64736
* Add hook to add attributes to function declarations that we knowDouglas Gregor2009-02-141-9/+27
| | | | | | | | | | | | | | | | about, whether they are builtins or not. Use this to add the appropriate "format" attribute to NSLog, NSLogv, asprintf, and vasprintf, and to translate builtin attributes (from Builtins.def) into actual attributes on the function declaration. Use the "printf" format attribute on function declarations to determine whether we should do format string checking, rather than looking at an ad hoc list of builtins and "known" function names. Be a bit more careful about when we consider a function a "builtin" in C++. llvm-svn: 64561
* Implicitly declare certain C library functions (malloc, strcpy, memmove,Douglas Gregor2009-02-131-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | etc.) when we perform name lookup on them. This ensures that we produce the correct signature for these functions, which has two practical impacts: 1) When we're supporting the "implicit function declaration" feature of C99, these functions will be implicitly declared with the right signature rather than as a function returning "int" with no prototype. See PR3541 for the reason why this is important (hint: GCC always predeclares these functions). 2) If users attempt to redeclare one of these library functions with an incompatible signature, we produce a hard error. This patch does a little bit of work to give reasonable error messages. For example, when we hit case #1 we complain that we're implicitly declaring this function with a specific signature, and then we give a note that asks the user to include the appropriate header (e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In case #2, we show the type of the implicit builtin that was incorrectly declared, so the user can see the problem. We could do better here: for example, when displaying this latter error message we say something like: 'strcpy' was implicitly declared here with type 'char *(char *, char const *)' but we should really print out a fake code line showing the declaration, like this: 'strcpy' was implicitly declared here as: char *strcpy(char *, char const *) This would also be good for printing built-in candidates with C++ operator overloading. The set of C library functions supported by this patch includes all functions from the C99 specification's <stdlib.h> and <string.h> that (a) are predefined by GCC and (b) have signatures that could cause codegen issues if they are treated as functions with no prototype returning and int. Future work could extend this set of functions to other C library functions that we know about. llvm-svn: 64504
* Fix the symptom of the regression, by having the CXXConditionDeclExpr not ↵Sebastian Redl2009-02-051-1/+3
| | | | | | | | destroy its Decl. However, the cause still remains: the Decl is linked into the chain of its DeclContext and remains there despite being deleted. llvm-svn: 63868
* Some name-lookup-related fixes, from Piotr Rak!Douglas Gregor2009-02-041-0/+36
| | | | | | | | | | | | | - Changes Lookup*Name functions to return NamedDecls, instead of Decls. Unfortunately my recent statement that it will simplify lot of code, was not quite right, but it simplifies some... - Makes MergeLookupResult SmallPtrSet instead of vector, following Douglas suggestions. - Adds %qN format for printing qualified names to Diagnostic. - Avoids searching for using-directives in Scopes, which are not DeclScope, during unqualified name lookup. llvm-svn: 63739
* Semantic analysis, ASTs, and unqualified name lookup support for C++Douglas Gregor2009-02-031-0/+8
| | | | | | 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-4/+4
| | | | | | | 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
* Finish making AST BumpPtrAllocation runtime configurable (based on ↵Steve Naroff2009-01-271-3/+2
| | | | | | | | | | | -disable-free). snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m 0.179u 0.051s 0:00.23 95.6% 0+0k 0+0io 0pf+0w snaroff% time ../../Release-Asserts/bin/clang INPUTS/Cocoa_h.m -disable-free 0.169u 0.052s 0:00.22 95.4% 0+0k 0+0io 0pf+0w llvm-svn: 63153
* Remove many references to ASTContext::getAllocator(), replacing them with ↵Steve Naroff2009-01-271-29/+16
| | | | | | | | 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
* Remove the TopLevelDecls from TranslationUnit, since all of those decls are ↵Douglas Gregor2009-01-201-1/+0
| | | | | | 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-54/+23
| | | | | | | | | | | | | | | | 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
* fix deallocation of FunctionDecl::ParamInfoNuno Lopes2009-01-181-5/+3
| | | | llvm-svn: 62469
* Teach DeclContext how to find the primary declaration for any TagDeclDouglas Gregor2009-01-171-12/+16
| | | | | | | | | | | | | 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
* FunctionDecl::setParams() now uses the allocator associated with ASTContext ↵Ted Kremenek2009-01-141-2/+4
| | | | | | to allocate the array of ParmVarDecl*'s. llvm-svn: 62203
* Make sure that ScopedDecls passed to DeclContext::addDecl are added into ↵Douglas Gregor2009-01-091-0/+7
| | | | | | their lexical context llvm-svn: 61998
* Unify the code for defining tags in C and C++, so that we alwaysDouglas Gregor2009-01-081-2/+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
* Finished semantic analysis of anonymous unions in C++.Douglas Gregor2009-01-071-0/+9
| | | | | | | | | 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
* Initial implementation of anonymous unions (and, as a GNU extension,Douglas Gregor2009-01-071-1/+2
| | | | | | | | | | | | 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
* Don't push OverloadedFunctionDecls onto the chain of declarationsDouglas Gregor2008-12-231-0/+13
| | | | | | | | 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
* Finish up saving original parameter type andFariborz Jahanian2008-12-201-1/+8
| | | | | | using it in ObjC's method parameter encoding. llvm-svn: 61293
* introducing ParmVarWithOriginalTypeDecl class toFariborz Jahanian2008-12-201-0/+10
| | | | | | | keep track of the original parameter decl. types. This is work in progress. llvm-svn: 61286
* fix leakage of var's initializersNuno Lopes2008-12-171-9/+23
| | | | llvm-svn: 61171
* Make sure that enumerators show up within the enumeration declaration. ↵Douglas Gregor2008-12-171-1/+0
| | | | | | Fixes. PR clang/3220 llvm-svn: 61116
* Create new EnumDecl nodes for redeclarations of enums, linking themDouglas Gregor2008-12-151-2/+4
| | | | | | | | | | together in the same way that we link RecordDecl/CXXRecordDecl nodes. Unify ActOnTag and ActOnTagStruct. Fixes PR clang/2753. llvm-svn: 61034
* 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
OpenPOWER on IntegriCloud