================ @@ -1238,27 +1413,36 @@ class SpanTwoParamConstructorGadget : public WarningGadget { const CXXConstructExpr *Ctor; // the span constructor expression public: - SpanTwoParamConstructorGadget(const MatchFinder::MatchResult &Result) + SpanTwoParamConstructorGadget(const MatchResult &Result) : WarningGadget(Kind::SpanTwoParamConstructor), - Ctor(Result.Nodes.getNodeAs<CXXConstructExpr>( - SpanTwoParamConstructorTag)) {} + Ctor(Result.getNodeAs<CXXConstructExpr>(SpanTwoParamConstructorTag)) {} static bool classof(const Gadget *G) { return G->getKind() == Kind::SpanTwoParamConstructor; } - static Matcher matcher() { - auto HasTwoParamSpanCtorDecl = hasDeclaration( - cxxConstructorDecl(hasDeclContext(isInStdNamespace()), hasName("span"), - parameterCountIs(2))); - - return stmt(cxxConstructExpr(HasTwoParamSpanCtorDecl, - unless(isSafeSpanTwoParamConstruct())) - .bind(SpanTwoParamConstructorTag)); + static bool matches(const Stmt *S, const ASTContext &Ctx, + MatchResult &Result) { + const auto *CE = dyn_cast<CXXConstructExpr>(S); + if (!CE) + return false; + const auto *CDecl = CE->getConstructor(); + const auto *DCtx = CDecl->getDeclContext(); ---------------- ilya-biryukov wrote:
NIT: Use `getParent()` instead, it will return a `CXXRecordDecl`, will allow to avoid the cast below and is generally more readable. 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