diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-02 21:09:13 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-10-02 21:09:13 +0000 |
commit | 2093e0bc4e436b1b2791d5423fb3274dd37231b8 (patch) | |
tree | f08c54360124813c94b0b2f1d7175307ae20aa53 /tools/libclang/Indexing.cpp | |
parent | ac9289deef6536e47b0da2c6d67d0a74e777b5a2 (diff) |
[libclang] When indexing an AST file, only deserialize the file level
declarations of the current primary module.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165046 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/Indexing.cpp')
-rw-r--r-- | tools/libclang/Indexing.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 8c19aeba28..598dbce7b6 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -472,30 +472,16 @@ static void indexPreprocessingRecord(ASTUnit &Unit, IndexingContext &IdxCtx) { } } -static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) { - // FIXME: Only deserialize stuff from the last chained PCH, not the PCH/Module - // that it depends on. - - bool OnlyLocal = !Unit.isMainFileAST() && Unit.getOnlyLocalDecls(); - - if (OnlyLocal) { - for (ASTUnit::top_level_iterator TL = Unit.top_level_begin(), - TLEnd = Unit.top_level_end(); - TL != TLEnd; ++TL) { - IdxCtx.indexTopLevelDecl(*TL); - if (IdxCtx.shouldAbort()) - return; - } +static bool topLevelDeclReceiver(void *context, const Decl *D) { + IndexingContext &IdxCtx = *static_cast<IndexingContext*>(context); + IdxCtx.indexTopLevelDecl(D); + if (IdxCtx.shouldAbort()) + return false; + return true; +} - } else { - TranslationUnitDecl *TUDecl = Unit.getASTContext().getTranslationUnitDecl(); - for (TranslationUnitDecl::decl_iterator - I = TUDecl->decls_begin(), E = TUDecl->decls_end(); I != E; ++I) { - IdxCtx.indexTopLevelDecl(*I); - if (IdxCtx.shouldAbort()) - return; - } - } +static void indexTranslationUnit(ASTUnit &Unit, IndexingContext &IdxCtx) { + Unit.applyOnLocalTopLevelDecls(&IdxCtx, topLevelDeclReceiver); } static void indexDiagnostics(CXTranslationUnit TU, IndexingContext &IdxCtx) { |