diff options
| author | Hubert Tong <hubert.reinterpretcast@gmail.com> | 2016-07-30 22:33:34 +0000 |
|---|---|---|
| committer | Hubert Tong <hubert.reinterpretcast@gmail.com> | 2016-07-30 22:33:34 +0000 |
| commit | e4a0c0ec78ed24bd564276f9af5dff1233ad4094 (patch) | |
| tree | 43e17b927c80dc42899de1109b3aa9046423541d /clang/lib | |
| parent | d08e18fc7dacd09e98211922130d06331b3b52e2 (diff) | |
| download | bcm5719-llvm-e4a0c0ec78ed24bd564276f9af5dff1233ad4094.tar.gz bcm5719-llvm-e4a0c0ec78ed24bd564276f9af5dff1233ad4094.zip | |
Reapply r276069 with workaround for MSVC 2013
llvm-svn: 277286
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 12 | ||||
| -rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 28 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaLambda.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplateDeduction.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 1 |
9 files changed, 48 insertions, 20 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 0d6ad9d0d60..2aa6a148e3e 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -651,6 +651,10 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( cast<TemplateTemplateParmDecl>(*P))); } + assert(!TTP->getRequiresClause() && + "Unexpected requires-clause on template template-parameter"); + LLVM_CONSTEXPR Expr *const CanonRequiresClause = nullptr; + TemplateTemplateParmDecl *CanonTTP = TemplateTemplateParmDecl::Create(*this, getTranslationUnitDecl(), SourceLocation(), TTP->getDepth(), @@ -660,7 +664,8 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( TemplateParameterList::Create(*this, SourceLocation(), SourceLocation(), CanonParams, - SourceLocation())); + SourceLocation(), + CanonRequiresClause)); // Get the new insert position for the node we care about. Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos); diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index bc1f9f96a06..76b495f84d5 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -2262,11 +2262,21 @@ TemplateParameterList *ASTNodeImporter::ImportTemplateParameterList( ToParams.push_back(cast<NamedDecl>(To)); } + Expr *ToRequiresClause; + if (Expr *const R = Params->getRequiresClause()) { + ToRequiresClause = Importer.Import(R); + if (!ToRequiresClause) + return nullptr; + } else { + ToRequiresClause = nullptr; + } + return TemplateParameterList::Create(Importer.getToContext(), Importer.Import(Params->getTemplateLoc()), Importer.Import(Params->getLAngleLoc()), ToParams, - Importer.Import(Params->getRAngleLoc())); + Importer.Import(Params->getRAngleLoc()), + ToRequiresClause); } TemplateArgument diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 37943cdd5b7..bcc8878eeae 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -31,9 +31,11 @@ using namespace clang; TemplateParameterList::TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params, - SourceLocation RAngleLoc) + SourceLocation RAngleLoc, + Expr *RequiresClause) : TemplateLoc(TemplateLoc), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc), - NumParams(Params.size()), ContainsUnexpandedParameterPack(false) { + NumParams(Params.size()), ContainsUnexpandedParameterPack(false), + HasRequiresClause(static_cast<bool>(RequiresClause)) { assert(this->NumParams == NumParams && "Too many template parameters"); for (unsigned Idx = 0; Idx < NumParams; ++Idx) { NamedDecl *P = Params[Idx]; @@ -52,15 +54,21 @@ TemplateParameterList::TemplateParameterList(SourceLocation TemplateLoc, // template parameter list does too. } } + if (RequiresClause) { + *getTrailingObjects<Expr *>() = RequiresClause; + } } -TemplateParameterList *TemplateParameterList::Create( - const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, - ArrayRef<NamedDecl *> Params, SourceLocation RAngleLoc) { - void *Mem = C.Allocate(totalSizeToAlloc<NamedDecl *>(Params.size()), +TemplateParameterList * +TemplateParameterList::Create(const ASTContext &C, SourceLocation TemplateLoc, + SourceLocation LAngleLoc, + ArrayRef<NamedDecl *> Params, + SourceLocation RAngleLoc, Expr *RequiresClause) { + void *Mem = C.Allocate(totalSizeToAlloc<NamedDecl *, Expr *>( + Params.size(), RequiresClause ? 1u : 0u), llvm::alignOf<TemplateParameterList>()); return new (Mem) TemplateParameterList(TemplateLoc, LAngleLoc, Params, - RAngleLoc); + RAngleLoc, RequiresClause); } unsigned TemplateParameterList::getMinRequiredArguments() const { @@ -1169,7 +1177,7 @@ createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC) { // <typename T, T ...Ints> NamedDecl *P[2] = {T, N}; auto *TPL = TemplateParameterList::Create( - C, SourceLocation(), SourceLocation(), P, SourceLocation()); + C, SourceLocation(), SourceLocation(), P, SourceLocation(), nullptr); // template <typename T, ...Ints> class IntSeq auto *TemplateTemplateParm = TemplateTemplateParmDecl::Create( @@ -1194,7 +1202,7 @@ createMakeIntegerSeqParameterList(const ASTContext &C, DeclContext *DC) { // template <template <typename T, T ...Ints> class IntSeq, typename T, T N> return TemplateParameterList::Create(C, SourceLocation(), SourceLocation(), - Params, SourceLocation()); + Params, SourceLocation(), nullptr); } static TemplateParameterList * @@ -1215,7 +1223,7 @@ createTypePackElementParameterList(const ASTContext &C, DeclContext *DC) { NamedDecl *Params[] = {Index, Ts}; return TemplateParameterList::Create(C, SourceLocation(), SourceLocation(), llvm::makeArrayRef(Params), - SourceLocation()); + SourceLocation(), nullptr); } static TemplateParameterList *createBuiltinTemplateParameterList( diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp index 472637ba800..a9462228d6c 100644 --- a/clang/lib/Sema/SemaLambda.cpp +++ b/clang/lib/Sema/SemaLambda.cpp @@ -235,7 +235,7 @@ getGenericLambdaTemplateParameterList(LambdaScopeInfo *LSI, Sema &SemaRef) { /*Template kw loc*/ SourceLocation(), LAngleLoc, llvm::makeArrayRef((NamedDecl *const *)LSI->AutoTemplateParams.data(), LSI->AutoTemplateParams.size()), - RAngleLoc); + RAngleLoc, nullptr); } return LSI->GLTemplateParameterList; } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 7fc5db82d32..fbae4ec5c42 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -832,11 +832,10 @@ Sema::ActOnTemplateParameterList(unsigned Depth, if (ExportLoc.isValid()) Diag(ExportLoc, diag::warn_template_export_unsupported); - // FIXME: store RequiresClause return TemplateParameterList::Create( Context, TemplateLoc, LAngleLoc, llvm::makeArrayRef((NamedDecl *const *)Params.data(), Params.size()), - RAngleLoc); + RAngleLoc, RequiresClause); } static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS) { @@ -1956,7 +1955,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier( // Fabricate an empty template parameter list for the invented header. return TemplateParameterList::Create(Context, SourceLocation(), SourceLocation(), None, - SourceLocation()); + SourceLocation(), nullptr); } return nullptr; diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 5740bc712e8..6fb3b53f91c 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4036,8 +4036,8 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *&Init, QualType &Result) { nullptr, false, false); QualType TemplArg = QualType(TemplParam->getTypeForDecl(), 0); NamedDecl *TemplParamPtr = TemplParam; - FixedSizeTemplateParameterListStorage<1> TemplateParamsSt( - Loc, Loc, TemplParamPtr, Loc); + FixedSizeTemplateParameterListStorage<1, false> TemplateParamsSt( + Loc, Loc, TemplParamPtr, Loc, nullptr); QualType FuncParam = SubstituteAutoTransform(*this, TemplArg).Apply(Type); assert(!FuncParam.isNull() && diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 967c2beec4c..208afa6de60 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -2932,10 +2932,14 @@ TemplateDeclInstantiator::SubstTemplateParams(TemplateParameterList *L) { if (Invalid) return nullptr; + // Note: we substitute into associated constraints later + Expr *const UninstantiatedRequiresClause = L->getRequiresClause(); + TemplateParameterList *InstL = TemplateParameterList::Create(SemaRef.Context, L->getTemplateLoc(), L->getLAngleLoc(), Params, - L->getRAngleLoc()); + L->getRAngleLoc(), + UninstantiatedRequiresClause); return InstL; } diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 491a0febd50..ec9503aa78f 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -7905,9 +7905,10 @@ ASTReader::ReadTemplateParameterList(ModuleFile &F, while (NumParams--) Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx)); + // TODO: Concepts TemplateParameterList* TemplateParams = TemplateParameterList::Create(Context, TemplateLoc, LAngleLoc, - Params, RAngleLoc); + Params, RAngleLoc, nullptr); return TemplateParams; } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 9a1e4f6778b..42e5b35f6d7 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -5381,6 +5381,7 @@ void ASTRecordWriter::AddTemplateParameterList( AddSourceLocation(TemplateParams->getTemplateLoc()); AddSourceLocation(TemplateParams->getLAngleLoc()); AddSourceLocation(TemplateParams->getRAngleLoc()); + // TODO: Concepts Record->push_back(TemplateParams->size()); for (const auto &P : *TemplateParams) AddDeclRef(P); |

