[clang-tools-extra] added check for the parentheses declaration (PR #196739)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 9 11:50:47 PDT 2026
================
@@ -61,13 +62,31 @@ void RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
hasParent(unaryExprOrTypeTraitExpr()))))
.bind("dup"),
this);
+
+ Finder->addMatcher(typeLoc(loc(parenType())).bind("parentheses-decl"), this);
}
void RedundantParenthesesCheck::check(const MatchFinder::MatchResult &Result) {
- const auto *PE = Result.Nodes.getNodeAs<ParenExpr>("dup");
- diag(PE->getBeginLoc(), "redundant parentheses around expression")
- << FixItHint::CreateRemoval(PE->getLParen())
- << FixItHint::CreateRemoval(PE->getRParen());
+ if (const auto *PE = Result.Nodes.getNodeAs<ParenExpr>("dup")) {
+
+ diag(PE->getBeginLoc(), "redundant parentheses around expression")
+ << FixItHint::CreateRemoval(PE->getLParen())
+ << FixItHint::CreateRemoval(PE->getRParen());
+ return ;
----------------
EugeneZelenko wrote:
Please run Clang-Format.
https://github.com/llvm/llvm-project/pull/196739
More information about the cfe-commits
mailing list