present.
No functionality change intended.
Differential Revision: https://reviews.llvm.org/D76438
bool isImmediateInvocation() const {
return ConstantExprBits.IsImmediateInvocation;
}
+ bool hasAPValueResult() const {
+ return ConstantExprBits.APValueKind != APValue::None;
+ }
APValue getAPValueResult() const;
APValue &getResultAsAPValue() const { return APValueResult(); }
llvm::APSInt getResultAsAPSInt() const;
}
APValue ConstantExpr::getAPValueResult() const {
+ assert(hasAPValueResult());
+
switch (ConstantExprBits.ResultKind) {
case ConstantExpr::RSK_APValue:
return APValueResult();
return CE->getChosenSubExpr();
}
- else if (auto *CE = dyn_cast<ConstantExpr>(E))
- return CE->getSubExpr();
-
return E;
}
return Error(E);
}
- bool VisitConstantExpr(const ConstantExpr *E)
- { return StmtVisitorTy::Visit(E->getSubExpr()); }
+ bool VisitConstantExpr(const ConstantExpr *E) {
+ if (E->hasAPValueResult())
+ return DerivedSuccess(E->getAPValueResult(), E);
+
+ return StmtVisitorTy::Visit(E->getSubExpr());
+ }
+
bool VisitParenExpr(const ParenExpr *E)
{ return StmtVisitorTy::Visit(E->getSubExpr()); }
bool VisitUnaryExtension(const UnaryOperator *E)
return ExprError();
}
+ ExprResult RValueExpr = DefaultLvalueConversion(E);
+ if (RValueExpr.isInvalid())
+ return ExprError();
+
+ E = RValueExpr.get();
+
// Circumvent ICE checking in C++11 to avoid evaluating the expression twice
// in the non-ICE case.
if (!getLangOpts().CPlusPlus11 && E->isIntegerConstantExpr(Context)) {