[clang] 00c2739 - [clang][Interp][NFC] Move some declarations into the if condition

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


Author: Timm Bäder
Date: 2023-07-06T14:52:05+02:00
New Revision: 00c27397dc63358bc7e5975c7af80efbf863d2c2

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

LOG: [clang][Interp][NFC] Move some declarations into the if condition

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 1a5b683a3b6955..359e774d12716d 100644
--- a/clang/lib/AST/Interp/ByteCodeEmitter.cpp
+++ b/clang/lib/AST/Interp/ByteCodeEmitter.cpp
@@ -126,8 +126,9 @@ Scope::Local ByteCodeEmitter::createLocal(Descriptor *D) {
 void ByteCodeEmitter::emitLabel(LabelTy Label) {
   const size_t Target = Code.size();
   LabelOffsets.insert({Label, Target});
-  auto It = LabelRelocs.find(Label);
-  if (It != LabelRelocs.end()) {
+
+  if (auto It = LabelRelocs.find(Label);
+      It != LabelRelocs.end()) {
     for (unsigned Reloc : It->second) {
       using namespace llvm::support;
 
@@ -148,10 +149,9 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
   assert(aligned(Position));
 
   // If target is known, compute jump offset.
-  auto It = LabelOffsets.find(Label);
-  if (It != LabelOffsets.end()) {
+  if (auto It = LabelOffsets.find(Label);
+      It != LabelOffsets.end())
     return It->second - Position;
-  }
 
   // Otherwise, record relocation and return dummy offset.
   LabelRelocs[Label].push_back(Position);


        


More information about the cfe-commits mailing list