================
@@ -61,13 +63,33 @@ 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")) {
+    const auto ParenType = TL->getAs<ParenTypeLoc>();
+
+    if (ParenType.isNull())
+      return;
+    const QualType InnerLocType = ParenType.getInnerLoc().getType();
+    if (InnerLocType->isPointerType() || InnerLocType->isReferenceType() ||
+        InnerLocType->isMemberPointerType() || InnerLocType->isFunctionType() 
||
+        InnerLocType->isArrayType())
----------------
zwuis wrote:

Please add tests for each condition.

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