summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Determine when the instantiation of a friend function defined inside aDouglas Gregor2010-05-171-3/+2
| | | | | | | class template conflicts with an existing (non-template) definition. This is another part of PR6952. llvm-svn: 103948
* Merged Elaborated and QualifiedName types.Abramo Bagnara2010-05-111-11/+1
| | | | llvm-svn: 103517
* Push TypeSourceInfo::getTypeLoc() into a header file so that it'sJohn McCall2010-05-061-5/+0
| | | | | | | | inlineable. That header file has to be TypeLoc.h, which means that TypeLoc.h needs to depend on Decl.h because TypeSourceInfo doesn't have its own header. That could be remedied, though. llvm-svn: 103176
* Remember the number of positive and negative bits used by the enumerators ofJohn McCall2010-05-061-1/+5
| | | | | | | an enum in the enum decl itself. Use some spare bits from TagDecl for this purpose. llvm-svn: 103173
* Mark a variable as used in the absence of asserts to silence a GCC warning.Chandler Carruth2010-05-061-0/+1
| | | | llvm-svn: 103165
* When we start the definition of a class template, set theDouglas Gregor2010-04-301-0/+9
| | | | | | | | | InjectedClassNameType's Decl to point at the definition. It's a little messy, but we do the same thing with classes and their record types, since much of Clang expects that the TagDecl* one gets out of a type is the definition. Fixes several Boost.Proto failures. llvm-svn: 102691
* Add FunctionDecl::isVariadic() to match BlockDecl::isVariadic() and ↵Ted Kremenek2010-04-291-0/+6
| | | | | | | | ObjCMethodDecl::isVariadic(). Do some minor refactoring along the way. llvm-svn: 102635
* Reduce string trashing in getQualifiedNameAsString.Benjamin Kramer2010-04-281-48/+38
| | | | llvm-svn: 102498
* Make TemplateDecl and ObjCContainerDecl abstractDouglas Gregor2010-04-221-1/+0
| | | | llvm-svn: 102145
* Specify linkage for Objective-C declarations.Ted Kremenek2010-04-201-0/+23
| | | | llvm-svn: 101953
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-191-8/+10
| | | | | | | | function declaration, since it may end up being changed (e.g., "extern" can become "static" if a prior declaration was static). Patch by Enea Zaffanella and Paolo Bolzoni. llvm-svn: 101826
* Add printName to DeclarationName which prints the human-readable name on aBenjamin Kramer2010-04-171-6/+0
| | | | | | raw_ostream. Use it in getAsString and NamedDecl's raw_ostream operator. llvm-svn: 101633
* Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer2010-04-171-0/+6
| | | | | | | | users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. llvm-svn: 101632
* Fix an embarrasing memory error. I was apparently very tired when I wrote thisJohn McCall2010-04-131-1/+1
| | | | | | | | code the first time. Fixes PR6827. llvm-svn: 101184
* Implement dependent friend function template specializations.John McCall2010-04-081-0/+34
| | | | llvm-svn: 100753
* Implement the protected access restriction ([class.protected]), which requiresJohn McCall2010-04-061-0/+18
| | | | | | | | that protected members be used on objects of types which derive from the naming class of the lookup. My first N attempts at this were poorly-founded, largely because the standard is very badly worded here. llvm-svn: 100562
* Properly account for redeclarations when explicitly instantiating class ↵John McCall2010-03-261-4/+2
| | | | | | | | | | | | | templates. What happens here is that we actually turn the first declaration into a definition, regardless of whether it was actually originally a definition, and furthermore we do this all after we've instantiated all the declarations. This exposes a bug in my DefinitionData patch where it was only setting the DefinitionData for previous declarations, not future declarations. Fortunately, there's an iterator for that. llvm-svn: 99657
* Implement -Wshadow. Based on a patch by Mike M.!John McCall2010-03-161-1/+4
| | | | llvm-svn: 98684
* Remember declaration scope qualifiers in the AST. Imposes no memory overheadJohn McCall2010-03-151-6/+69
| | | | | | | | | | | on unqualified declarations. Patch by Enea Zaffanella! Minimal adjustments: allocate the ExtInfo nodes with the ASTContext and delete them during Destroy(). I audited a bunch of Destroy methods at the same time, to ensure that the correct teardown was being done. llvm-svn: 98540
* Make Decl::isOutOfLine() virtual, and use that to determine when definitionsChandler Carruth2010-02-211-4/+4
| | | | | | | are for out of line declarations more easily. This simplifies the logic and handles the case of out-of-line class definitions correctly. Fixes PR6107. llvm-svn: 96729
* Remove use of 'std::string' from Attr objects, using instead a byteTed Kremenek2010-02-111-9/+0
| | | | | | | | | array allocated using the allocator in ASTContext. This addresses these strings getting leaked when using a BumpPtrAllocator (in ASTContext). Fixes: <rdar://problem/7636765> llvm-svn: 95853
* Eliminate a bunch of unnecessary ASTContexts from members functions ofDouglas Gregor2010-02-111-13/+10
| | | | | | Decl subclasses. No functionality change. llvm-svn: 95841
* Eliminate the ASTContext parameter from RecordDecl::getDefinition()Douglas Gregor2010-02-111-1/+1
| | | | | | | and CXXRecordDecl::getDefinition(); it's totally unnecessary. No functionality change. llvm-svn: 95836
* Always start tag definitions before completing them. Assert same.John McCall2010-02-051-0/+4
| | | | | | Fixes latent and not-so-latent objc++ and blocks++ bugs. llvm-svn: 95340
* Extract a common structure for holding information about the definitionJohn McCall2010-02-041-0/+10
| | | | | | | | of a C++ record. Exposed a lot of problems where various routines were silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order) when presented with a non-definition. Also cuts down on memory usage. llvm-svn: 95330
* When a function or variable somehow depends on a type or declarationDouglas Gregor2010-02-031-25/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is in an anonymous namespace, give that function or variable internal linkage. This change models an oddity of the C++ standard, where names declared in an anonymous namespace have external linkage but, because anonymous namespace are really "uniquely-named" namespaces, the names cannot be referenced from other translation units. That means that they have external linkage for semantic analysis, but the only sensible implementation for code generation is to give them internal linkage. We now model this notion via the UniqueExternalLinkage linkage type. There are several changes here: - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage when the declaration is in an anonymous namespace. - Added Type::getLinkage() to determine the linkage of a type, which is defined as the minimum linkage of the types (when we're dealing with a compound type that is not a struct/class/union). - Extended NamedDecl::getLinkage() to consider the linkage of the template arguments and template parameters of function template specializations and class template specializations. - Taught code generation to rely on NamedDecl::getLinkage() when determining the linkage of variables and functions, also considering the linkage of the types of those variables and functions (C++ only). Map UniqueExternalLinkage to internal linkage, taking out the explicit checks for isInAnonymousNamespace(). This fixes much of PR5792, which, as discovered by Anders Carlsson, is actually the reason behind the pass-manager assertion that causes the majority of clang-on-clang regression test failures. With this fix, Clang-built-Clang+LLVM passes 88% of its regression tests (up from 67%). The specific numbers are: LLVM: Expected Passes : 4006 Expected Failures : 32 Unsupported Tests : 40 Unexpected Failures: 736 Clang: Expected Passes : 1903 Expected Failures : 14 Unexpected Failures: 75 Overall: Expected Passes : 5909 Expected Failures : 46 Unsupported Tests : 40 Unexpected Failures: 811 Still to do: - Improve testing - Check whether we should allow the presence of types with InternalLinkage (in addition to UniqueExternalLinkage) given variables/functions internal linkage in C++, as mentioned in PR5792. - Determine how expensive the getLinkage() calls are in practice; consider caching the result in NamedDecl. - Assess the feasibility of Chris's idea in comment #1 of PR5792. llvm-svn: 95216
* Fix a C++ regression where redefinitions weren't diagnosed.Sebastian Redl2010-02-021-1/+3
| | | | llvm-svn: 95096
* In C++, an initializer on a variable doesn't necessarily mean it's the ↵Sebastian Redl2010-02-011-7/+11
| | | | | | definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
* Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the ↵Sebastian Redl2010-01-311-11/+77
| | | | | | logic for when a variable declaration is a (possibly tentativ) definition. Add a few functions building on this, and shift C tentative definition handling over to this new functionality. This shift also kills the Sema::TentativeDefinitions map and instead simply stores all declarations in the renamed list. The correct handling for multiple tentative definitions is instead shifted to the final walk of the list. llvm-svn: 94968
* Bring some semblance of order into Decl.h and Decl.cpp. While at it, fix ↵Sebastian Redl2010-01-261-235/+247
| | | | | | some typo comments and remove an unused and unimplemented function prototype. No functionality change. llvm-svn: 94599
* Teach CIndex's cursor visitor to restrict its traversal to a specificDouglas Gregor2010-01-221-2/+6
| | | | | | | | | | | | | | region of interest (if provided). Implement clang_getCursor() in terms of this traversal rather than using the Index library; the unified cursor visitor is more complete, and will be The Way Forward. Minor other tweaks needed to make this work: - Extend Preprocessor::getLocForEndOfToken() to accept an offset from the end, making it easy to move to the last character in the token (rather than just past the end of the token). - In Lexer::MeasureTokenLength(), the length of whitespace is zero. llvm-svn: 94200
* Implement semantic checking for C++ literal operators.Alexis Hunt2010-01-131-0/+9
| | | | | | | This now rejects literal operators that don't meet the requirements. Templates are not yet checked for. llvm-svn: 93315
* Fix spelling.Mike Stump2010-01-061-1/+1
| | | | llvm-svn: 92816
* Typedefs can be redeclared. That seems like something we should record inJohn McCall2009-12-301-0/+3
| | | | | | the AST lest we run into some crazy canonicalization bug like PR5874. llvm-svn: 92283
* Fix for PR5871. Make __PRETTY_FUNCTION__ work for member functions defined ↵Sam Weinig2009-12-281-5/+28
| | | | | | in a class local to a function. llvm-svn: 92200
* Fix for PR5844. Be explicit about anonymous struct/class/union/namespaces in ↵Sam Weinig2009-12-241-0/+14
| | | | | | __PRETTY_FUNCTION__ predefined expression. llvm-svn: 92149
* If a ParmVarDecl's default argument is a CXXExprWithTemporaries, return the ↵Anders Carlsson2009-12-151-0/+29
| | | | | | underlying expr instead. Add getNumDefaultArgTemporaries and getDefaultArgTemporary which returns the temporaries a default arg creates. llvm-svn: 91439
* More improvements to checking allocation and deallocation functions.Anders Carlsson2009-12-131-2/+2
| | | | llvm-svn: 91244
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-1/+1
| | | | | | no extra safety anyway. llvm-svn: 91207
* First pass at implementing C++ enum semantics: calculate (and store) anJohn McCall2009-12-091-1/+4
| | | | | | | | | | | | "integer promotion" type associated with an enum decl, and use this type to determine which type to promote to. This type obeys C++ [conv.prom]p2 and is therefore generally signed unless the range of the enumerators forces it to be unsigned. Kills off a lot of false positives from -Wsign-compare in C++, addressing rdar://7455616 llvm-svn: 90965
* DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated ↵John McCall2009-12-071-11/+11
| | | | | | | | | | | | | | | | | | | | | variables, but the results are imperfect. For posterity, I did: cat <<EOF > $cmdfile s/DeclaratorInfo/TypeSourceInfo/g s/DInfo/TInfo/g s/TypeTypeSourceInfo/TypeSourceInfo/g s/SourceTypeSourceInfo/TypeSourceInfo/g EOF find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \; find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \; find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \; llvm-svn: 90743
* Be a little more clever about inline member functions that are marked inline ↵Anders Carlsson2009-12-041-1/+13
| | | | | | | | | | | | | | in the inline class declaration but not in the actual definition: class A { inline void f(); } void A::f() { } This is not the most ideal solution, since it doesn't work 100% with regular functions (as my FIXME comment states). llvm-svn: 90607
* Slight tweak to the algorithm for getLinkage().Eli Friedman2009-11-261-1/+1
| | | | llvm-svn: 89932
* Implement the rules in C++ [basic.link] and C99 6.2.2 for computingDouglas Gregor2009-11-251-7/+198
| | | | | | | | | | | the linkage of a declaration. Switch the lame (and completely wrong) NamedDecl::hasLinkage() over to using the new NamedDecl::getLinkage(), along with the "can this declaration be a template argument?" check that started all of this. Fixes -fsyntax-only for PR5597. llvm-svn: 89891
* Instead of hanging a using declaration's target decls directly off the using John McCall2009-11-171-1/+5
| | | | | | | decl, create shadow declarations and put them in scope like normal. Work in progress. llvm-svn: 89048
* Implement proper linkage for explicit instantiation declarations ofDouglas Gregor2009-10-271-3/+27
| | | | | | | | | | | | | | | | | | | | | inlined functions. For example, given template<typename T> class string { unsigned Len; public: unsigned size() const { return Len; } }; extern template class string<char>; we now give the instantiation of string<char>::size available_externally linkage (if it is ever instantiated!), as permitted by the C++0x standard. llvm-svn: 85340
* Introduce FunctionDecl::isInlined() to tell whether a function shouldDouglas Gregor2009-10-271-3/+6
| | | | | | be inlined. llvm-svn: 85307
* Rename FunctionDecl::isInline/setInline toDouglas Gregor2009-10-271-4/+4
| | | | | | FunctionDecl::isInlineSpecified/setInlineSpecified. llvm-svn: 85305
* Explicit instantiation suppresses the instantiation of non-inlineDouglas Gregor2009-10-271-0/+54
| | | | | | | function template specializations and member functions of class template specializations. llvm-svn: 85300
* An explicit instantiation definition only instantiations those classDouglas Gregor2009-10-271-0/+13
| | | | | | | | | members that have a definition. Also, use CheckSpecializationInstantiationRedecl as part of this instantiation to make sure that we diagnose the various kinds of problems that can occur with explicit instantiations. llvm-svn: 85270
OpenPOWER on IntegriCloud