Skip to content

Commit 8f09b03

Browse files
authored
[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.
1 parent ee1ecf3 commit 8f09b03

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

clang/lib/Sema/SemaModule.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "clang/AST/ASTConsumer.h"
1515
#include "clang/AST/ASTMutationListener.h"
16-
#include "clang/AST/RecursiveASTVisitor.h"
16+
#include "clang/AST/DynamicRecursiveASTVisitor.h"
1717
#include "clang/Lex/HeaderSearch.h"
1818
#include "clang/Lex/Preprocessor.h"
1919
#include "clang/Sema/ParsedAttr.h"
@@ -1422,14 +1422,14 @@ bool ExposureChecker::checkExposure(const CXXRecordDecl *RD, bool Diag) {
14221422
return IsExposure;
14231423
}
14241424

1425-
template <typename CallbackTy>
1426-
class ReferenceTULocalChecker
1427-
: public clang::RecursiveASTVisitor<ReferenceTULocalChecker<CallbackTy>> {
1425+
class ReferenceTULocalChecker : public DynamicRecursiveASTVisitor {
14281426
public:
1427+
using CallbackTy = std::function<void(DeclRefExpr *, ValueDecl *)>;
1428+
14291429
ReferenceTULocalChecker(ExposureChecker &C, CallbackTy &&Callback)
14301430
: Checker(C), Callback(std::move(Callback)) {}
14311431

1432-
bool VisitDeclRefExpr(DeclRefExpr *DRE) {
1432+
bool VisitDeclRefExpr(DeclRefExpr *DRE) override {
14331433
ValueDecl *Referenced = DRE->getDecl();
14341434
if (!Referenced)
14351435
return true;
@@ -1468,10 +1468,6 @@ class ReferenceTULocalChecker
14681468
CallbackTy Callback;
14691469
};
14701470

1471-
template <typename CallbackTy>
1472-
ReferenceTULocalChecker(ExposureChecker &, CallbackTy &&)
1473-
-> ReferenceTULocalChecker<CallbackTy>;
1474-
14751471
bool ExposureChecker::checkExposure(const Stmt *S, bool Diag) {
14761472
if (!S)
14771473
return false;

0 commit comments

Comments
 (0)