[Lldb-commits] [lldb] 08201cb - [lldb][test] Fix GCC warnings in TestGetControlFlowKindX86.cpp

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 19 08:36:14 PDT 2024


Author: David Spickett
Date: 2024-08-19T16:35:47+01:00
New Revision: 08201cb4245b0a03e1af664e00a22ea4db1fc2fb

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

LOG: [lldb][test] Fix GCC warnings in TestGetControlFlowKindX86.cpp

```
<...>/TestGetControlFlowKindx86.cpp:148:8: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]
  148 |     if (kind == eInstructionControlFlowKindReturn)
      |        ^
```

Usually llvm is a "no braces for single line body" project but
for whatever reason gcc objects to it here. Perhaps because it's
within a for loop.

Added the newlines just for readability.

Added: 
    

Modified: 
    lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp b/lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
index fecd93361e5633..e9d5ae3f7b3cdb 100644
--- a/lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
+++ b/lldb/unittests/Disassembler/x86/TestGetControlFlowKindx86.cpp
@@ -145,14 +145,19 @@ TEST_F(TestGetControlFlowKindx86, TestX86_64Instruction) {
     EXPECT_EQ(kind, result[i]);
 
     // Also, test the DisassemblerLLVMC::MCDisasmInstance methods.
-    if (kind == eInstructionControlFlowKindReturn)
+    if (kind == eInstructionControlFlowKindReturn) {
       EXPECT_FALSE(inst_sp->IsCall());
-    if (kind == eInstructionControlFlowKindCall)
+    }
+
+    if (kind == eInstructionControlFlowKindCall) {
       EXPECT_TRUE(inst_sp->IsCall());
+    }
+
     if (kind == eInstructionControlFlowKindCall ||
         kind == eInstructionControlFlowKindJump ||
         kind == eInstructionControlFlowKindCondJump ||
-        kind == eInstructionControlFlowKindReturn)
+        kind == eInstructionControlFlowKindReturn) {
       EXPECT_TRUE(inst_sp->DoesBranch());
+    }
   }
 }


        


More information about the lldb-commits mailing list