diff options
author | FĂ©lix-Antoine Constantin <60141446+felix642@users.noreply.github.com> | 2023-11-14 17:32:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-14 23:32:58 +0100 |
commit | 2602d888d99ddcffa55dc55099b9a4dec6fdb97e (patch) | |
tree | 9524d6d7206990a44283f4e8294cee9484e1ec97 /clang-tools-extra/test/clang-tidy/checkers/readability | |
parent | 2aec86683c074a19b9c4d42d0b2b33d4f999ba00 (diff) | |
download | llvm-2602d888d99ddcffa55dc55099b9a4dec6fdb97e.zip llvm-2602d888d99ddcffa55dc55099b9a4dec6fdb97e.tar.gz llvm-2602d888d99ddcffa55dc55099b9a4dec6fdb97e.tar.bz2 |
[clang-tidy] Improved readability-bool-conversion to be more consistent when using parentheses (#72068)
Provides more consistent suggestions when parentheses are added to the return value.
Fixes #71852
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/readability')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp index 323cf813..f7f5d50 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp @@ -472,6 +472,36 @@ bool f(S& s) { } // namespace ignore_1bit_bitfields +int implicitConversionReturnInt() +{ + return true; + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion bool -> 'int' + // CHECK-FIXES: return 1 +} + +int implicitConversionReturnIntWithParens() +{ + return (true); + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion bool -> 'int' + // CHECK-FIXES: return 1 +} + + +bool implicitConversionReturnBool() +{ + return 1; + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> bool + // CHECK-FIXES: return true +} + +bool implicitConversionReturnBoolWithParens() +{ + return (1); + // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> bool + // CHECK-FIXES: return true +} + + namespace PR47000 { int to_int(bool x) { return int{x}; } |