[clang] Add ``ignoringParenImpCasts`` in arguments of hasArgument (PR #89553)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 21 14:59:03 PDT 2024
https://github.com/komalverma04 created https://github.com/llvm/llvm-project/pull/89553
# Maintaining Consistency in `hasAnyArgument()` and `hasArgument()` Matchers in Clang AST Matchers
The correct behavior is to not ignore implicit AST nodes in hasArgument. We have the TK_IgnoreUnlessSpelledInSource traversal kind for when the user wants to silently skip implicit nodes.
The code changes made are as follows:
```diff
- return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
+ return InnerMatcher.matches(*Arg, Finder, Builder);
```
Fixes #75754
>From 4a56db71e8bf2b6414cd305515d9d4434be8efc0 Mon Sep 17 00:00:00 2001
From: komalverma04 <komal148btit21 at igdtuw.ac.in>
Date: Mon, 22 Apr 2024 02:37:25 +0530
Subject: [PATCH] remove IgnoreParenImpCasts() from hasArgument matcher
---
clang/include/clang/ASTMatchers/ASTMatchers.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 8a2bbfff9e9e6b..f900ad42e3efb7 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4560,7 +4560,7 @@ AST_POLYMORPHIC_MATCHER_P2(hasArgument,
const Expr *Arg = Node.getArg(N);
if (Finder->isTraversalIgnoringImplicitNodes() && isa<CXXDefaultArgExpr>(Arg))
return false;
- return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
+ return InnerMatcher.matches(*Arg->ignoringParenImpCasts(), Finder, Builder);
}
/// Matches the operand that does not contain the parameter pack.
More information about the cfe-commits
mailing list