[clang-tools-extra] [clang-tidy][readability-redundant-parentheses] add option to prevent widely used work around (PR #164827)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 25 06:35:04 PDT 2025


================
@@ -47,6 +60,15 @@ void RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
 
 void RedundantParenthesesCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *PE = Result.Nodes.getNodeAs<ParenExpr>("dup");
+  if (auto *DRE = dyn_cast<DeclRefExpr>(PE->getSubExpr())) {
+    const std::string Name = DRE->getDecl()->getQualifiedNameAsString();
+    llvm::errs() << Name << "\n";
+    bool Allowed = llvm::any_of(AllowedDecls, [&Name](const llvm::Regex &NM) {
----------------
vbvictor wrote:

There is also effort to explicitly state that options accept regexes: https://github.com/llvm/llvm-project/pull/161142, I think we should continue to pursue this goal and write that option _can be_ regex

https://github.com/llvm/llvm-project/pull/164827


More information about the cfe-commits mailing list