Skip to content

Commit 4fa9fe6

Browse files
Perdixkyclaude
andcommitted
refactor(semantic): remove redundant AST traversal filters
RecursiveASTVisitor already skips implicit decls and implicit template instantiations by default via shouldVisitImplicitCode() and shouldVisitTemplateInstantiations(). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d42d9d5 commit 4fa9fe6

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/semantic/filtered_ast_visitor.h

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class FilteredASTVisitor : public clang::RecursiveASTVisitor<Derived> {
3333
return true;
3434
}
3535

36+
/// Clang doesn't visit implicit declarations and
37+
/// implicit template instantiations by default.
3638
if(llvm::isa<clang::TranslationUnitDecl>(decl)) {
3739
if(interested_only) {
3840
for(auto top: unit.top_level_decls()) {
@@ -46,29 +48,6 @@ class FilteredASTVisitor : public clang::RecursiveASTVisitor<Derived> {
4648
return Base::TraverseDecl(decl);
4749
}
4850

49-
if(decl->isImplicit()) {
50-
return true;
51-
}
52-
53-
/// We don't want to visit implicit instantiation.
54-
if(auto SD = llvm::dyn_cast<clang::ClassTemplateSpecializationDecl>(decl)) {
55-
if(SD->getSpecializationKind() == clang::TSK_ImplicitInstantiation) {
56-
return true;
57-
}
58-
}
59-
60-
if(auto SD = llvm::dyn_cast<clang::FunctionDecl>(decl)) {
61-
if(SD->getTemplateSpecializationKind() == clang::TSK_ImplicitInstantiation) {
62-
return true;
63-
}
64-
}
65-
66-
if(auto SD = llvm::dyn_cast<clang::VarTemplateSpecializationDecl>(decl)) {
67-
if(SD->getSpecializationKind() == clang::TSK_ImplicitInstantiation) {
68-
return true;
69-
}
70-
}
71-
7251
if constexpr(requires { getDerived().on_traverse_decl(decl, &Base::TraverseDecl); }) {
7352
return getDerived().on_traverse_decl(decl, &Base::TraverseDecl);
7453
} else {

0 commit comments

Comments
 (0)