[clang] c8a23ec - [NFC][Driver] Fix -Wdangling-else warning

Michael Platings via cfe-commits cfe-commits at lists.llvm.org
Thu May 18 13:19:30 PDT 2023


Author: Michael Platings
Date: 2023-05-18T21:16:56+01:00
New Revision: c8a23ec0cbac460dbbefb6683cdbed49e5472086

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

LOG: [NFC][Driver] Fix -Wdangling-else warning

GCC emits this warning because the EXPECT_STREQ macro contains an
if-else statement:

  warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else]

Added: 
    

Modified: 
    clang/unittests/Driver/DXCModeTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Driver/DXCModeTest.cpp b/clang/unittests/Driver/DXCModeTest.cpp
index c30f3c34a7fea..b3767c042edb2 100644
--- a/clang/unittests/Driver/DXCModeTest.cpp
+++ b/clang/unittests/Driver/DXCModeTest.cpp
@@ -137,8 +137,9 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
     auto *A = TranslatedArgs->getLastArg(
         clang::driver::options::OPT_dxil_validator_version);
     EXPECT_NE(A, nullptr);
-    if (A)
+    if (A) {
       EXPECT_STREQ(A->getValue(), "1.1");
+    }
   }
   EXPECT_EQ(Diags.getNumErrors(), 0u);
 


        


More information about the cfe-commits mailing list