================
@@ -71,20 +71,20 @@ void
ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
const auto Zero = integerLiteral(equals(0));
- const auto SubscriptOperator = callee(cxxMethodDecl(hasName("operator[]")));
-
- Finder->addMatcher(
+ const auto AddressOfMatcher =
unaryOperator(
unless(isExpansionInSystemHeader()), hasOperatorName("&"),
- hasUnaryOperand(expr(
- anyOf(cxxOperatorCallExpr(SubscriptOperator, argumentCountIs(2),
- hasArgument(0, ContainerExpr),
- hasArgument(1, Zero)),
- cxxMemberCallExpr(SubscriptOperator, on(ContainerExpr),
- argumentCountIs(1), hasArgument(0,
Zero)),
- arraySubscriptExpr(hasLHS(ContainerExpr), hasRHS(Zero))))))
- .bind(AddressOfName),
- this);
+ hasUnaryOperand(ignoringParenImpCasts(expr(anyOf(
+ cxxOperatorCallExpr(
+ hasOverloadedOperatorName("[]"), argumentCountIs(2),
+ hasArgument(0, ContainerExpr), hasArgument(1, Zero)),
+ cxxMemberCallExpr(callee(cxxMethodDecl(hasName("operator[]"))),
+ on(ContainerExpr), argumentCountIs(1),
+ hasArgument(0, Zero)),
+ arraySubscriptExpr(hasLHS(ContainerExpr), hasRHS(Zero)))))))
+ .bind(AddressOfName);
+
+ Finder->addMatcher(traverse(TK_AsIs, AddressOfMatcher), this);
----------------
zeyi2 wrote:
Hi, I'm not quite sure whether I understood you completely. I've reverted to
the commit before the new testcase was added. Please let me know if I do it
wrong and I'll fix it quickly. Thanks.
https://github.com/llvm/llvm-project/pull/165636
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits