[clang-tools-extra] [clang-tidy] Add new check 'bugprone-inconsistent-ifelse-braces' (PR #162361)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 7 13:08:31 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- clang-tools-extra/clang-tidy/bugprone/InconsistentIfelseBracesCheck.cpp clang-tools-extra/clang-tidy/bugprone/InconsistentIfelseBracesCheck.h clang-tools-extra/test/clang-tidy/checkers/bugprone/inconsistent-ifelse-braces.cpp clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/InconsistentIfelseBracesCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/InconsistentIfelseBracesCheck.cpp
index e0ca5605e..b69546797 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InconsistentIfelseBracesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InconsistentIfelseBracesCheck.cpp
@@ -51,12 +51,12 @@ void InconsistentIfelseBracesCheck::registerMatchers(MatchFinder *Finder) {
this);
}
-void InconsistentIfelseBracesCheck::check(const MatchFinder::MatchResult &Result) {
+void InconsistentIfelseBracesCheck::check(
+ const MatchFinder::MatchResult &Result) {
const auto *MatchedIf = Result.Nodes.getNodeAs<IfStmt>("if_stmt");
if (shouldHaveBraces(MatchedIf) && !doesHaveBraces(MatchedIf)) {
- diag(MatchedIf->getBeginLoc(), "bad!")
- << MatchedIf->getSourceRange();
+ diag(MatchedIf->getBeginLoc(), "bad!") << MatchedIf->getSourceRange();
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/162361
More information about the cfe-commits
mailing list