summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use more ArrayRefsDavid Majnemer2016-06-241-11/+9
| | | | | | No functional change is intended, just a small refactoring. llvm-svn: 273647
* [Sema] Don't crash when a field w/ a mem-initializer clashes with a record nameDavid Majnemer2016-06-091-2/+1
| | | | | | | | | | | It is possible for a field and a class to have the same name. In such cases, performing lookup for the field might return a result set with more than one entry. An overzealous assertion fired, causing us to crash instead of using the non-class lookup result. This fixes PR28060. llvm-svn: 272247
* Produce better pretty stack traces from crashes in template instantiation: addRichard Smith2016-05-261-0/+7
| | | | | | | | pretty stack trace entries for all cases where we instantiate the definition of something, and include the fully-qualified name with template arguments in the name of the instantiated entity. llvm-svn: 270904
* Re-commit r270748 "clang-cl: Treat dllimport explicit template instantiation ↵Hans Wennborg2016-05-261-0/+7
| | | | | | | | | | definitions as declarations (PR27810, PR27811)" Also make explicit instantiation decls not apply to nested classes when targeting MSVC. That dll attributes are not inherited by inner classes might be the explanation for MSVC's behaviour here. llvm-svn: 270897
* Preserve the FoundDecl when performing overload resolution for constructors.Richard Smith2016-05-111-2/+3
| | | | | | | | | This is in preparation for C++ P0136R1, which switches the model for inheriting constructors over from synthesizing a constructor to finding base class constructors (via using shadow decls) when looking for derived class constructors. llvm-svn: 269231
* [modules] Enforce the rules that an explicit or partial specialization must beRichard Smith2016-05-051-2/+13
| | | | | | | | declared before it is used. Because we don't use normal name lookup to find these, the normal code to filter out non-visible names from name lookup results does not apply. llvm-svn: 268585
* Make sure to perform dependent access checks when instantiating aRichard Smith2016-03-231-0/+5
| | | | | | | | lambda-expression. We don't actually instantiate the closure type / operator() in the template in order to produce the closure type / operator() in the instantiation, so this isn't caught by the normal path. llvm-svn: 264184
* Fix the template instantiation of ExtParameterInfos; tests to follow.John McCall2016-03-011-3/+6
| | | | llvm-svn: 262289
* [dllexport] Sort out emission order of delayed exported classesReid Kleckner2016-02-261-0/+10
| | | | | | | | | | | | | | | | Relands r260194 with a fix. If we have a template that transitions from an extern template to an explicitly instantiated dllexport template, we would add that class to the delayed exported class list without flushing it. For explicit instantiations, we can just flush the list of delayed classes immediately. We don't have to worry about the bug fixed in r260194 in this case because explicit instantiations can only occur at file and namespace scope. Fixes PR26490. llvm-svn: 262056
* Revert "Avoid forcing emission of delayed dllexported classes on template ↵Reid Kleckner2016-02-091-10/+0
| | | | | | | | | | instantiation" This reverts commit r260194. It caused PR26549. There's probably a better way to do this also. llvm-svn: 260241
* Avoid forcing emission of delayed dllexported classes on template instantiationReid Kleckner2016-02-091-0/+10
| | | | | | Fixes PR26490 llvm-svn: 260194
* Always build a new TypeSourceInfo for function templates with parametersNico Weber2016-02-011-16/+6
| | | | | | | | | | | | | | | | | | | | | RecursiveASTVisitor::TraverseFunctionHelper() traverses a function's ParmVarDecls by going to the function's getTypeSourceInfo if it exists, and `DEF_TRAVERSE_TYPELOC(FunctionProtoType` then goes to the function's ParmVarDecls. For a function template that doesn't have parameters that explicitly depend on the template parameter, we used to be clever and not build a new TypeSourceInfo. That meant that when an instantiation of such a template is visited, its TypeSourceInfo would point to the ParmVarDecls of the template, not of the instantiation, which then confused clients of RecursiveASTVisitor. So don't be clever for function templates that have parameters, even if none of the parameters depend on the type. Fixes PR26257. http://reviews.llvm.org/D16478 llvm-svn: 259428
* [Sema] ArrayRef-ize ActOnBaseSpecifiers. NFCCraig Topper2015-12-271-3/+1
| | | | llvm-svn: 256478
* Revert r256399 "[Sema] ArrayRef-ize ActOnBaseSpecifiers. NFC"Craig Topper2015-12-251-1/+3
| | | | | | It broke lldb build. llvm-svn: 256403
* [Sema] ArrayRef-ize SubstExprs. NFCCraig Topper2015-12-241-3/+4
| | | | llvm-svn: 256401
* [Sema] ArrayRef-ize ActOnBaseSpecifiers. NFCCraig Topper2015-12-241-3/+1
| | | | llvm-svn: 256399
* Correctly type-check the default arguments of local functionsJohn McCall2015-12-111-2/+5
| | | | | | | | when eagerly instantiating them. rdar://23721638 llvm-svn: 255325
* Revert r107690 (for PR7417) and add a testcase that it breaks. The approach ofRichard Smith2015-10-051-8/+0
| | | | | | | | | that change turns out to not be reasonable: mutating the AST of a parsed template during instantiation is not a sound thing to do, does not work across chained PCH / modules builds, and is in any case a special-case workaround to a more general problem that should be solved centrally. llvm-svn: 249342
* Fix FunctionParmPackExpr::Create() to take a ParmVarDecl* array.James Y Knight2015-09-301-4/+4
| | | | | | | | | | | | FunctionParmPackExpr actually stores an array of ParmVarDecl* (and accessors return that). But, the FunctionParmPackExpr::Create() constructor accepted an array of Decl *s instead. It was easy for this mismatch to occur without any obvious sign of something wrong, since both the store and the access used independent 'reinterpet_cast<XX>(this+1)' calls. llvm-svn: 248905
* Instantiate function declarations in instantiated functions.Serge Pavlov2015-08-231-5/+4
| | | | | | | | | | | | | | | | | If a function declaration is found inside a template function as in: template<class T> void f() { void g(int x = T::v) except(T::w); } it must be instantiated along with the enclosing template function, including default arguments and exception specification. Together with the patch committed in r240974 this implements DR1484. Differential Revision: http://reviews.llvm.org/D11194 llvm-svn: 245810
* Delay emitting members of dllexport classes until the class is fully parsed ↵Hans Wennborg2015-08-151-1/+1
| | | | | | | | | | | | | | | | | (PR23542) This enables Clang to correctly handle code such as: struct __declspec(dllexport) S { int x = 42; }; where it would otherwise error due to trying to generate the default constructor before the in-class initializer for x has been parsed. Differential Revision: http://reviews.llvm.org/D11850 llvm-svn: 245139
* Sema: Allow null names to be passed in to isAcceptableTagRedeclarationJustin Bogner2015-07-101-1/+1
| | | | | | | | | | | | | It's possible for TagRedeclarations to involve decls without a name, ie, anonymous enums. We hit some undefined behaviour if we bind these null names to the reference here. We never dereference the name, so it's harmless if it's null - make it a pointer to allow that. Fixes the Modules/submodules-merge-defs.cpp test under ubsan. llvm-svn: 241963
* Instantiation of local class members.Serge Pavlov2015-06-291-5/+18
| | | | | | | | | | | | If a function containing a local class is instantiated, instantiate all of local class member, including default arguments and exception specifications. This change fixes PR21332 and thus implements DR1484. Differential Revision: http://reviews.llvm.org/D9990 llvm-svn: 240974
* Fix crash-on-invalid bug in template instantiation.Manuel Klimek2015-06-261-27/+0
| | | | | | | | Get rid of code-path that (according to Richard Smith) is not needed but leads to a crasher bug when assuming a template has been fully instantiated and thus has a definition. llvm-svn: 240752
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Limit set of types instantiated in FindInstantiatedDecl.Serge Pavlov2015-05-151-3/+8
| | | | | | | | Starting from r236426 FindInstantiatedDecl may instantiate types that are referenced before definition. This change limit the set of types that can be instantiated by this function. llvm-svn: 237434
* Instantiate incomplete class used in template method.Serge Pavlov2015-05-041-0/+5
| | | | | | | | | | | If a class is absent from instantiation and is incomplete, instantiate it as an incomplete class thus avoiding compiler crash. This change fixes PR18653. Differential Revision: http://reviews.llvm.org/D8281 llvm-svn: 236426
* Combine instantiation context of field initializer with context of class.Serge Pavlov2015-04-281-1/+1
| | | | | | | | | | | | | | Inclass initializer is instantiated in its own LocalInstantiationScope. It causes problems when instantiating local classes - when instantiation scope is searched for DeclContext of the field, the search fails. As a solution, the instantiation scope of field initializer is combined with its outer scope. This patch fixes PR23194. Differential Revision: http://reviews.llvm.org/D9258 llvm-svn: 236005
* PR23334: Perform semantic checking of lambda capture initialization in the ↵Richard Smith2015-04-271-22/+14
| | | | | | | | | | | | | | | | | | right context. Previously we'd try to perform checks on the captures from the middle of parsing the lambda's body, at the point where we detected that a variable needed to be captured. This was wrong in a number of subtle ways. In PR23334, we couldn't correctly handle the list of potential odr-uses resulting from the capture, and our attempt to recover from that resulted in a use-after-free. We now defer building the initialization expression until we leave the lambda body and return to the enclosing context, where the initialization does the right thing. This patch only covers lambda-expressions, but we should apply the same change to blocks and captured statements too. llvm-svn: 235921
* Change range-based for-loops to be -Wrange-loop-analysis clean.Richard Trieu2015-04-151-1/+1
| | | | | | No functionality change. llvm-svn: 234964
* MS ABI: Build C++ default argument exprs for exported template classesReid Kleckner2015-03-171-0/+4
| | | | | | This was an omission from r232229. llvm-svn: 232554
* Sema: We can use delegating ctors now. NFC.Benjamin Kramer2015-03-061-117/+91
| | | | llvm-svn: 231488
* Sema: Disable template instantiation once a fatal error is raisedDavid Majnemer2015-01-301-0/+6
| | | | | | | | | | | | Fatal errors disable all further diagnostics. Continuing to permit template instantiation does nothing but make it take longer for clang to finish with the TU. Instead, halt all further instantiation. Fixed in PR22396. llvm-svn: 227556
* PR22117: Fix a case where we would get confused about which function parameterRichard Smith2015-01-091-7/+26
| | | | | | | | | | we're instantiating, if there's a ParmVarDecl within a FunctionDecl context that is not a parameter of that function. Add some asserts to catch this kind of issue more generally, and fix another bug exposed by those asserts where we were missing a local instantiation scope around substitution of explicitly-specified template arguments. llvm-svn: 225490
* Fix crash-on-valid if a lambda-expression appears lexically directly within aRichard Smith2014-11-201-1/+4
| | | | | | local class inside a template. llvm-svn: 222476
* Handle use of default member initializers before end of outermost classReid Kleckner2014-11-171-31/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, when we have this situation: struct A { template <typename T> struct B { int m1 = sizeof(A); }; B<int> m2; }; We can't parse m1's initializer eagerly because we need A to be complete. Therefore we wait until the end of A's class scope to parse it. However, we can trigger instantiation of B before the end of A, which will attempt to instantiate the field decls eagerly, and it would build a bad field decl instantiation that said it had an initializer but actually lacked one. Fixed by deferring instantiation of default member initializers until they are needed during constructor analysis. This addresses a long standing FIXME in the code. Fixes PR19195. Reviewed By: rsmith Differential Revision: http://reviews.llvm.org/D5690 llvm-svn: 222192
* Instantiate exception specifications when instantiating function types (otherRichard Smith2014-11-121-16/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. This is a re-commit of r219977: r219977 was reverted in r220038 because it hit a wrong-code bug in GCC 4.7.2. (That's gcc.gnu.org/PR56135, and affects any implicit lambda-capture of 'this' within a template.) r219977 was a re-commit of r217995, r218011, and r218053: r217995 was reverted in r218058 because it hit a rejects-valid bug in MSVC. (Incorrect overload resolution in the presence of using-declarations.) It was re-committed in r219977 with a workaround for the MSVC rejects-valid. r218011 was a workaround for an MSVC parser bug. (Incorrect desugaring of unbraced range-based for loop). llvm-svn: 221750
* Revert r219977, "Re-commit r217995 and follow-up patches (r217997, r218011, ↵NAKAMURA Takumi2014-10-171-46/+16
| | | | | | | | | | | | | r218053). These were" It broke some builders. I guess it'd be reproducible with --vg. Failing Tests (3): Clang :: CXX/except/except.spec/p1.cpp Clang :: SemaTemplate/instantiate-exception-spec-cxx11.cpp Clang :: SemaTemplate/instantiate-exception-spec.cpp llvm-svn: 220038
* Re-commit r217995 and follow-up patches (r217997, r218011, r218053). These wereRichard Smith2014-10-161-16/+46
| | | | | | | | | | | | | | | reverted in r218058 because they triggered a rejects-valid bug in MSVC. Original commit message from r217995: Instantiate exception specifications when instantiating function types (other 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: 219977
* Allow constant expressions in pragma loop hints.Tyler Nowicki2014-10-121-0/+20
| | | | | | | | Previously loop hints such as #pragma loop vectorize_width(#) required a constant. This patch allows a constant expression to be used as well. Such as a non-type template parameter or an expression (2 * c + 1). Reviewed by Richard Smith llvm-svn: 219589
* Revert r217995 and follow-ups:Hans Wennborg2014-09-181-43/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Skip parens when detecting whether we're instantiating a function declaration.Richard Smith2014-09-181-2/+2
| | | | llvm-svn: 217997
* Instantiate exception specifications when instantiating function types (otherRichard Smith2014-09-171-16/+42
| | | | | | | | | | 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
* Wrap to 80 columns. No behavior change.Nico Weber2014-07-281-3/+3
| | | | llvm-svn: 214059
* Make a small crash preventing change.Fariborz Jahanian2014-07-031-2/+2
| | | | llvm-svn: 212291
* Refactoring. Remove Owned method from Sema.Nikola Smiljanic2014-05-291-10/+8
| | | | llvm-svn: 209812
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-2/+2
| | | | | | takeAs to getAs. llvm-svn: 209800
* Consolidate some note diagnosticsAlp Toker2014-05-281-1/+1
| | | | | | | | | These note diags have the same message and can be unified further but for now let's just bring them together. Incidental change: Display a source range in the final attr diagnostic. llvm-svn: 209728
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-39/+40
| | | | llvm-svn: 209613
OpenPOWER on IntegriCloud