diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp index df875e0b40079..0749f5636ccdc 100644 --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -40,10 +40,10 @@ class IndexingDeclVisitor : public ConstDeclVisitor { explicit IndexingDeclVisitor(IndexingContext &indexCtx) : IndexCtx(indexCtx) { } - bool Handled = true; - + // Default handler for declarations not matched by more specific Visit* bool VisitDecl(const Decl *D) { - Handled = false; + if (isa(D)) + return IndexCtx.indexDeclContext(cast(D)); return true; } @@ -784,15 +784,9 @@ bool IndexingContext::indexDecl(const Decl *D) { if (isTemplateImplicitInstantiation(D) && !shouldIndexImplicitInstantiation()) return true; + // Dispatch the Decl by kind to specific Visit* that index the whole subtree. IndexingDeclVisitor Visitor(*this); - bool ShouldContinue = Visitor.Visit(D); - if (!ShouldContinue) - return false; - - if (!Visitor.Handled && isa(D)) - return indexDeclContext(cast(D)); - - return true; + return Visitor.Visit(D); } bool IndexingContext::indexDeclContext(const DeclContext *DC) {