summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-10-08 23:37:49 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-10-08 23:37:49 +0000
commitb9f58af3585b83da5648bb2971679d0474a03db3 (patch)
tree9750c139b6cfdd19e7e75ebe65ac4daf2a74aace
parentb39c40c58951f18b5812ec839cdff5d9f41fe40e (diff)
downloadclang-b9f58af3585b83da5648bb2971679d0474a03db3.tar.gz
Factor out some duplication. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@374130 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ExprConstant.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 55ed550a1e..02639679a4 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -137,7 +137,7 @@ namespace {
/// Given an expression, determine the type used to store the result of
/// evaluating that expression.
- static QualType getStorageType(ASTContext &Ctx, Expr *E) {
+ static QualType getStorageType(const ASTContext &Ctx, const Expr *E) {
if (E->isRValue())
return E->getType();
return Ctx.getLValueReferenceType(E->getType());
@@ -13569,10 +13569,8 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, ConstExprUsage Usage,
if (!Info.discardCleanups())
llvm_unreachable("Unhandled cleanup; missing full expression marker?");
- QualType T = getType();
- if (!isRValue())
- T = Ctx.getLValueReferenceType(T);
- return CheckConstantExpression(Info, getExprLoc(), T, Result.Val, Usage) &&
+ return CheckConstantExpression(Info, getExprLoc(), getStorageType(Ctx, this),
+ Result.Val, Usage) &&
CheckMemoryLeaks(Info);
}