[clang] Add ``ignoringParenImpCasts`` in arguments of hasArgument (PR #89553)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 21 14:59:35 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (komalverma04)
<details>
<summary>Changes</summary>
# 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
---
Full diff: https://github.com/llvm/llvm-project/pull/89553.diff
1 Files Affected:
- (modified) clang/include/clang/ASTMatchers/ASTMatchers.h (+1-1)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/89553
More information about the cfe-commits
mailing list