Author: Chuanqi Xu Date: 2025-07-30T11:10:39+08:00 New Revision: 8f09b03aebb71c154f3bbe725c29e3f47d37c26e
URL: https://github.com/llvm/llvm-project/commit/8f09b03aebb71c154f3bbe725c29e3f47d37c26e DIFF: https://github.com/llvm/llvm-project/commit/8f09b03aebb71c154f3bbe725c29e3f47d37c26e.diff LOG: [NFC] [Sema] [Modules] Use DynamicRecursiveASTVisitor to reduce generted code size (#151074) It is better to use DynamicRecursiveASTVisitor than RecursiveASTVisitor as it can reduce the generated size. And also avoid using a template type to present callbacks to avoid generating more code too. Added: Modified: clang/lib/Sema/SemaModule.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index 98ebd707aae2e..b137549b8f859 100644 --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -13,7 +13,7 @@ #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTMutationListener.h" -#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/AST/DynamicRecursiveASTVisitor.h" #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/Preprocessor.h" #include "clang/Sema/ParsedAttr.h" @@ -1422,14 +1422,14 @@ bool ExposureChecker::checkExposure(const CXXRecordDecl *RD, bool Diag) { return IsExposure; } -template <typename CallbackTy> -class ReferenceTULocalChecker - : public clang::RecursiveASTVisitor<ReferenceTULocalChecker<CallbackTy>> { +class ReferenceTULocalChecker : public DynamicRecursiveASTVisitor { public: + using CallbackTy = std::function<void(DeclRefExpr *, ValueDecl *)>; + ReferenceTULocalChecker(ExposureChecker &C, CallbackTy &&Callback) : Checker(C), Callback(std::move(Callback)) {} - bool VisitDeclRefExpr(DeclRefExpr *DRE) { + bool VisitDeclRefExpr(DeclRefExpr *DRE) override { ValueDecl *Referenced = DRE->getDecl(); if (!Referenced) return true; @@ -1468,10 +1468,6 @@ class ReferenceTULocalChecker CallbackTy Callback; }; -template <typename CallbackTy> -ReferenceTULocalChecker(ExposureChecker &, CallbackTy &&) - -> ReferenceTULocalChecker<CallbackTy>; - bool ExposureChecker::checkExposure(const Stmt *S, bool Diag) { if (!S) return false; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits