[llvm] [NFC] Fix dangling-else warning (PR #112817)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 06:01:29 PDT 2024


teresajohnson wrote:

> Given that omit braces in such cases is part of LLVM's style guide

Reference: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

> I wonder whether it may be better to use `-Wno-dangling-else` when compiling gtest based code using GCC?
> 
> As Clang doesn't have this false positive, this warning will creep back in over time.

Agree. But where is the else in this case? I assume it is inside the gtest macros being invoked in the if statement bodies - might be better to add fixes there?

https://github.com/llvm/llvm-project/pull/112817


More information about the llvm-commits mailing list