================ @@ -79,21 +81,39 @@ static std::string getDREAncestorString(const DeclRefExpr *DRE, } // namespace #endif /* NDEBUG */ -namespace clang::ast_matchers { +class CustomMatcher { +public: + virtual bool matches(const DynTypedNode &DynNode, ASTContext &Ctx, + const UnsafeBufferUsageHandler &Handler) = 0; + virtual ~CustomMatcher() = default; +}; + +struct MatchResult { +public: + std::map<std::string, DynTypedNode> + Nodes; // DynTypedNode needed to store different types of Nodes, not + // necessarily sharing the same base. + + template <typename T> const T *getNodeAs(StringRef ID) const { + auto It = Nodes.find(std::string(ID)); + if (It == Nodes.end()) { + return nullptr; + } + return It->second.get<T>(); + } +}; + // A `RecursiveASTVisitor` that traverses all descendants of a given node "n" // except for those belonging to a different callable of "n". class MatchDescendantVisitor : public DynamicRecursiveASTVisitor { public: // Creates an AST visitor that matches `Matcher` on all // descendants of a given node "n" except for the ones // belonging to a different callable of "n". - MatchDescendantVisitor(const internal::DynTypedMatcher *Matcher, - internal::ASTMatchFinder *Finder, - internal::BoundNodesTreeBuilder *Builder, - internal::ASTMatchFinder::BindKind Bind, + MatchDescendantVisitor(CustomMatcher &Matcher, bool BindAll, const bool ignoreUnevaluatedContext) - : Matcher(Matcher), Finder(Finder), Builder(Builder), Bind(Bind), - Matches(false), ignoreUnevaluatedContext(ignoreUnevaluatedContext) { + : Matcher(&Matcher), BindAll(BindAll), Matches(false), ---------------- ivanaivanovska wrote:
Changed to FindAll. https://github.com/llvm/llvm-project/pull/124554 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits