42
42
#include < clang/Parse/ParseAST.h>
43
43
#include < clang/Sema/Sema.h>
44
44
#include < clang/Sema/SemaConsumer.h>
45
+ #include < clang/Sema/Template.h>
45
46
#include < clang/Frontend/Utils.h>
46
47
#include < clang/Driver/Driver.h>
47
48
#include < clang/Driver/ToolChain.h>
@@ -3053,8 +3054,7 @@ void Parser::CompleteIfSpecializationType(const clang::QualType& QualType)
3053
3054
RD = const_cast <CXXRecordDecl*>(Type->getPointeeCXXRecordDecl ());
3054
3055
ClassTemplateSpecializationDecl* CTS;
3055
3056
if (!RD ||
3056
- !(CTS = llvm::dyn_cast<ClassTemplateSpecializationDecl>(RD)) ||
3057
- CTS->isCompleteDefinition ())
3057
+ !(CTS = llvm::dyn_cast<ClassTemplateSpecializationDecl>(RD)))
3058
3058
return ;
3059
3059
3060
3060
auto existingClient = c->getSema ().getDiagnostics ().getClient ();
@@ -3065,8 +3065,7 @@ void Parser::CompleteIfSpecializationType(const clang::QualType& QualType)
3065
3065
Scope Scope (nullptr , Scope::ScopeFlags::ClassScope, c->getSema ().getDiagnostics ());
3066
3066
c->getSema ().TUScope = &Scope;
3067
3067
3068
- c->getSema ().InstantiateClassTemplateSpecialization (CTS->getBeginLoc (),
3069
- CTS, TSK_ImplicitInstantiation, false );
3068
+ InstantiateSpecialization (CTS);
3070
3069
3071
3070
c->getSema ().getDiagnostics ().setClient (existingClient, false );
3072
3071
c->getSema ().TUScope = nullptr ;
@@ -3082,6 +3081,32 @@ void Parser::CompleteIfSpecializationType(const clang::QualType& QualType)
3082
3081
}
3083
3082
}
3084
3083
3084
+ void Parser::InstantiateSpecialization (clang::ClassTemplateSpecializationDecl* CTS)
3085
+ {
3086
+ using namespace clang ;
3087
+
3088
+ if (!CTS->isCompleteDefinition ())
3089
+ {
3090
+ c->getSema ().InstantiateClassTemplateSpecialization (CTS->getBeginLoc (),
3091
+ CTS, TSK_ImplicitInstantiation, false );
3092
+ }
3093
+
3094
+ for (auto Decl : CTS->decls ())
3095
+ {
3096
+ if (Decl->getKind () == Decl::Kind::CXXRecord)
3097
+ {
3098
+ CXXRecordDecl* Nested = cast<CXXRecordDecl>(Decl);
3099
+ CXXRecordDecl* Template = Nested->getInstantiatedFromMemberClass ();
3100
+ if (Template && !Nested->isCompleteDefinition () && !Nested->hasDefinition ())
3101
+ {
3102
+ c->getSema ().InstantiateClass (Nested->getBeginLoc (), Nested, Template,
3103
+ MultiLevelTemplateArgumentList (CTS->getTemplateArgs ()),
3104
+ TSK_ImplicitInstantiation, false );
3105
+ }
3106
+ }
3107
+ }
3108
+ }
3109
+
3085
3110
Parameter* Parser::WalkParameter (const clang::ParmVarDecl* PVD,
3086
3111
const clang::SourceLocation& ParamStartLoc)
3087
3112
{
0 commit comments