diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-08 23:37:49 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-10-08 23:37:49 +0000 |
commit | b9f58af3585b83da5648bb2971679d0474a03db3 (patch) | |
tree | 9750c139b6cfdd19e7e75ebe65ac4daf2a74aace | |
parent | b39c40c58951f18b5812ec839cdff5d9f41fe40e (diff) | |
download | clang-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.cpp | 8 |
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); } |