r374130 - Factor out some duplication. NFC.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 8 16:37:50 PDT 2019


Author: rsmith
Date: Tue Oct  8 16:37:49 2019
New Revision: 374130

URL: http://llvm.org/viewvc/llvm-project?rev=374130&view=rev
Log:
Factor out some duplication. NFC.

Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=374130&r1=374129&r2=374130&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Oct  8 16:37:49 2019
@@ -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(EvalRe
   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);
 }
 




More information about the cfe-commits mailing list