summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* When we're deserializing a template parameter declaration, temporarilyDouglas Gregor2011-03-051-3/+0
| | | | | | | | | | use the translation unit as its declaration context, then deserialize the actual lexical and semantic DeclContexts after the template parameter is complete. This avoids problems when the DeclContext itself (e.g., a class template) is dependent on the template parameter (e.g., for the injected-class-name). llvm-svn: 127056
* Make sure to put template parameters into their owning template'sDouglas Gregor2011-03-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DeclContext once we've created it. This mirrors what we do for function parameters, where the parameters start out with translation-unit context and then are adopted by the appropriate DeclContext when it is created. Also give template parameters public access and make sure that they don't show up for the purposes of name lookup. Fixes PR9400, a regression introduced by r126920, which implemented substitution of default template arguments provided in template template parameters (C++ core issue 150). How on earth could the DeclContext of a template parameter affect the handling of default template arguments? I'm so glad you asked! The link is Sema::getTemplateInstantiationArgs(), which determines the outer template argument lists that correspond to a given declaration. When we're instantiating a default template argument for a template template parameter within the body of a template definition (not it's instantiation, per core issue 150), we weren't getting any outer template arguments because the context of the template template parameter was the translation unit. Now that the context of the template template parameter is its owning template, we get the template arguments from the injected-class-name of the owning template, so substitution works as it should. llvm-svn: 127004
* Provide a Decl::getNonClosureContext to look through any "closure" (i.e.John McCall2011-02-221-0/+16
| | | | | | block and, eventually, C++ lambda) contexts. llvm-svn: 126252
* Revert all of my commits that devirtualized the Decl hierarchy, whichDouglas Gregor2011-02-191-145/+2
| | | | | | | | lead to a serious slowdown (4%) on parsing of Cocoa.h. This memory optimization should be revisited later, when we have time to look at the generated code. llvm-svn: 126033
* Remove the last virtual member function from the Decl hierarchy,Douglas Gregor2011-02-171-3/+0
| | | | | | | | reducing the size of all declarations by one pointer. For a 64-bit Clang parsing Cocoa.h, this saves ~630k of memory (about 3.5% of ASTContext's memory usage for this header). llvm-svn: 125756
* Devirtualize Decl::getNextRedeclaration().Douglas Gregor2011-02-171-0/+72
| | | | llvm-svn: 125740
* Simple little optimization to Decl::getCanonicalDecl(), eliminating some ↵Douglas Gregor2011-02-171-4/+4
| | | | | | heavyweight machinery and indirection that we don't need llvm-svn: 125737
* Devirtualize Decl::getSourceRange()Douglas Gregor2011-02-171-1/+25
| | | | llvm-svn: 125736
* Devirtualize Decl::getCanonicalDecl().Douglas Gregor2011-02-171-0/+23
| | | | llvm-svn: 125735
* Step #1/N of implementing support for __label__: split labels intoChris Lattner2011-02-171-1/+2
| | | | | | | | | | | | | | | | | | | LabelDecl and LabelStmt. There is a 1-1 correspondence between the two, but this simplifies a bunch of code by itself. This is because labels are the only place where we previously had references to random other statements, causing grief for AST serialization and other stuff. This does cause one regression (attr(unused) doesn't silence unused label warnings) which I'll address next. This does fix some minor bugs: 1. "The only valid attribute " diagnostic was capitalized. 2. Various diagnostics printed as ''labelname'' instead of 'labelname' 3. This reduces duplication of label checking between functions and blocks. Review appreciated, particularly for the cindex and template bits. llvm-svn: 125733
* Devirtualize Decl::getBody() and Decl::hasBody().Douglas Gregor2011-02-171-0/+18
| | | | llvm-svn: 125731
* De-virtualize Decl::isOutOfLine().Douglas Gregor2011-02-171-0/+9
| | | | llvm-svn: 125730
* Add Decl::isParameterPack(), which covers both function and templateDouglas Gregor2011-01-051-0/+7
| | | | | | | | parameter packs, along with ParmVarDecl::isParameterPack(), which looks for function parameter packs. Use these routines to fix some obvious FIXMEs. llvm-svn: 122904
* Implement support for template template parameter packs, e.g.,Douglas Gregor2011-01-051-1/+4
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* Add an AST representation for non-type template parameterDouglas Gregor2010-12-231-1/+3
| | | | | | | | | | | | | | packs, e.g., template<typename T, unsigned ...Dims> struct multi_array; along with semantic analysis support for finding unexpanded non-type template parameter packs in types, expressions, and so on. Template instantiation involving non-type template parameter packs probably doesn't work yet. That'll come soon. llvm-svn: 122527
* Revert r120808, my previous implementation of caching for the linkageDouglas Gregor2010-12-061-32/+0
| | | | | | | | | and visibility of declarations, because it was extremely messy and it increased the size of NamedDecl. An improved implementation is forthcoming. llvm-svn: 121012
* Implement caching for the linkage and visibility calculations ofDouglas Gregor2010-12-031-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | declarations. The motivation for this patch is that linkage/visibility computations are linear in the number of redeclarations of an entity, and we've run into a case where a single translation unit has > 6500 redeclarations of the same (unused!) external variable. Since each redeclaration involves a linkage check, the resulting quadratic behavior makes Clang slow to a crawl. With this change, a simple test with 512 redeclarations of a variable syntax-checks ~20x faster than before. That said, I hate this change, and will probably end up reverting it in a few hours. Reasons to hate it: - It makes NamedDecl larger, since we don't have enough free bits in Decl to squeeze in the extra information about caching. - There are way too many places where we need to invalidate this cache, because the visibility of a declaration can change due to redeclarations (!). Despite self-hosting and passing the testsuite, I have no confidence that I've found all of places where this cache needs to be invalidated. llvm-svn: 120808
* Eliminate two uses of NDEBUG in headers that cause different symbolsDouglas Gregor2010-12-021-2/+2
| | | | | | to be available in debug vs. release builds. llvm-svn: 120629
* Major anonymous union/struct redesign.Francois Pichet2010-11-211-2/+3
| | | | | | | | | | | A new AST node is introduced: def IndirectField : DDecl<Value>; IndirectFields are injected into the anonymous's parent scope and chain back to the original field. Name lookup for anonymous entities now result in an IndirectFieldDecl instead of a FieldDecl. There is no functionality change, the code generated should be the same. llvm-svn: 119919
* Use the ASTMutationListener to track when a named decl gets added to a ↵Argyrios Kyrtzidis2010-10-281-0/+7
| | | | | | | | DeclContext, meaning we need to rewrite its name lookup table in a chained PCH. llvm-svn: 117536
* A couple of tweaks to the visibility rules: John McCall2010-10-261-0/+11
| | | | | | | | | | | - tags with C linkage should ignore visibility=hidden - functions and variables with explicit visibility attributes should ignore the linkage of their types Either of these should be sufficient to fix PR8457. Also, FileCheck-ize a test case. llvm-svn: 117351
* Put the mechanism in place to track modifications in an AST entity that were ↵Argyrios Kyrtzidis2010-10-241-0/+4
| | | | | | | | | | | | committed after its initial creation/deserialization and store the changes in a chained PCH. The idea is that the AST entities call methods on the ASTMutationListener to give notifications of changes; the PCHWriter implements the ASTMutationListener interface and stores the incremental changes of the updated entity. WIP llvm-svn: 117235
* Allow deserialization of just the fields of a record, when we want to ↵Argyrios Kyrtzidis2010-10-141-16/+30
| | | | | | | | | | | | | iterate over them, instead of deserializing the complete declaration context of the record. Iterating over the fields of a record is very common (e.g to determine the layout), unfortunately we needlessly deserialize every declaration that the declaration context of the record contains; this can be bad for large C++ classes that contain a lot of methods. Fix this by allow deserialization of just the fields when we want to iterate over them. Progress for rdar://7260160. llvm-svn: 116507
* Implement C++0x scoped enumerations, from Daniel Wallin! (and tweaked aDouglas Gregor2010-10-081-1/+1
| | | | | | bit by me). llvm-svn: 116122
* Centralize the handling ofDouglas Gregor2010-09-271-8/+5
| | | | | | | CXXRecordDecl::DefinitionData::DeclaredCopyAssignment, for copy-assignment operators. Another step toward <rdar://problem/8459981>. llvm-svn: 114899
* Clean up the handling of the DeclaredDefaultConstructor andDouglas Gregor2010-09-271-0/+8
| | | | | | | | | | | | | DeclaredCopyConstructor bits in CXXRecordDecl's DefinitionData structure. Rather than having Sema call addedConstructor or set the bits directly at semi-random places, move all of the logic for managing these bits into CXXRecordDecl itself and tie the addedConstructor call into DeclContext::addDecl(). This makes it easier for AST-building clients to get the right bits set in DefinitionData, and is one small part of <rdar://problem/8459981>. llvm-svn: 114889
* Decl::CheckAccessDeclContext() keeps asserting. Access is not set in some cases.Argyrios Kyrtzidis2010-09-081-4/+9
| | | | llvm-svn: 113419
* Re-enable CheckAccessDeclContext and make sure it doesn't trigger assertions.Argyrios Kyrtzidis2010-09-081-4/+6
| | | | llvm-svn: 113413
* Make inline namespace not be transparent after all. The concept simply ↵Sebastian Redl2010-08-311-10/+13
| | | | | | doesn't fit. Instead, special-case the few places where transparent contexts have the desired behavior for inline namespaces. Fixes a redeclaration issue in inline namespaces. llvm-svn: 112637
* Enable inline namespaces in the AST.Sebastian Redl2010-08-311-1/+1
| | | | llvm-svn: 112564
* Rename DeclContext::getLookupContext to getRedeclContext and change its ↵Sebastian Redl2010-08-311-6/+24
| | | | | | semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them. llvm-svn: 112563
* Decl::getEnclosingNamespaceContext has no reason to explicitly skip ↵Sebastian Redl2010-08-311-1/+1
| | | | | | transparent contexts, and would be wrong to do so with inline namespaces. llvm-svn: 112562
OpenPOWER on IntegriCloud