@@ -2978,18 +2978,19 @@ static const clang::CodeGen::CGFunctionInfo& GetCodeGenFunctionInfo(
2978
2978
FTy.castAs <clang::FunctionProtoType>());
2979
2979
}
2980
2980
2981
- bool Parser::CanCheckCodeGenInfo (clang::Sema& S, const clang::Type* Ty)
2981
+ bool Parser::CanCheckCodeGenInfo (const clang::Type* Ty)
2982
2982
{
2983
2983
auto FinalType = GetFinalType (Ty);
2984
2984
2985
2985
if (FinalType->isDependentType () ||
2986
- FinalType->isInstantiationDependentType () || FinalType->isUndeducedType ())
2986
+ FinalType->isInstantiationDependentType () ||
2987
+ FinalType->isUndeducedType ())
2987
2988
return false ;
2988
2989
2989
2990
if (FinalType->isFunctionType ())
2990
2991
{
2991
2992
auto FTy = FinalType->getAs <clang::FunctionType>();
2992
- auto CanCheck = CanCheckCodeGenInfo (S, FTy->getReturnType ().getTypePtr ());
2993
+ auto CanCheck = CanCheckCodeGenInfo (FTy->getReturnType ().getTypePtr ());
2993
2994
if (!CanCheck)
2994
2995
return false ;
2995
2996
@@ -2998,7 +2999,7 @@ bool Parser::CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
2998
2999
auto FPTy = FinalType->getAs <clang::FunctionProtoType>();
2999
3000
for (const auto & ParamType : FPTy->getParamTypes ())
3000
3001
{
3001
- auto CanCheck = CanCheckCodeGenInfo (S, ParamType.getTypePtr ());
3002
+ auto CanCheck = CanCheckCodeGenInfo (ParamType.getTypePtr ());
3002
3003
if (!CanCheck)
3003
3004
return false ;
3004
3005
}
@@ -3015,7 +3016,8 @@ bool Parser::CanCheckCodeGenInfo(clang::Sema& S, const clang::Type* Ty)
3015
3016
{
3016
3017
if (auto MPT = Ty->getAs <clang::MemberPointerType>())
3017
3018
if (!MPT->isDependentType ())
3018
- S.RequireCompleteType (clang::SourceLocation (), clang::QualType (Ty, 0 ), 1 );
3019
+ c->getSema ().RequireCompleteType (clang::SourceLocation (),
3020
+ clang::QualType (Ty, 0 ), 1 );
3019
3021
}
3020
3022
3021
3023
return true ;
@@ -3088,7 +3090,7 @@ void Parser::InstantiateSpecialization(clang::ClassTemplateSpecializationDecl* C
3088
3090
if (!CTS->isCompleteDefinition ())
3089
3091
{
3090
3092
c->getSema ().InstantiateClassTemplateSpecialization (CTS->getBeginLoc (),
3091
- CTS, TSK_ImplicitInstantiation, false );
3093
+ CTS, clang::TemplateSpecializationKind:: TSK_ImplicitInstantiation, false );
3092
3094
}
3093
3095
3094
3096
for (auto Decl : CTS->decls ())
@@ -3101,7 +3103,7 @@ void Parser::InstantiateSpecialization(clang::ClassTemplateSpecializationDecl* C
3101
3103
{
3102
3104
c->getSema ().InstantiateClass (Nested->getBeginLoc (), Nested, Template,
3103
3105
MultiLevelTemplateArgumentList (CTS->getTemplateArgs ()),
3104
- TSK_ImplicitInstantiation, false );
3106
+ clang::TemplateSpecializationKind:: TSK_ImplicitInstantiation, false );
3105
3107
}
3106
3108
}
3107
3109
}
@@ -3210,7 +3212,8 @@ void Parser::MarkValidity(Function* F)
3210
3212
3211
3213
auto FD = static_cast <FunctionDecl*>(F->originalPtr );
3212
3214
3213
- if (!FD->getTemplateInstantiationPattern () || !FD->isExternallyVisible ())
3215
+ if (!FD->isImplicit () &&
3216
+ (!FD->getTemplateInstantiationPattern () || !FD->isExternallyVisible ()))
3214
3217
return ;
3215
3218
3216
3219
auto existingClient = c->getSema ().getDiagnostics ().getClient ();
@@ -3230,6 +3233,18 @@ void Parser::MarkValidity(Function* F)
3230
3233
F->isInvalid = IsInvalid (FD->getBody (), Bodies);
3231
3234
}
3232
3235
3236
+ if (!F->isInvalid )
3237
+ {
3238
+ DeclContext* Context = FD->getDeclContext ();
3239
+ while (Context)
3240
+ {
3241
+ F->isInvalid = cast<Decl>(Context)->isInvalidDecl ();
3242
+ if (F->isInvalid )
3243
+ break ;
3244
+ Context = Context->getParent ();
3245
+ }
3246
+ }
3247
+
3233
3248
c->getSema ().getDiagnostics ().setClient (existingClient, false );
3234
3249
c->getSema ().TUScope = nullptr ;
3235
3250
}
@@ -3332,13 +3347,10 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F)
3332
3347
ParamStartLoc = VD->getEndLoc ();
3333
3348
}
3334
3349
3335
- if (!opts->skipFunctionBodies )
3350
+ if (!opts->skipFunctionBodies && FD-> hasBody () )
3336
3351
{
3337
- if (FD->hasBody ())
3338
- {
3339
- if (auto Body = FD->getBody ())
3340
- F->bodyStmt = WalkStatement (Body);
3341
- }
3352
+ if (auto Body = FD->getBody ())
3353
+ F->bodyStmt = WalkStatement (Body);
3342
3354
}
3343
3355
3344
3356
auto & CXXABI = codeGenTypes->getCXXABI ();
@@ -3355,15 +3367,17 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F)
3355
3367
if (auto FTSI = FD->getTemplateSpecializationInfo ())
3356
3368
F->specializationInfo = WalkFunctionTemplateSpec (FTSI, F);
3357
3369
3370
+ MarkValidity (F);
3371
+ F->qualifiedType = GetQualifiedType (FD->getType (), &FTL);
3372
+
3358
3373
const CXXMethodDecl* MD;
3359
3374
if (FD->isDependentContext () ||
3360
3375
((MD = dyn_cast<CXXMethodDecl>(FD)) && !MD->isStatic () &&
3361
3376
!HasLayout (cast<CXXRecordDecl>(MD->getDeclContext ()))) ||
3362
- !CanCheckCodeGenInfo (c-> getSema (), FD->getReturnType ().getTypePtr ()) ||
3377
+ !CanCheckCodeGenInfo (FD->getReturnType ().getTypePtr ()) ||
3363
3378
std::any_of (FD->parameters ().begin (), FD->parameters ().end (),
3364
- [this ](auto * P) { return !CanCheckCodeGenInfo (c-> getSema (), P->getType ().getTypePtr ()); }))
3379
+ [this ](auto * P) { return !CanCheckCodeGenInfo (P->getType ().getTypePtr ()); }))
3365
3380
{
3366
- F->qualifiedType = GetQualifiedType (FD->getType (), &FTL);
3367
3381
return ;
3368
3382
}
3369
3383
@@ -3377,9 +3391,6 @@ void Parser::WalkFunction(const clang::FunctionDecl* FD, Function* F)
3377
3391
F->Parameters [Index++]->isIndirect =
3378
3392
Arg.info .isIndirect () && !Arg.info .getIndirectByVal ();
3379
3393
}
3380
-
3381
- MarkValidity (F);
3382
- F->qualifiedType = GetQualifiedType (FD->getType (), &FTL);
3383
3394
}
3384
3395
3385
3396
Function* Parser::WalkFunction (const clang::FunctionDecl* FD)
0 commit comments