@@ -989,6 +989,9 @@ static bool getParameterName(ParmVarDecl *PVD, std::string &Out) {
989
989
StringRef FirstNameSeen = PVD->getName ();
990
990
unsigned ParamIdx = PVD->getFunctionScopeIndex ();
991
991
992
+ // TODO(P2996): This will crash if we're in the trailing requires-clause of
993
+ // a function declaration, since the DeclContext is not the function but the
994
+ // TranslationUnitDecl.
992
995
FunctionDecl *FD = cast<FunctionDecl>(PVD->getDeclContext ());
993
996
FD = FD->getMostRecentDecl ();
994
997
@@ -1019,6 +1022,9 @@ static bool getParameterName(ParmVarDecl *PVD, std::string &Out) {
1019
1022
}
1020
1023
1021
1024
static ParmVarDecl *getMostRecentParmVarDecl (ParmVarDecl *PVD) {
1025
+ // TODO(P2996): This will crash if we're in the trailing requires-clause of
1026
+ // a function declaration, since the DeclContext is not the function but the
1027
+ // TranslationUnitDecl.
1022
1028
FunctionDecl *FD = cast<FunctionDecl>(PVD->getDeclContext ());
1023
1029
FD = FD->getMostRecentDecl ();
1024
1030
return FD->getParamDecl (PVD->getFunctionScopeIndex ());
@@ -5570,14 +5576,22 @@ bool current_access_context(APValue &Result, ASTContext &C, MetaActions &Meta,
5570
5576
SourceRange Range, ArrayRef<Expr *> Args,
5571
5577
Decl *ContainingDecl) {
5572
5578
assert (ResultTy == C.MetaInfoTy );
5579
+ Decl *Ctx = nullptr ;
5573
5580
5574
5581
StackLocationExpr *SLE = StackLocationExpr::Create (C, SourceRange (), 1 );
5575
- if (!Evaluator (Result, SLE, true ) || !Result.isReflection ())
5582
+ if (!Evaluator (Result, SLE, true ) || !Result.isReflectedDecl ())
5576
5583
return true ;
5577
- else if (Result.getReflectedDecl () != nullptr )
5578
- return false ;
5584
+ else if (Ctx = Result.getReflectedDecl (); !Ctx)
5585
+ Ctx = Meta.CurrentCtx ();
5586
+
5587
+ if (auto *Ctor = dyn_cast<CXXConstructorDecl>(Ctx);
5588
+ Ctor && Ctor->isInheritingConstructor ())
5589
+ Ctx = cast<Decl>(Ctor->getDeclContext ());
5579
5590
5580
- return SetAndSucceed (Result, makeReflection (Meta.CurrentCtx ()));
5591
+ if (auto *RD = dyn_cast<CXXRecordDecl>(Ctx))
5592
+ return SetAndSucceed (Result,
5593
+ makeReflection (QualType (RD->getTypeForDecl (), 0 )));
5594
+ return SetAndSucceed (Result, makeReflection (Ctx));
5581
5595
}
5582
5596
5583
5597
bool is_accessible (APValue &Result, ASTContext &C, MetaActions &Meta,
0 commit comments