summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Cleanup and test C++ default arguments. Improvements include:Douglas Gregor2009-09-111-6/+16
| | | | | | | | | | | - Diagnose attempts to add default arguments to templates (or member functions of templates) after the initial declaration (DR217). - Improve diagnostics when a default argument is redefined. Now, the note will always point at the place where the default argument was previously defined, rather than pointing to the most recent declaration of the function. llvm-svn: 81548
* When stringizing a NamedDecl for a diagnostic, treat the templateJohn McCall2009-09-111-0/+12
| | | | | | specialization types differently. llvm-svn: 81512
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-46/+46
| | | | llvm-svn: 81346
* Vastly improve PredefinedExpr output, both in Sema and CodeGen. Patch by Sam ↵Anders Carlsson2009-09-081-3/+5
| | | | | | Weinig! llvm-svn: 81237
* Improve the AST representation and semantic analysis for externDouglas Gregor2009-09-041-12/+23
| | | | | | | | | | | templates. We now distinguish between an explicit instantiation declaration and an explicit instantiation definition, and know not to instantiate explicit instantiation declarations. Unfortunately, there is some remaining confusion w.r.t. instantiation of out-of-line member function definitions that causes trouble here. llvm-svn: 81053
* Correctly handle elaborated template ids. Still not handled properly for ↵John McCall2009-09-041-0/+12
| | | | | | friends. llvm-svn: 80977
* Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use ↵Argyrios Kyrtzidis2009-08-211-9/+16
| | | | | | DeclaratorInfo to get this information. llvm-svn: 79584
* Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema ↵Argyrios Kyrtzidis2009-08-191-13/+15
| | | | | | | | | | | | interfaces. DeclaratorDecl contains a DeclaratorInfo* to keep type source info. Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl. EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo. Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet. llvm-svn: 79392
* Introduce DeclaratorInfo and TypeLoc, intended to be used for storing and ↵Argyrios Kyrtzidis2009-08-191-0/+5
| | | | | | | | | | | reading source information for types. DeclaratorInfo will contain a flat memory block for source information about a type that came out of a declarator. TypeLoc and its subclasses will be used by clients as wrappers to "traverse" the memory block and read the information. Both DeclaratorInfo and TypeLoc are not utilized in this commit. llvm-svn: 79391
* Disable all recognition of main() in -ffreestanding. Addresses bug #4720.John McCall2009-08-151-2/+3
| | | | llvm-svn: 79070
* There's no point in going through the getAs<TagType> stuff to find the ↵Douglas Gregor2009-07-291-3/+0
| | | | | | definition of a tag, since tags rarely have more than one or two declarations llvm-svn: 77546
* Make tag declarations redeclarable. This change has three purposes:Douglas Gregor2009-07-291-21/+27
| | | | | | | | | | | | | | | | 1) Allow the Index library (and any other interested client) to walk the set of declarations for a given tag (enum, union, class, whatever). At the moment, this information is not readily available. 2) Reduce our dependence on TagDecl::TypeForDecl being mapped down to a TagType (for which getDecl() will return the tag definition, if one exists). This property won't exist for class template partial specializations. 3) Make the canonical declaration of a TagDecl actually canonical, e.g., so that it does not change when the tag is defined. llvm-svn: 77523
* Change uses of:Ted Kremenek2009-07-291-6/+6
| | | | | | | | | | | | | | | | | | | | Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsRecordType() -> Type::getAs<RecordType>() Type::getAsPointerType() -> Type::getAs<PointerType>() Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>() Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>() Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>() Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>() Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsTagType() -> Type::getAs<TagType>() And remove Type::getAsReferenceType(), etc. This change is similar to one I made a couple weeks ago, but that was partly reverted pending some additional design discussion. With Doug's pending smart pointer changes for Types, it seemed natural to take this approach. llvm-svn: 77510
* Template instantiation for static data members that are defined out-of-line.Douglas Gregor2009-07-241-0/+4
| | | | | | | | Note that this also fixes a bug that affects non-template code, where we were not treating out-of-line static data members are "file-scope" variables, and therefore not checking their initializers. llvm-svn: 77002
* Add the location of the tag keyword into TagDecl. From EneaDouglas Gregor2009-07-211-7/+7
| | | | | | Zaffanella, with tweaks from Abramo Bagnara. llvm-svn: 76576
* Introduce a redecl_iterator in Decl class, so that we can do a "iterate over ↵Argyrios Kyrtzidis2009-07-181-1/+1
| | | | | | all declarations of the same decl" without knowing the exact type. llvm-svn: 76298
* Introduce the Redeclarable template class, which serves as a base type ↵Argyrios Kyrtzidis2009-07-181-42/+4
| | | | | | | | defining the common interface for Decls that can be redeclared. Make FunctionDecl and VarDecl use it. llvm-svn: 76297
* Remove getFirstDeclaration/getLatestDeclaration from FunctionDecl and VarDecl.Argyrios Kyrtzidis2009-07-181-18/+4
| | | | | | Their usefulness is questionable since redecl_iterator was introduced. llvm-svn: 76275
* Move the functionality of ASTContext::getCanonicalDecl(), into a virtual ↵Argyrios Kyrtzidis2009-07-181-4/+18
| | | | | | method Decl::getCanonicalDecl(). llvm-svn: 76273
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-6/+6
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
* Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), ↵Ted Kremenek2009-07-171-6/+6
| | | | | | Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents. llvm-svn: 76139
* Add a "TypeSpecStartLoc" to FieldDecl. Patch contributed by Enea Zaffanella.Steve Naroff2009-07-141-2/+2
| | | | | Note: One day, it might be useful to consider adding this info to DeclGroup (as the comments in FunctionDecl/VarDecl suggest). For now, I think this works fine. I considered moving this to ValueDecl (a common ancestor of FunctionDecl/VarDecl/FieldDecl), however this would add overhead to EnumConstantDecl (which would burn memory and isn't necessary). llvm-svn: 75635
* Introduce redecl_iterator, used for iterating over the redeclarations of a ↵Argyrios Kyrtzidis2009-07-141-19/+19
| | | | | | | | | | | | | | | | | | | | | FunctionDecl or VarDecl. It iterates over all the redeclarations, regardless of the starting point. For example: 1) int f(); 2) int f(); 3) int f(); if you have the (2) FunctionDecl and call redecls_begin/redecls_end to iterate, you'll get this sequence: (2) (1) (3) The motivation to introduce this was that, previously, if (3) was a function definition, and you called getBody() at (2), it would not return it, since getBody() iterated over the previous declarations only, so it would only check (2) and (1). llvm-svn: 75604
* Introduce FunctionDecl::getLatestDeclaration() and ↵Argyrios Kyrtzidis2009-07-141-7/+39
| | | | | | | | | | VarDecl::getLatestDeclaration(). For multiple redeclarations they return the last one. Also, add some non const versions of methods. llvm-svn: 75603
* Introduce FunctionDecl::getFirstDeclaration() and ↵Argyrios Kyrtzidis2009-07-141-10/+18
| | | | | | | | VarDecl::getFirstDeclaration(). For multiple redeclarations they return the first one. llvm-svn: 75602
* Add the SourceLocation for the right brace in TagDecl.Argyrios Kyrtzidis2009-07-141-0/+5
| | | | llvm-svn: 75590
* Implemented memmove_collectable API for Next runtimeFariborz Jahanian2009-07-081-0/+1
| | | | | | | when struct variables with GC'able members are copied into. Will provide a test case later. llvm-svn: 74984
* Introduce the virtual method Decl::getPrimaryDecl().Argyrios Kyrtzidis2009-07-051-0/+16
| | | | | | | When a Decl subclass can have multiple re-declarations in the same declaration context (like FunctionDecl), getPrimaryDecl() will return a particular Decl that all of them will point to as the "primary" declaration. llvm-svn: 74800
* Remove the ASTContext parameter from the getBody() methods of Decl and ↵Argyrios Kyrtzidis2009-06-301-3/+2
| | | | | | | | subclasses. Timings showed no significant difference before and after the commit. llvm-svn: 74504
* Remove the ASTContext parameter from the attribute-related methods of Decl.Argyrios Kyrtzidis2009-06-301-6/+6
| | | | | | | | | The implementations of these methods can Use Decl::getASTContext() to get the ASTContext. This commit touches a lot of files since call sites for these methods are everywhere. I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it. llvm-svn: 74501
* Key decisions about 'bool' vs '_Bool' to be based on a new flag in langoptions.Chris Lattner2009-06-301-2/+1
| | | | | | | | | | | | This is simple enough, but then I thought it would be nice to make PrintingPolicy get a LangOptions so that various things can key off "bool" and "C++" independently. This spiraled out of control. There are many fixme's, but I think things are slightly better than they were before. One thing that can be improved: CFG should probably have an ASTContext pointer in it, which would simplify its clients. llvm-svn: 74493
* Improve code generation for function template specializations:Douglas Gregor2009-06-291-2/+23
| | | | | | | | | | | | | | | | - Track implicit instantiations vs. the not-yet-supported explicit specializations - Give implicit instantiations of function templates (and member functions of class templates) linkonce_odr linkage. - Improve name mangling for function template specializations, including the template arguments of the instantiation and the return type of the function. Note that our name-mangling is improved, but not correct: we still don't mangle substitutions, although the manglings we produce can be demangled. llvm-svn: 74466
* Keep track of function template specializations, to eliminateDouglas Gregor2009-06-291-6/+19
| | | | | | | redundant, implicit instantiations of function templates and provide a place where we can hang function template specializations. llvm-svn: 74454
* -Keep a reference to the ASTContext inside the TranslationUnitDecl.Argyrios Kyrtzidis2009-06-291-1/+1
| | | | | | | | -Introduce Decl::getASTContext() which returns the reference from the TranslationUnitDecl that it is contained in. The general idea is that Decls can point to their own ASTContext so that it is no longer required to "manually" keep track and make sure that you pass the correct ASTContext to Decls' methods, e.g. methods like Decl::getAttrs should eventually not require a ASTContext parameter. llvm-svn: 74434
* Move FunctionDecl::TemplateSpecializationInfo out into its own class,Douglas Gregor2009-06-291-5/+25
| | | | | | FunctionTemplateSpecializationInfo, in DeclTemplate.h. No functionality change. llvm-svn: 74431
* Add NamedDecl::getUnderlyingDecl that can see through UsingDecl and ↵Anders Carlsson2009-06-261-0/+13
| | | | | | ObjCCompatibleAliasDecl. llvm-svn: 74279
* Implicit instantiation for function template specializations.Douglas Gregor2009-06-261-0/+18
| | | | | | | | | For a FunctionDecl that has been instantiated due to template argument deduction, we now store the primary template from which it was instantiated and the deduced template arguments. From this information, we can instantiate the body of the function template. llvm-svn: 74232
* Improved semantic analysis and AST respresentation for functionDouglas Gregor2009-06-251-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | templates. For example, this now type-checks (but does not instantiate the body of deref<int>): template<typename T> T& deref(T* t) { return *t; } void test(int *ip) { int &ir = deref(ip); } Specific changes/additions: * Template argument deduction from a call to a function template. * Instantiation of a function template specializations (just the declarations) from the template arguments deduced from a call. * FunctionTemplateDecls are stored directly in declaration contexts and found via name lookup (all forms), rather than finding the FunctionDecl and then realizing it is a template. This is responsible for most of the churn, since some of the core declaration matching and lookup code assumes that all functions are FunctionDecls. llvm-svn: 74213
* Don't use operator overload '<' for SourceLocation, it has not semantic meaning.Argyrios Kyrtzidis2009-06-231-1/+1
| | | | llvm-svn: 73932
* Add a comment.Argyrios Kyrtzidis2009-06-231-1/+2
| | | | llvm-svn: 73930
* Addressing Doug's suggestions:Argyrios Kyrtzidis2009-06-221-1/+1
| | | | | | | -Added comment for FunctionDecl::EndRangeLoc -Removed a redundant check from FunctionDecl::setBody llvm-svn: 73886
* Introduce Decl::getSourceRange() which, like Stmt::getSourceRange(), ↵Argyrios Kyrtzidis2009-06-201-0/+16
| | | | | | | | | | | represents the range that the declaration covers. Add initial support for NamespaceDecl, VarDecl, and FunctionDecl: -NamespaceDecl range is from name to '}' -VarDecl is from name to possible init expression -FunctionDecl is from name to last parameter name or to end of its function body. llvm-svn: 73821
* Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.Douglas Gregor2009-06-181-9/+10
| | | | llvm-svn: 73702
* Sink the BuiltinInfo object from ASTContext into theChris Lattner2009-06-141-0/+1
| | | | | | | | preprocessor and initialize it early in clang-cc. This ensures that __has_builtin works in all modes, not just when ASTContext is around. llvm-svn: 73319
* Make ParmVarDecl::getDefaultArg() more robust, it now asserts that the ↵Anders Carlsson2009-06-061-1/+1
| | | | | | argument is not unparsed. Add a new hasDefaultArg() and use it in places where getDefaultArg() was called when the argument was unparsed. llvm-svn: 72984
* Create a new PrintingPolicy class, which we pass down through the ASTDouglas Gregor2009-05-291-1/+5
| | | | | | | | | printing logic to help customize the output. For now, we use this rather than a special flag to suppress the "struct" when printing "struct X" and to print the Boolean type as "bool" in C++ but "_Bool" in C. llvm-svn: 72590
* Introduced DeclContext::isDependentContext, which determines whether aDouglas Gregor2009-05-281-13/+0
| | | | | | | | | | | | | | | | | | | given DeclContext is dependent on type parameters. Use this to properly determine whether a TagDecl is dependent; previously, we were missing the case where the TagDecl is a local class of a member function of a class template (phew!). Also, make sure that, when we instantiate declarations within a member function of a class template (or a function template, eventually), that we add those declarations to the "instantiated locals" map so that they can be found when instantiating declaration references. Unfortunately, I was not able to write a useful test for this change, although the assert() that fires when uncommenting the FIXME'd line in test/SemaTemplate/instantiate-declref.cpp tells the "experienced user" that we're now doing the right thing. llvm-svn: 72526
* When evaluating a VarDecl as a constant or determining whether it isDouglas Gregor2009-05-261-1/+15
| | | | | | | | an integral constant expression, maintain a cache of the value and the is-an-ICE flag within the VarDecl itself. This eliminates exponential-time behavior of the Fibonacci template metaprogram. llvm-svn: 72428
* When instantiating the definition of a member function of a classDouglas Gregor2009-05-181-1/+9
| | | | | | | | | | | | | | template, introduce that member function into the template instantiation stack. Also, add diagnostics showing the member function within the instantiation stack and clean up the qualified-name printing so that we get something like: note: in instantiation of member function 'Switch1<int, 2, 2>::f' requested here in the template instantiation backtrace. llvm-svn: 72015
* Improvements to the FunctionDecl getters/setters.Anders Carlsson2009-05-141-2/+2
| | | | llvm-svn: 71800
OpenPOWER on IntegriCloud