@@ -3088,7 +3088,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD,
3088
3088
// [...] A member shall not be declared twice in the
3089
3089
// member-specification, except that a nested class or member
3090
3090
// class template can be declared and then later defined.
3091
- if (ActiveTemplateInstantiations.empty ()) {
3091
+ if (!inTemplateInstantiation ()) {
3092
3092
unsigned NewDiag;
3093
3093
if (isa<CXXConstructorDecl>(OldMethod))
3094
3094
NewDiag = diag::err_constructor_redeclared;
@@ -9061,7 +9061,7 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
9061
9061
9062
9062
// Warn that we did this, if we're not performing template instantiation.
9063
9063
// In that case, we'll have warned already when the template was defined.
9064
- if (ActiveTemplateInstantiations.empty ()) {
9064
+ if (!inTemplateInstantiation ()) {
9065
9065
SourceLocation AddConstLoc;
9066
9066
if (FunctionTypeLoc FTL = MD->getTypeSourceInfo()->getTypeLoc()
9067
9067
.IgnoreParens().getAs<FunctionTypeLoc>())
@@ -9918,8 +9918,8 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
9918
9918
// checks.
9919
9919
// We only want to warn outside of template instantiations, though:
9920
9920
// inside a template, the 'id' could have come from a parameter.
9921
- if (ActiveTemplateInstantiations.empty () && !DefaultedAnyToId &&
9922
- !IsInitCapture && ! DeducedType.isNull() && DeducedType->isObjCIdType()) {
9921
+ if (!inTemplateInstantiation () && !DefaultedAnyToId && !IsInitCapture &&
9922
+ !DeducedType.isNull() && DeducedType->isObjCIdType()) {
9923
9923
SourceLocation Loc = TSI->getTypeLoc().getBeginLoc();
9924
9924
Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
9925
9925
}
@@ -10821,7 +10821,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
10821
10821
// Apply section attributes and pragmas to global variables.
10822
10822
bool GlobalStorage = var->hasGlobalStorage();
10823
10823
if (GlobalStorage && var->isThisDeclarationADefinition() &&
10824
- ActiveTemplateInstantiations.empty ()) {
10824
+ !inTemplateInstantiation ()) {
10825
10825
PragmaStack<StringLiteral *> *Stack = nullptr;
10826
10826
int SectionFlags = ASTContext::PSF_Implicit | ASTContext::PSF_Read;
10827
10827
if (var->getType().isConstQualified())
@@ -11472,7 +11472,7 @@ ParmVarDecl *Sema::BuildParmVarDeclForTypedef(DeclContext *DC,
11472
11472
void Sema::DiagnoseUnusedParameters(ArrayRef<ParmVarDecl *> Parameters) {
11473
11473
// Don't diagnose unused-parameter errors in template instantiations; we
11474
11474
// will already have done so in the template itself.
11475
- if (!ActiveTemplateInstantiations.empty ())
11475
+ if (inTemplateInstantiation ())
11476
11476
return;
11477
11477
11478
11478
for (const ParmVarDecl *Parameter : Parameters) {
@@ -11822,14 +11822,14 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
11822
11822
// captures during transformation of nested lambdas, it is necessary to
11823
11823
// have the LSI properly restored.
11824
11824
if (isGenericLambdaCallOperatorSpecialization(FD)) {
11825
- assert(ActiveTemplateInstantiations.size () &&
11826
- "There should be an active template instantiation on the stack "
11827
- "when instantiating a generic lambda!");
11825
+ assert(inTemplateInstantiation () &&
11826
+ "There should be an active template instantiation on the stack "
11827
+ "when instantiating a generic lambda!");
11828
11828
RebuildLambdaScopeInfo(cast<CXXMethodDecl>(D), *this);
11829
- }
11830
- else
11829
+ } else {
11831
11830
// Enter a new function scope
11832
11831
PushFunctionScope();
11832
+ }
11833
11833
11834
11834
// Builtin functions cannot be defined.
11835
11835
if (unsigned BuiltinID = FD->getBuiltinID()) {
@@ -12706,7 +12706,7 @@ bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous,
12706
12706
if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
12707
12707
isTemplate = Record->getDescribedClassTemplate();
12708
12708
12709
- if (!ActiveTemplateInstantiations.empty ()) {
12709
+ if (inTemplateInstantiation ()) {
12710
12710
// In a template instantiation, do not offer fix-its for tag mismatches
12711
12711
// since they usually mess up the template instead of fixing the problem.
12712
12712
Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
0 commit comments