The clang-tidy check bugprone-branch-clone has a false positive if some symbols are undefined. This patch silences the warning when the two sides of a branch are invalid.
See //github.com/llvm/llvm-project/issues/56057 for the original issue.
Differential D128402
[clang-tidy] Don't treat invalid branches as identical ishaangandhi on Jun 22 2022, 5:16 PM. Authored by
Details The clang-tidy check bugprone-branch-clone has a false positive if some symbols are undefined. This patch silences the warning when the two sides of a branch are invalid. See //github.com/llvm/llvm-project/issues/56057 for the original issue.
Diff Detail
Event Timeline
Comment Actions OK, I've pushed the link fix and the sorting fix to main so if you rebase again, it should just show your changes to the release notes. Comment Actions @LegalizeAdulthood Thanks! I don't have commit rights to the repository, can you commit it on my behalf? Comment Actions Does anybody on this thread have land permissions? If not, would anyone know who to tag?
Comment Actions I remember now, @njames93 : Without the -fix-errors, the test fails as follows: Command Output (stdout): -- Running ['clang-tidy', '/var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/branch-clone-unknown-expr.cpp.tmp.cpp', '-fix', '--checks=-*,bugprone-branch-clone', '-config={}', '--', '-std=c++11', '-nostdinc++']... clang-tidy /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/branch-clone-unknown-expr.cpp.tmp.cpp -fix --checks=-*,bugprone-branch-clone -config={} -- -std=c++11 -nostdinc++ failed: 3 errors generated. Error while processing /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/branch-clone-unknown-expr.cpp.tmp.cpp. /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/branch-clone-unknown-expr.cpp.tmp.cpp:4:7: error: use of undeclared identifier 'unknown_expression_1' [clang-diagnostic-error] if (unknown_expression_1) { // ^ /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/branch-clone-unknown-expr.cpp.tmp.cpp:5:15: error: use of undeclared identifier 'unknown_expression_2' [clang-diagnostic-error] function1(unknown_expression_2); // ^ /var/lib/buildkite-agent/builds/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/branch-clone-unknown-expr.cpp.tmp.cpp:7:15: error: use of undeclared identifier 'unknown_expression_3' [clang-diagnostic-error] function2(unknown_expression_3); // ^ Found compiler errors, but -fix-errors was not specified. I won't update the diff, since I assume you will want to see the buildkite failure for yourself. Once you see it, can you either confirm -fix-errors was correct originally, or instruct me on how to fix this test failure? Comment Actions -expect-clang-tidy-error is the technically correct flag to use, but I'm easy either way. Comment Actions Please provide the name and email address you wish to use on the commit and I will submit. |
auto could be used because type is spelled in same statement.