================
@@ -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 ;
+  }
+
+  if (const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("parentheses-decl")) {
+    ParenTypeLoc ParenType = TL->getAs<ParenTypeLoc>();
+
+    if (ParenType.isNull())
+      return;
+
+    diag(ParenType.getLParenLoc(), "redundant parentheses in declaration")
+        << FixItHint::CreateRemoval(ParenType.getLParenLoc())
+        << FixItHint::CreateRemoval(ParenType.getRParenLoc());
+    return;
+  }
+
----------------
EugeneZelenko wrote:

```suggestion
```

https://github.com/llvm/llvm-project/pull/196739
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to