summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Support the assume_aligned function attributeHal Finkel2014-09-261-0/+29
| | | | | | | | | In addition to __builtin_assume_aligned, GCC also supports an assume_aligned attribute which specifies the alignment (and optional offset) of a function's return value. Here we implement support for the assume_aligned attribute by making use of the @llvm.assume intrinsic. llvm-svn: 218500
* Revert r217995 and follow-ups:Hans Wennborg2014-09-181-35/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r218053: Use exceptions() instead of getNumExceptions()/getExceptionType() to avoid r218011: Work around MSVC parser bug by putting redundant braces around the body of r217997: Skip parens when detecting whether we're instantiating a function declaration. r217995: Instantiate exception specifications when instantiating function types (other The Windows build was broken for 16 hours and no one had any good ideas of how to fix it. Reverting for now to make the builders green. See the cfe-commits thread [1] for more info. This was the build error (from [2]): C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1590) : error C2668: '`anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType' : ambiguous call to overloaded function C:\bb-win7\ninja-clang-i686-msc17-R\llvm-project\clang\lib\Sema\SemaTemplateInstantiate.cpp(1313): could be 'clang::QualType `anonymous-namespace'::TemplateInstantiator::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] c:\bb-win7\ninja-clang-i686-msc17-r\llvm-project\clang\lib\sema\TreeTransform.h(4532): or 'clang::QualType clang::TreeTransform<Derived>::TransformFunctionProtoType<clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>>(clang::TypeLocBuilder &,clang::FunctionProtoTypeLoc,clang::CXXRecordDecl *,unsigned int,Fn)' with [ Derived=`anonymous-namespace'::TemplateInstantiator, Fn=clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735> ] while trying to match the argument list '(clang::TypeLocBuilder, clang::FunctionProtoTypeLoc, clang::CXXRecordDecl *, unsigned int, clang::Sema::SubstFunctionDeclType::<lambda_756edcbe7bd5c7584849a6e3a1491735>)' 1. http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140915/115011.html 2. http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/10515/steps/build_clang_tools_1/logs/stdio llvm-svn: 218058
* Instantiate exception specifications when instantiating function types (otherRichard Smith2014-09-171-133/+35
| | | | | | | | | | than the type of a function declaration). We previously didn't instantiate these at all! This also covers the pathological case where the only mention of a parameter pack is within the exception specification; this gives us a second way (other than alias templates) to reach the horrible state where a type contains an unexpanded pack, but its canonical type does not. llvm-svn: 217995
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* Fix member function call on null pointer in Sema::FindInstantiatedDecl.Alexey Samsonov2014-09-031-11/+11
| | | | | | This bug was reported by UBSan. llvm-svn: 217059
* [modules] Track the described template in an alias declaration that is theRichard Smith2014-08-261-0/+1
| | | | | | | pattern of an alias template declaration. Use this to merge alias templates properly when they're members of class template specializations. llvm-svn: 216437
* Don't assert on different DLL attributes in template and explicit ↵Hans Wennborg2014-08-241-0/+8
| | | | | | | | | | | | | | | | | | | | instantiation (PR20137) We would previously assert (a decl cannot have two DLL attributes) on this code: template <typename T> struct __declspec(dllimport) S { T f() { return T(); } }; template struct __declspec(dllexport) S<int>; The problem was that when instantiating, we would take the attribute from the template even if the instantiation itself already had an attribute. Also, don't inherit DLL attributes from the template to its members before instantiation, as the attribute may change. I couldn't figure out what MinGW does here, so I'm leaving that open. At least we're not asserting anymore. llvm-svn: 216340
* Make sure that vtables referenced from delay-parsed templates get referenced.Nico Weber2014-08-151-12/+15
| | | | | | | | | | | | | | This fixes PR20671, see the bug for details. In short, ActOnTranslationUnit() calls DefineUsedVTables() and only then PerformPendingInstantiations(). But PerformPendingInstantiations() is what does delayed template parsing, so vtables only references from late-parsed templates weren't marked used. As a fix, move the SavePendingInstantiationsAndVTableUsesRAII in PerformPendingInstantiations() up above the delayed template parsing code. That way, vtables referenced from templates end up in the RAII object, and the call to DefineUsedVTables() in PerformPendingInstantiations() marks them used. llvm-svn: 215786
* Add a RAII class for saving and restoring instantiations and uses. No ↵Nico Weber2014-08-151-39/+18
| | | | | | behavior change. llvm-svn: 215780
* Factor out exception specification information fromRichard Smith2014-07-311-18/+15
| | | | | | | | FunctionProtoType::ExtProtoInfo. Most of the users of these fields don't care about the other ExtProtoInfo bits and just want to talk about the exception specification. llvm-svn: 214450
* PR20256: don't accidentally instantiate non-dependent default-initialization asRichard Smith2014-07-101-2/+3
| | | | | | value-initialization. llvm-svn: 212764
* Remove llvm:: from uses of ArrayRef.Craig Topper2014-06-281-1/+1
| | | | llvm-svn: 211987
* Convert some function arguments to use ArrayRef.Craig Topper2014-06-261-12/+6
| | | | llvm-svn: 211764
* Fix bug in code for avoiding dynamic initialization of dllimport globalsHans Wennborg2014-06-181-1/+0
| | | | | | | | | | | | | When instantiating dllimport variables with dynamic initializers, don't bail out of Sema::InstantiateVariableInitializer without calling PopExpressionEvaluationContext(). This was causing a stale object to stay on the ExprEvalContexts stack, causing subsequent calls to getCurrentMangleNumberContext() to fail, resulting in incorrect numbering of static locals (and probably other broken things). llvm-svn: 211137
* Improve checking for dynamic initializers of dllimport fields in template ↵Hans Wennborg2014-06-101-8/+8
| | | | | | | | | instantiation We would previously assert if the initializer was dependent. I also think that checking isConstantInitializer is more correct here than checkInitIsICE. llvm-svn: 210505
* Don't dynamically initialize dllimport vars (PR19933)Hans Wennborg2014-06-041-0/+6
| | | | | | | | They should be initialized when they're exported. Differential Revision: http://reviews.llvm.org/D4020 llvm-svn: 210217
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-2/+2
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-13/+13
| | | | | | takeAs to getAs. llvm-svn: 209800
* When merging functions across modules (and in particular, instantiations ofRichard Smith2014-05-291-2/+10
| | | | | | | member functions), ensure that the redecl chain never transitions from 'inline' to 'not inline', since that violates an AST invariant. llvm-svn: 209794
* Move the logic for testing for namespace std into one location. This check canRichard Trieu2014-05-281-5/+1
| | | | | | be performed by using Decl::isInStdNamespace or DeclContext::isStdNamespace llvm-svn: 209708
* Retain isImplicit flag for local variable declarations when instantiatingAlexander Kornienko2014-05-271-0/+2
| | | | | | | | | | | | | | templates. Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3924 llvm-svn: 209686
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-151/+153
| | | | llvm-svn: 209613
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-1/+0
| | | | llvm-svn: 207896
* Rewrite NRVO determination. Track NRVO candidates on the parser Scope and ↵Nick Lewycky2014-05-031-0/+7
| | | | | | | | apply the NRVO candidate flag to all possible NRVO candidates here, and remove the flags in computeNRVO or upon template instantiation. A variable now has NRVO applied if and only if every return statement in that scope returns that variable. This is nearly optimal. Performs NRVO roughly 7% more often in a bootstrap build of clang. Patch co-authored by Richard Smith. llvm-svn: 207890
* Make typo-correction of inheriting constructors work a bit better. LimitRichard Smith2014-05-011-2/+1
| | | | | | | correction to direct base class members, and recover properly after we apply such a correction. llvm-svn: 207731
* If a using-declaration names a class member, but appears outside a class, tryRichard Smith2014-04-021-1/+1
| | | | | | to suggest a different syntax to get the same effect. llvm-svn: 205467
* PR19252: Fix crash if alignas is used with an auto-typed variable. Don't checkRichard Smith2014-03-271-3/+0
| | | | | | the type of the variable until it's known. llvm-svn: 204887
* Emit an update record if we instantiate the definition of a function templateRichard Smith2014-03-221-1/+3
| | | | | | | | specialization from a module. (This can also happen for function template specializations in PCHs if they're instantiated eagerly, because they're constexpr or have a deduced return type.) llvm-svn: 204547
* Refactor: move loading pending instantiations from chained PCHs to a more ↵Richard Smith2014-03-221-8/+2
| | | | | | appropriate place, so that we only ask the external source once. llvm-svn: 204535
* When the exception specification for a function in an imported PCH or module isRichard Smith2014-03-201-11/+4
| | | | | | resolved, emit an update record. llvm-svn: 204403
* PR19152: If a variable template's type involves 'auto', instantiate theRichard Smith2014-03-161-2/+5
| | | | | | initializer with the variable in order to determine the type. llvm-svn: 204015
* [C++11] Replacing OMPThreadPrivateDecl and OMPClause iterators ↵Aaron Ballman2014-03-141-4/+2
| | | | | | varlist_begin() and varlist_end() with iterator_range varlists(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203937
* [C++11] Replacing UsingDecl iterators shadow_begin() and shadow_end() with ↵Aaron Ballman2014-03-131-3/+1
| | | | | | iterator_range shadows(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203825
* [C++11] Replacing CXXRecordDecl iterators init_begin() and init_end() with ↵Aaron Ballman2014-03-131-5/+1
| | | | | | iterator_range inits(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203819
* PR18275: If a member function of a class template is declared with aRichard Smith2014-03-131-0/+11
| | | | | | | | | | | | | | | const-qualified parameter type and the defined with a non-const-qualified parameter type, the parameter is not const inside its body. Ensure that the type we use when instantiating the body is the right one. Patch by suyog sarda! This is still rather unsatisfactory; it seems like it might be better to instantiate at least the function parameters, and maybe the complete function declaration, when we instantiate the definition for such a member function (instead of reusing the declaration from inside the instantiated class definition). llvm-svn: 203741
* [C++11] Replacing Decl iterators attr_begin() and attr_end() with ↵Aaron Ballman2014-03-081-4/+1
| | | | | | | | iterator_range attrs(). Updating all of the usages of the iterators with range-based for loops. This is a reapplication of r203236 with modifications to the definition of attrs() and following the new style guidelines on auto usage. llvm-svn: 203362
* [C++11] Replacing EnumDecl iterators enumerator_begin() and enumerator_end() ↵Aaron Ballman2014-03-081-5/+3
| | | | | | with iterator_range enumerators(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203353
* Renaming the chains() ranged iterator to chain() per suggestion by Richard ↵Aaron Ballman2014-03-071-1/+1
| | | | | | Smith. llvm-svn: 203262
* [C++11] Replacing IndirectFieldDecl iterators chain_begin() and chain_end() ↵Aaron Ballman2014-03-071-4/+2
| | | | | | with iterator_range chains(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203261
* [C++11] Replacing iterators ddiag_begin() and ddiag_end() with ↵Aaron Ballman2014-03-071-4/+1
| | | | | | iterator_range ddiags(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203240
* Fully reverting r203236 -- it seems the only bots that are happy are the ↵Aaron Ballman2014-03-071-1/+4
| | | | | | MSVC bots. llvm-svn: 203237
* [C++11] Replacing iterators attr_begin() and attr_end() with iterator_range ↵Aaron Ballman2014-03-071-4/+1
| | | | | | attrs(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203236
* [OPENMP] Fix for threadprivate construct instantiatiation.Alexey Bataev2014-03-071-0/+3
| | | | llvm-svn: 203225
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-061-4/+2
| | | | | | iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely. llvm-svn: 203179
* [-cxx-abi microsoft] Implement local manglings accuratelyDavid Majnemer2014-03-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The MSVC ABI appears to mangle the lexical scope into the names of statics. Specifically, a counter is incremented whenever a scope is entered where things can be declared in such a way that an ambiguity can arise. For example, a class scope inside of a class scope doesn't do anything interesting because the nested class cannot collide with another nested class. There are problems with this scheme: - It is unreliable. The counter is only incremented when a previously never encountered scope is entered. There are cases where this will cause ambiguity amongst declarations that have the same name where one was introduced in a deep scope while the other was introduced right after in the previous lexical scope. - It is wasteful. Statements like: {{{{{{{ static int foo = a; }}}}}}} will make the mangling of "foo" larger than it need be because the scope counter has been incremented many times. Because of these problems, and practical implementation concerns. We choose not to implement this scheme if the local static or local type isn't visible. The mangling of these declarations will look very similar but the numbering will make far more sense, this scheme is lifted from the Itanium ABI implementation. Reviewers: rsmith, doug.gregor, rnk, eli.friedman, cdavis5x Reviewed By: rnk CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2953 llvm-svn: 202951
* Sema: Don't crash when trying to instantiate a local class with an invalid ↵David Majnemer2014-02-221-8/+5
| | | | | | | | | | | | | | | | base specifier It was previously thought that Sema::InstantiateClass could not fail from within this point in instantiate. However, it can happen if the class is invalid some way (i.e. invalid base specifier). This fixes PR18907. Differential Revision: http://llvm-reviews.chandlerc.com/D2850 llvm-svn: 201913
* Implement DR329. We already did the right thing here in C++98 mode, but r104014Richard Smith2014-02-031-47/+31
| | | | | | (which implemented the DR) was disabled in C++11. llvm-svn: 200673
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-7/+7
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Update FunctionTypeLoc and related names to match r199686Alp Toker2014-01-211-6/+7
| | | | llvm-svn: 199699
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-5/+5
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
OpenPOWER on IntegriCloud