aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2025-07-30 11:10:39 +0800
committerGitHub <noreply@github.com>2025-07-30 11:10:39 +0800
commit8f09b03aebb71c154f3bbe725c29e3f47d37c26e (patch)
treef563ace4e738cfc65cfe016198eb864ab8b24f93 /clang/lib/Sema/SemaModule.cpp
parentee1ecf32451ee87705666cfb919879123d388220 (diff)
downloadllvm-8f09b03aebb71c154f3bbe725c29e3f47d37c26e.zip
llvm-8f09b03aebb71c154f3bbe725c29e3f47d37c26e.tar.gz
llvm-8f09b03aebb71c154f3bbe725c29e3f47d37c26e.tar.bz2
[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.
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 98ebd70..b137549 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 @@ public:
CallbackTy Callback;
};
-template <typename CallbackTy>
-ReferenceTULocalChecker(ExposureChecker &, CallbackTy &&)
- -> ReferenceTULocalChecker<CallbackTy>;
-
bool ExposureChecker::checkExposure(const Stmt *S, bool Diag) {
if (!S)
return false;