[PATCH] D91495: [clang-tidy] false-positive for bugprone-redundant-branch-condition in case of passed-by-ref params
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 17 13:07:06 PST 2020
aaron.ballman added a comment.
Thank you for working on this!
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:10
+bool tryToExtinguish(bool&);
+bool tryToExtinguishByVal(bool &);
void tryPutFireOut();
----------------
Did you mean for the parameter to be a reference?
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:963
+ if (tryToExtinguishByVal(isSet) && isSet) {
+ if (tryToExtinguishByVal(isSet) && isSet) {
+ // NO-MESSAGE: fire may have been extinguished
----------------
FWIW, I would expect this one to be diagnosed if the call really was byval instead of byref.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:968
+ }
+}
+
----------------
Another test that would be interesting is:
```
if (tryToExtinguish(isSet) && isSet) {
if (tryToExtinguishByVal(isSet) && isSet) { // Dupe check of isSet should be diagnosed
scream();
}
}
if (tryToExtinguishByVal(isSet) && isSet) {
if (tryToExtinguish(isSet) && isSet) { // Ok
scream();
}
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91495/new/
https://reviews.llvm.org/D91495
More information about the cfe-commits
mailing list