diff options
author | Alexander Shaposhnikov <ashaposhnikov@google.com> | 2023-03-10 09:10:37 +0000 |
---|---|---|
committer | Alexander Shaposhnikov <ashaposhnikov@google.com> | 2023-03-10 09:21:09 +0000 |
commit | 421c098b32bd50122de8de03a71092c7f36994eb (patch) | |
tree | 1a116f71657411f359946207b3edb8e1522282e2 /clang/lib/Parse/ParseDecl.cpp | |
parent | bf00eda69f4b7044f8eb37027485986883516780 (diff) | |
download | llvm-421c098b32bd50122de8de03a71092c7f36994eb.zip llvm-421c098b32bd50122de8de03a71092c7f36994eb.tar.gz llvm-421c098b32bd50122de8de03a71092c7f36994eb.tar.bz2 |
[Clang][Sema] Start fixing handling of out-of-line definitions of constrained templates
This diff starts fixing our handling of out-of-line definitions of constrained templates.
Initially it was motivated by https://github.com/llvm/llvm-project/issues/49620 and
https://github.com/llvm/llvm-project/issues/60231.
In particular, this diff adjusts Sema::computeDeclContext to work properly in the case of
constrained template parameters.
Test plan:
1/ ninja check-all
2/ Bootstrapped Clang passes all the tests
3/ Internal testing
Differential revision: https://reviews.llvm.org/D145034
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 3106571..da84da0 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3380,6 +3380,8 @@ void Parser::ParseDeclarationSpecifiers( goto DoneWithDeclSpec; CXXScopeSpec SS; + if (TemplateInfo.TemplateParams) + SS.setTemplateParamLists(*TemplateInfo.TemplateParams); Actions.RestoreNestedNameSpecifierAnnotation(Tok.getAnnotationValue(), Tok.getAnnotationRange(), SS); @@ -3475,7 +3477,8 @@ void Parser::ParseDeclarationSpecifiers( &SS) && isConstructorDeclarator(/*Unqualified=*/false, /*DeductionGuide=*/false, - DS.isFriendSpecified())) + DS.isFriendSpecified(), + &TemplateInfo)) goto DoneWithDeclSpec; // C++20 [temp.spec] 13.9/6. @@ -4957,6 +4960,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS, assert(TemplateInfo.TemplateParams && "no template parameters"); TParams = MultiTemplateParamsArg(TemplateInfo.TemplateParams->data(), TemplateInfo.TemplateParams->size()); + SS.setTemplateParamLists(TParams); } if (!Name && TUK != Sema::TUK_Definition) { @@ -5679,11 +5683,15 @@ bool Parser::isDeclarationSpecifier( } bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide, - DeclSpec::FriendSpecified IsFriend) { + DeclSpec::FriendSpecified IsFriend, + const ParsedTemplateInfo *TemplateInfo) { TentativeParsingAction TPA(*this); // Parse the C++ scope specifier. CXXScopeSpec SS; + if (TemplateInfo && TemplateInfo->TemplateParams) + SS.setTemplateParamLists(*TemplateInfo->TemplateParams); + if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr, /*ObjectHasErrors=*/false, /*EnteringContext=*/true)) { @@ -6075,6 +6083,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D, bool EnteringContext = D.getContext() == DeclaratorContext::File || D.getContext() == DeclaratorContext::Member; CXXScopeSpec SS; + SS.setTemplateParamLists(D.getTemplateParameterLists()); ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr, /*ObjectHasErrors=*/false, EnteringContext); |