[clang] ddbd8ff - [clang][Interp][NFC] Move a declaration into an if statement

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 13 05:10:35 PDT 2023


Author: Timm Bäder
Date: 2023-07-13T13:45:48+02:00
New Revision: ddbd8ffe314bf121c7e488de1b510dea5ecc8b42

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

LOG: [clang][Interp][NFC] Move a declaration into an if statement

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 4f61f87b0fd241..c6c4c787e5d849 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1610,7 +1610,6 @@ bool ByteCodeExprGen<Emitter>::visitExpr(const Expr *Exp) {
 template <class Emitter>
 bool ByteCodeExprGen<Emitter>::visitDecl(const VarDecl *VD) {
   assert(!VD->isInvalidDecl() && "Trying to constant evaluate an invalid decl");
-  std::optional<PrimType> VarT = classify(VD->getType());
 
   // Create and initialize the variable.
   if (!this->visitVarDecl(VD))
@@ -1630,7 +1629,7 @@ bool ByteCodeExprGen<Emitter>::visitDecl(const VarDecl *VD) {
   }
 
   // Return the value
-  if (VarT) {
+  if (std::optional<PrimType> VarT = classify(VD->getType())) {
     if (!this->emitLoadPop(*VarT, VD))
       return false;
 


        


More information about the cfe-commits mailing list