[clang] 3ec1274 - [clang][NFC] Move two declarations closer to their point of use

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 4 23:54:48 PDT 2023


Author: Timm Bäder
Date: 2023-07-05T08:54:24+02:00
New Revision: 3ec12740d0bc1b14bcafb8c9ece9e679f6957e9a

URL: https://github.com/llvm/llvm-project/commit/3ec12740d0bc1b14bcafb8c9ece9e679f6957e9a
DIFF: https://github.com/llvm/llvm-project/commit/3ec12740d0bc1b14bcafb8c9ece9e679f6957e9a.diff

LOG: [clang][NFC] Move two declarations closer to their point of use

Added: 
    

Modified: 
    clang/lib/AST/ExprConstant.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 09466253778a90..39e6b634eb2520 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15477,9 +15477,6 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
   Info.setEvaluatingDecl(VD, Value);
   Info.InConstantContext = IsConstantInitialization;
 
-  SourceLocation DeclLoc = VD->getLocation();
-  QualType DeclTy = VD->getType();
-
   if (Info.EnableNewConstInterp) {
     auto &InterpCtx = const_cast<ASTContext &>(Ctx).getInterpContext();
     if (!InterpCtx.evaluateAsInitializer(Info, VD, Value))
@@ -15500,6 +15497,9 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
     if (!Info.discardCleanups())
       llvm_unreachable("Unhandled cleanup; missing full expression marker?");
   }
+
+  SourceLocation DeclLoc = VD->getLocation();
+  QualType DeclTy = VD->getType();
   return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,
                                  ConstantExprKind::Normal) &&
          CheckMemoryLeaks(Info);


        


More information about the cfe-commits mailing list