[clang] 658b655 - [clang][Interp][NFC] Refactor ByteCodeEmitter a bit

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 23 02:45:41 PDT 2023


Author: Timm Bäder
Date: 2023-09-23T11:45:30+02:00
New Revision: 658b655191e997258ac0e5f3308c59e51c2a1ee3

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

LOG: [clang][Interp][NFC] Refactor ByteCodeEmitter a bit

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeEmitter.cpp b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
index 9f0a2dfb47c9e7a..9b6adcc29bac5f1 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -109,23 +109,22 @@ ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {
     // Return a dummy function if compilation failed.
     if (BailLocation)
       return llvm::make_error<ByteCodeGenError>(*BailLocation);
-    else {
-      Func->setIsFullyCompiled(true);
-      return Func;
-    }
-  } else {
-    // Create scopes from descriptors.
-    llvm::SmallVector<Scope, 2> Scopes;
-    for (auto &DS : Descriptors) {
-      Scopes.emplace_back(std::move(DS));
-    }
 
-    // Set the function's code.
-    Func->setCode(NextLocalOffset, std::move(Code), std::move(SrcMap),
-                  std::move(Scopes), FuncDecl->hasBody());
     Func->setIsFullyCompiled(true);
     return Func;
   }
+
+  // Create scopes from descriptors.
+  llvm::SmallVector<Scope, 2> Scopes;
+  for (auto &DS : Descriptors) {
+    Scopes.emplace_back(std::move(DS));
+  }
+
+  // Set the function's code.
+  Func->setCode(NextLocalOffset, std::move(Code), std::move(SrcMap),
+                std::move(Scopes), FuncDecl->hasBody());
+  Func->setIsFullyCompiled(true);
+  return Func;
 }
 
 Scope::Local ByteCodeEmitter::createLocal(Descriptor *D) {


        


More information about the cfe-commits mailing list