summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Preserve type source information in TypedefDecls. Preserve it acrossJohn McCall2009-10-241-3/+3
| | | | | | | | | template instantiation. Preserve it through PCH. Show it off to the indexer. I'm healthily ignoring the vector type cases because we don't have a sensible TypeLoc implementation for them anyway. llvm-svn: 84994
* Remove OriginalTypeParmDecl; the original type is the one specifiedJohn McCall2009-10-231-15/+0
| | | | | | | | | | | | | in the DeclaratorInfo, if one is present. Preserve source information through template instantiation. This is made more complicated by the possibility that ParmVarDecls don't have DIs, which is possibly worth fixing in the future. Also preserve source information for function parameters in ObjC method declarations. llvm-svn: 84971
* Move clients to use IdentifierInfo::getNameStart() instead of getName()Daniel Dunbar2009-10-181-1/+3
| | | | llvm-svn: 84436
* Clone the full Type hierarchy into the TypeLoc hierarchy. NormalizeJohn McCall2009-10-181-2/+9
| | | | | | | | | | | | | TypeLoc class names to be $(Type classname)Loc. Rewrite the visitor. Provide skeleton implementations for all the new TypeLocs. Handle all cases in PCH. Handle a few more cases when inserting location information in SemaType. It should be extremely straightforward to add new location information to existing TypeLoc objects now. llvm-svn: 84386
* Simplify checking of explicit template specialization/explicitDouglas Gregor2009-10-151-6/+32
| | | | | | | | | instantiation redeclaration semantics for function template specializations and member functions of class template specializations. Also, record the point of instantiation for explicit-instantiated functions and static data members. llvm-svn: 84188
* Give explicit and implicit instantiations of static data members ofDouglas Gregor2009-10-141-3/+18
| | | | | | | | class templates the proper linkage. Daniel, please look over the CodeGenModule bits. llvm-svn: 84140
* Testing and some minor fixes for explicit template instantiation.Douglas Gregor2009-10-141-1/+1
| | | | llvm-svn: 84129
* When explicitly specializing a member that is a template, mark theDouglas Gregor2009-10-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | template as a specialization. For example, this occurs with: template<typename T> struct X { template<typename U> struct Inner { /* ... */ }; }; template<> template<typename T> struct X<int>::Inner { T member; }; We need to treat templates that are member specializations as special in two contexts: - When looking for a definition of a member template, we look through the instantiation chain until we hit the primary template *or a member specialization*. This allows us to distinguish between the primary "Inner" definition and the X<int>::Inner definition, above. - When computing all of the levels of template arguments needed to instantiate a member template, don't add template arguments from contexts outside of the instantiation of a member specialization, since the user has already manually substituted those arguments. Fix up the existing test for p18, which was actually wrong (but we didn't diagnose it because of our poor handling of member specializations of templates), and add a new test for member specializations of templates. llvm-svn: 83974
* Diagnose the declaration of explicit specializations after an implicitDouglas Gregor2009-10-121-6/+11
| | | | | | | instantiation has already been required. To do so, keep track of the point of instantiation for anything that can be instantiated. llvm-svn: 83890
* Refactor the LookupResult API to simplify most common operations. Require ↵John McCall2009-10-091-0/+3
| | | | | | | | | users to pass a LookupResult reference to lookup routines. Call out uses which assume a single result. llvm-svn: 83674
* For instantiations of static data members of class templates, keepDouglas Gregor2009-10-081-1/+20
| | | | | | | | track of the kind of specialization or instantiation. Also, check the scope of the specialization and ensure that a specialization declaration without an initializer is not a definition. llvm-svn: 83533
* Keep track of whether a member function instantiated from a memberDouglas Gregor2009-10-071-20/+46
| | | | | | | | | function of a class template was implicitly instantiated, explicitly instantiated (declaration or definition), or explicitly specialized. The same MemberSpecializationInfo structure will be used for static data members and member classes as well. llvm-svn: 83509
* -Introduce TypeLoc::getOpaqueData()Argyrios Kyrtzidis2009-09-291-1/+1
| | | | | | -Make TypeLoc's constructor public. llvm-svn: 83088
* Fix http://llvm.org/PR5090.Mike Stump2009-09-291-0/+4
| | | | llvm-svn: 83035
* WIP implementation of explicit function template specialization. ThisDouglas Gregor2009-09-241-4/+18
| | | | | | | | | | | | | | | | | | | | | first implementation recognizes when a function declaration is an explicit function template specialization (based on the presence of a template<> header), performs template argument deduction + ambiguity resolution to determine which template is being specialized, and hooks There are many caveats here: - We completely and totally drop any explicitly-specified template arguments on the floor - We don't diagnose any of the extra semantic things that we should diagnose. - I haven't looked to see that we're getting the right linkage for explicit specializations On a happy note, this silences a bunch of errors that show up in libstdc++'s <iostream>, although Clang still can't get through the entire header. llvm-svn: 82728
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-1/+1
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Rework the way we determine whether an externally visible symbol isDouglas Gregor2009-09-131-18/+57
| | | | | | | | generated for an inline function definition, taking into account C99 and GNU inline/extern inline semantics. This solution is simpler, cleaner, and fixes PR4536. llvm-svn: 81670
* Remove unnecessary ASTContext parameter from FunctionDecl::isBuiltinIDDouglas Gregor2009-09-121-1/+2
| | | | llvm-svn: 81590
* Remove unnecessary ASTContext parameters from isMain and isExternCDouglas Gregor2009-09-121-3/+6
| | | | llvm-svn: 81589
* Eliminate FunctionDecl::getBodyIfAvailableDouglas Gregor2009-09-121-10/+0
| | | | llvm-svn: 81588
* Tweak the semantics of FunctionDecl::isOutOfLine to consider anDouglas Gregor2009-09-111-0/+24
| | | | | | | | | | instantiation of a member function template or member function of a class template to be out-of-line if the definition of that function template or member function was defined out-of-line. This ensures that we get the correct linkage for explicit instantiations of out-of-line definitions. llvm-svn: 81562
OpenPOWER on IntegriCloud