@@ -8951,39 +8951,39 @@ static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
8951
8951
}
8952
8952
8953
8953
bool LValueExprEvaluator::VisitDeclRefExpr(const DeclRefExpr *E) {
8954
- const NamedDecl *D = E->getDecl();
8955
- if (isa<FunctionDecl, MSGuidDecl, TemplateParamObjectDecl,
8956
- UnnamedGlobalConstantDecl>(D))
8957
- return Success(cast<ValueDecl>(D));
8958
- if (const VarDecl *VD = dyn_cast<VarDecl>(D))
8959
- return VisitVarDecl(E, VD);
8960
- if (const BindingDecl *BD = dyn_cast<BindingDecl>(D))
8961
- return Visit(BD->getBinding());
8962
- return Error(E);
8963
- }
8954
+ const ValueDecl *D = E->getDecl();
8964
8955
8965
- bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
8966
8956
// If we are within a lambda's call operator, check whether the 'VD' referred
8967
8957
// to within 'E' actually represents a lambda-capture that maps to a
8968
8958
// data-member/field within the closure object, and if so, evaluate to the
8969
8959
// field or what the field refers to.
8970
8960
if (Info.CurrentCall && isLambdaCallOperator(Info.CurrentCall->Callee) &&
8971
- isa<DeclRefExpr>(E) &&
8972
- cast<DeclRefExpr>(E)->refersToEnclosingVariableOrCapture()) {
8961
+ E->refersToEnclosingVariableOrCapture()) {
8973
8962
// We don't always have a complete capture-map when checking or inferring if
8974
8963
// the function call operator meets the requirements of a constexpr function
8975
8964
// - but we don't need to evaluate the captures to determine constexprness
8976
8965
// (dcl.constexpr C++17).
8977
8966
if (Info.checkingPotentialConstantExpression())
8978
8967
return false;
8979
8968
8980
- if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(VD )) {
8969
+ if (auto *FD = Info.CurrentCall->LambdaCaptureFields.lookup(D )) {
8981
8970
const auto *MD = cast<CXXMethodDecl>(Info.CurrentCall->Callee);
8982
8971
return HandleLambdaCapture(Info, E, Result, MD, FD,
8983
8972
FD->getType()->isReferenceType());
8984
8973
}
8985
8974
}
8986
8975
8976
+ if (isa<FunctionDecl, MSGuidDecl, TemplateParamObjectDecl,
8977
+ UnnamedGlobalConstantDecl>(D))
8978
+ return Success(cast<ValueDecl>(D));
8979
+ if (const VarDecl *VD = dyn_cast<VarDecl>(D))
8980
+ return VisitVarDecl(E, VD);
8981
+ if (const BindingDecl *BD = dyn_cast<BindingDecl>(D))
8982
+ return Visit(BD->getBinding());
8983
+ return Error(E);
8984
+ }
8985
+
8986
+ bool LValueExprEvaluator::VisitVarDecl(const Expr *E, const VarDecl *VD) {
8987
8987
CallStackFrame *Frame = nullptr;
8988
8988
unsigned Version = 0;
8989
8989
if (VD->hasLocalStorage()) {
0 commit comments