================
@@ -1505,23 +1741,51 @@ class DataInvocationGadget : public WarningGadget {
   const ExplicitCastExpr *Op;
 
 public:
-  DataInvocationGadget(const MatchFinder::MatchResult &Result)
+  DataInvocationGadget(const MatchResult &Result)
       : WarningGadget(Kind::DataInvocation),
-        Op(Result.Nodes.getNodeAs<ExplicitCastExpr>(OpTag)) {}
+        Op(Result.getNodeAs<ExplicitCastExpr>(OpTag)) {}
 
   static bool classof(const Gadget *G) {
     return G->getKind() == Kind::DataInvocation;
   }
 
-  static Matcher matcher() {
+  static bool checkCallExpr(const CXXMemberCallExpr *call) {
+    if (!call)
+      return false;
+    auto *callee = call->getDirectCallee();
+    if (!callee || !isa<CXXMethodDecl>(callee))
+      return false;
+    auto *method = cast<CXXMethodDecl>(callee);
+    if (method->getNameAsString() == "data" &&
+        (method->getParent()->getQualifiedNameAsString() == "std::span" ||
----------------
ilya-biryukov wrote:

`getQualifiedNameAsString` is a code smell as it will unnecessarily allocate 
memory for the string output.

This code could easily be rewritten to (meta-code, but get the idea):
```cpp
Parent->IsInStdNamespace() && Parent->Name in {"span", "array", "vector"}
```

Could we do that?

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

Reply via email to