Index: include/clang/Sema/Lookup.h =================================================================== --- include/clang/Sema/Lookup.h +++ include/clang/Sema/Lookup.h @@ -784,6 +784,11 @@ /// class of the context we searched. virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass) = 0; + + /// \brief Callback to inform the client that Sema begins to visit a context. + // + /// \param Ctx the context which Sema begins to visit. + virtual void BeginVisitContext(DeclContext *Ctx) {}; }; /// \brief A class for storing results from argument-dependent lookup. Index: lib/Sema/SemaLookup.cpp =================================================================== --- lib/Sema/SemaLookup.cpp +++ lib/Sema/SemaLookup.cpp @@ -3507,6 +3507,8 @@ if (Visited.visitedContext(Ctx->getPrimaryContext())) return; + Consumer.BeginVisitContext(Ctx); + // Outside C++, lookup results for the TU live on identifiers. if (isa(Ctx) && !Result.getSema().getLangOpts().CPlusPlus) {