summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
Commit message (Collapse)AuthorAgeFilesLines
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-1/+1
| | | | llvm-svn: 148577
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-171-1/+0
| | | | | | This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-141-2/+2
| | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. llvm-svn: 148187
* Implement redeclaration merging for namespaces defined in distinctDouglas Gregor2012-01-091-5/+8
| | | | | | | | | modules. Teach name lookup into namespaces to search in each of the merged DeclContexts as well as the (now-primary) DeclContext. This supports the common case where two different modules put something into the same namespace. llvm-svn: 147778
* Switch NamespaceDecl from its own hand-rolled redeclaration chain overDouglas Gregor2012-01-071-12/+20
| | | | | | | | | | | | to Redeclarable<NamespaceDecl>, so that we benefit from the improveed redeclaration deserialization and merging logic provided by Redeclarable<T>. Otherwise, no functionality change. As a drive-by fix, collapse the "inline" bit into the low bit of the original namespace/anonymous namespace, saving 8 bytes per NamespaceDecl on x86_64. llvm-svn: 147729
* Stash Decl's TopLevelDeclInObjCContainer and ModulePrivate bitsDouglas Gregor2012-01-061-10/+10
| | | | | | | | into the two unused lower bits of the NextDeclInContext link, dropping the number of bits in Decl down to 32, and saving 8 bytes per declaration on x86-64. llvm-svn: 147660
* Always allocate an extra 8 bytes for a deserialized declaration, sinceDouglas Gregor2012-01-051-8/+5
| | | | | | some code in Clang expects 8-byte alignment of declarations. llvm-svn: 147626
* When we deserialize a declaration from a module file, allocate extraDouglas Gregor2012-01-051-1/+14
| | | | | | | | | | | | | | | storage for the global declaration ID. Declarations that are parsed (rather than deserialized) are unaffected, so the number of declarations that pay this cost tends to be relatively small (since relatively few declarations are ever deserialized). This replaces a largish DenseMap within the AST reader. It's not strictly a win in terms of memory use---not every declaration was added to that DenseMap in the first place---but it's cleaner to have this information available for every deserialized declaration, so that future clients can rely on it. llvm-svn: 147617
* When creating declarations that are deserialized from an module file,Douglas Gregor2012-01-051-0/+6
| | | | | | | go through a central allocation routine Decl::AllocateDeserializedDecl(). No actual functionality change (yet). llvm-svn: 147614
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-1/+0
| | | | | | ObjCProtocolDecl modules forward declarations properly. llvm-svn: 147415
* Introduce the core infrastructure needed to model redeclaration chainsDouglas Gregor2012-01-011-2/+4
| | | | | | | | | | | | | | | for Objective-C protocols, including: - Using the first declaration as the canonical declaration - Using the definition as the primary DeclContext - Making sure that all declarations have a pointer to the definition data, and that we know which declaration is the definition - Serialization support for redeclaration chains and for adding definitions to already-serialized declarations. However, note that we're not taking advantage of much of this code yet, because we're still re-using ObjCProtocolDecls. llvm-svn: 147410
* Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDeclDouglas Gregor2011-12-271-6/+0
| | | | | | | covers both declarations (@class) and definitions (@interface) of an Objective-C class. llvm-svn: 147299
* Introduce the core infrastructure needed to model a completeDouglas Gregor2011-12-151-1/+8
| | | | | | | | | | | | | | | redeclaration chain for Objective-C classes, including: - Using the first declaration as the canonical declaration. - Using the definition as the primary DeclContext - Making sure that all declarations have a pointer to the definition data, and the definition knows that it is the definition. - Serialization support for when a definition gets added to a declaration that comes from an AST file. However, note that we're not taking advantage of much of this code yet, because we're still re-using ObjCInterfaceDecls. llvm-svn: 146667
* Add ability to supply additional message to availability macros,Fariborz Jahanian2011-12-101-5/+12
| | | | | | // rdar://10095131 llvm-svn: 146304
* Keep track of all of the import declarations that are parsed orDouglas Gregor2011-12-031-0/+7
| | | | | | | implicitly generated in a translation unit. Modules will need this information to identify the actual imports that occurred. llvm-svn: 145734
* Introduce a module import declaration, so that we properly represent, e.g.,Douglas Gregor2011-12-021-0/+1
| | | | | | | | __import_module__ std.vector; in the AST. llvm-svn: 145725
* From Vassil Vassilev: add checks for removing Decls for more use cases.Axel Naumann2011-11-081-1/+2
| | | | llvm-svn: 144094
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | property references to use a new PseudoObjectExpr expression which pairs a syntactic form of the expression with a set of semantic expressions implementing it. This should significantly reduce the complexity required elsewhere in the compiler to deal with these kinds of expressions (e.g. IR generation's special l-value kind, the static analyzer's Message abstraction), at the lower cost of specifically dealing with the odd AST structure of these expressions. It should also greatly simplify efforts to implement similar language features in the future, most notably Managed C++'s properties and indexed properties. Most of the effort here is in dealing with the various clients of the AST. I've gone ahead and simplified the ObjC rewriter's use of properties; other clients, like IR-gen and the static analyzer, have all the old complexity *and* all the new complexity, at least temporarily. Many thanks to Ted for writing and advising on the necessary changes to the static analyzer. I've xfailed a small diagnostics regression in the static analyzer at Ted's request. llvm-svn: 143867
* I added a new function to DeclContext calledSean Callanan2011-10-211-11/+29
| | | | | | | | | | | | | | | | | | | addDeclInternal(). This function suppresses any calls to FindExternalVisibleDeclsByName() while a Decl is added to a DeclContext. This behavior is required for the ASTImporter, because in the case of the LLDB client the ASTImporter would be called recursively to import the visible decls, which leads to assertions because the recursive call is seeing partially-formed types. I also modified the ASTImporter to use addDeclInternal() in all places where it would otherwise use addDecl(). This fix should not affect the rest of Clang, passes Clang's testsuite, and fixes several serious LLDB bugs. llvm-svn: 142634
* Teach the ASTImporter to perform DeclContext lookups in a way thatDouglas Gregor2011-10-151-0/+32
| | | | | | | | | | avoids loading data from an external source, since those lookups were causing some "interesting" recursion in LLDB. This code is not efficient. I plan to remedy this inefficiency in a follow-up commit. llvm-svn: 142023
* In DeclContext::LoadLexicalDeclsFromExternalStorage don't clear outArgyrios Kyrtzidis2011-10-071-18/+13
| | | | | | | | | | | | | | | | the fields if they are already loaded, just ignore them when we are building the chain in BuildDeclChain. This fixes an lldb issue where fields were removed and not getting re-added because lldb is based on ASTImporter adding decls to DeclContext and fields were already added before by the ASTImporter. We should really simplify the interaction between DeclContext <-> lldb going forward.. rdar://10246067 llvm-svn: 141418
* Introduce Decl::getParentFunctionOrMethod which if the decl is defined insideArgyrios Kyrtzidis2011-09-281-5/+5
| | | | | | a function/method/block it returns the corresponding DeclContext, otherwise it returns null. llvm-svn: 140672
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-2/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-5/+5
| | | | llvm-svn: 140367
* Use ArrayRef in ExternalASTSource::SetExternalVisibleDeclsForName.Argyrios Kyrtzidis2011-09-091-4/+5
| | | | llvm-svn: 139357
* Thread safety: added support for function scopes in attribute arguments.Caitlin Sadowski2011-09-081-0/+4
| | | | | | This patch was written by DeLesley Hutchins. llvm-svn: 139302
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-2/+2
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* objective-c: Treat top-level objective-c declarationsFariborz Jahanian2011-08-271-4/+2
| | | | | | | | | | , such as list of forward @class decls, in a DeclGroup node. Deal with its consequence throught clang. This is in preparation for more Sema work ahead. // rdar://8843851. Feel free to reverse if it breaks something important and I am unavailable. llvm-svn: 138709
* When we're deserializing declarations lexically stored in a RecordDeclDouglas Gregor2011-08-261-8/+16
| | | | | | | | | | | after having already deserialized the fields, clear out the fields first. This makes sure that we keep all of the declarations in the lexical context (including those implicitly added by later type-checking) within the same list. A test case for this behavior is coming as part of another commit; testing for this problem in isolation is a nightmare. llvm-svn: 138661
* From Vassil Vassilev: unnamed decls cannot be removed from the lookup map.Axel Naumann2011-08-261-0/+3
| | | | llvm-svn: 138631
* Remove long-dead FIXMEDouglas Gregor2011-08-241-2/+0
| | | | llvm-svn: 138498
* Don't force the complete deserialization of the visible-declarationsDouglas Gregor2011-08-241-28/+0
| | | | | | | | | | table when serializing an AST file. This was a holdover from the days before chained PCH, and is a complete waste of time and storage now. It's a good thing it's useless, because I have no idea how I would have implemented MaterializeVisibleDecls efficiently in the presence of modules. llvm-svn: 138496
* Add serialization support for ClassScopeFunctionSpecializationDecl.Francois Pichet2011-08-171-1/+2
| | | | llvm-svn: 137799
* Implement function template specialization at class scope extension in ↵Francois Pichet2011-08-141-0/+1
| | | | | | | | | | | | | | | | | Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization. Example: template <class T> class A { public: template <class U> void f(U p) { } template <> void f(int p) { } // <== class scope specialization }; This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code. BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error. llvm-svn: 137573
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-7/+7
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Augment the interface of ExternalASTSource::FindExternalLexicalDecls()Douglas Gregor2011-07-151-4/+9
| | | | | | | | | | | to allow clients to specify that they've already (correctly) loaded declarations, and that no further action is needed. Also, make sure that we clear the "has external lexical declarations" bit before calling FindExternalLexicalDecls(), to avoid infinite recursion. llvm-svn: 135306
* Switch the Decl and Stmt stats printing to use llvm::errs() instead ofChandler Carruth2011-07-041-7/+7
| | | | | | | fprintf, and to be more consistent in formatting with the other stats printing routines. llvm-svn: 134374
* Apparently at some point in the past I forgot how 'continue'John McCall2011-06-231-6/+2
| | | | | | | | works in a 'while(false)' loop. Simplify this code; it was complicated only in anticipation of C++0x lambdas, and it can become complicated again when those happen. :) llvm-svn: 133761
* Move definition of template <typename T> void Decl::dropAttrFariborz Jahanian2011-06-231-18/+0
| | | | | | to its header to avoid an explicit instantiation. llvm-svn: 133753
* Minor tweak to my last patch per Doug's comment.Fariborz Jahanian2011-06-231-2/+4
| | | | llvm-svn: 133731
* Remove multiple use of weak_import attribute onFariborz Jahanian2011-06-231-14/+16
| | | | | | same declaration. Templatize dropAttr for general use. llvm-svn: 133724
* Remove weak_import attribute on new declaration.Fariborz Jahanian2011-06-231-0/+14
| | | | | | // rdar://9538608 llvm-svn: 133721
* Implement a minor optimization by not introducing declarations intoDouglas Gregor2011-05-061-4/+4
| | | | | | DeclContext's lookup table when they aren't in any identifier namespace. llvm-svn: 131037
* Implement support for C++0x alias templates.Richard Smith2011-05-051-0/+1
| | | | llvm-svn: 130953
* Remove unused STL header includes.Jay Foad2011-04-231-1/+0
| | | | llvm-svn: 130068
* We regard a function as 'unused' from the codegen perspective, so our ↵Argyrios Kyrtzidis2011-04-191-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | warnings diverge from gcc's unused warnings which don't get emitted if the function is referenced even in an unevaluated context (e.g. in templates, sizeof, etc.). Also, saying that a function is 'unused' because it won't get codegen'ed is somewhat misleading. - Don't emit 'unused' warnings for functions that are referenced in any part of the user's code. - A warning that an internal function/variable won't get emitted is useful though, so introduce -Wunneeded-internal-declaration which will warn if a function/variable with internal linkage is not "needed" ('used' from the codegen perspective), e.g: static void foo() { } template <int> void bar() { foo(); } test.cpp:1:13: warning: function 'foo' is not needed and will not be emitted static void foo() { } ^ Addresses rdar://8733476. llvm-svn: 129794
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-151-0/+1
| | | | llvm-svn: 129567
* Extend the new 'availability' attribute with support for anDouglas Gregor2011-03-261-0/+11
| | | | | | | 'unavailable' argument, which specifies that the declaration to which the attribute appertains is unavailable on that platform. llvm-svn: 128329
* remove a dead variable.Chris Lattner2011-03-231-1/+0
| | | | llvm-svn: 128141
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-0/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
OpenPOWER on IntegriCloud