================
@@ -44,7 +44,10 @@ internal::Matcher<Expr> callToGet(const 
internal::Matcher<Decl> &OnClass) {
 }
 
 internal::Matcher<Decl> knownSmartptr() {
-  return recordDecl(hasAnyName("::std::unique_ptr", "::std::shared_ptr"));
+  return recordDecl(
+      hasAnyName("::std::unique_ptr", "::std::shared_ptr"),
+      unless(anyOf(has(cxxMethodDecl(hasName("operator[]"))),
----------------
kadircet wrote:

i can't comment on the unchanged lines, but this will affect non-dereferencing 
uses as well (e.g. `foo.get() == nullptr` or `foo.get() ? X : Y`, ...), i think 
we shouldn't regress those. so can you just change the matchers we feed for 
those 2 specific cases in `registerMatchersForGetArrowStart`?

i think we should just make sure methoddecl requirements in 
`QuacksLikeASmartptr` holds also for `std::{unique,shared}_ptr`, rather than 
looking for absence of `operator[]` (as we're actually not interested in lack 
of `operator[]` but existence of `operator{*,->}`).

https://github.com/llvm/llvm-project/pull/141092
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to