Skip to content

Commit

Permalink
Fix instantiation of specializations not to crash
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dobrev <[email protected]>
  • Loading branch information
ddobrev committed Oct 2, 2021
1 parent 0e963aa commit 851ec5e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/CppParser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3051,10 +3051,14 @@ void Parser::CompleteIfSpecializationType(const clang::QualType& QualType)
SemaDiagnostics->Decl = CTS;
c->getSema().getDiagnostics().setClient(SemaDiagnostics.get(), false);

Scope Scope(nullptr, Scope::ScopeFlags::ClassScope, c->getSema().getDiagnostics());
c->getSema().TUScope = &Scope;

c->getSema().InstantiateClassTemplateSpecialization(CTS->getBeginLoc(),
CTS, TSK_ImplicitInstantiation, false);

c->getSema().getDiagnostics().setClient(existingClient, false);
c->getSema().TUScope = nullptr;

auto CT = WalkClassTemplate(CTS->getSpecializedTemplate());
auto USR = GetDeclUSR(CTS);
Expand Down Expand Up @@ -3178,6 +3182,9 @@ void Parser::MarkValidity(Function* F)
SemaDiagnostics->Decl = FD;
c->getSema().getDiagnostics().setClient(SemaDiagnostics.get(), false);

Scope Scope(nullptr, Scope::ScopeFlags::FnScope, c->getSema().getDiagnostics());
c->getSema().TUScope = &Scope;

c->getSema().InstantiateFunctionDefinition(FD->getBeginLoc(), FD,
/*Recursive*/true);
F->isInvalid = FD->isInvalidDecl();
Expand All @@ -3188,6 +3195,7 @@ void Parser::MarkValidity(Function* F)
}

c->getSema().getDiagnostics().setClient(existingClient, false);
c->getSema().TUScope = nullptr;
}

void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F)
Expand Down

0 comments on commit 851ec5e

Please sign in to comment.