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 | 10e7846abf4e69f03dfb65b36d866c01ece66645 (patch) | |
tree | c237a52fbbd973c3eea4cb769bc38695e7bc23ac /clang/tools/libclang/Indexing.cpp | |
parent | 7768299b98ba4f5b8a4e3f627b521bb8f0e40173 (diff) | |
download | bcm5719-llvm-10e7846abf4e69f03dfb65b36d866c01ece66645.tar.gz bcm5719-llvm-10e7846abf4e69f03dfb65b36d866c01ece66645.zip |
[libclang] When indexing an AST file, only deserialize the file level
declarations of the current primary module.
llvm-svn: 165046
Diffstat (limited to 'clang/tools/libclang/Indexing.cpp')
-rw-r--r-- | clang/tools/libclang/Indexing.cpp | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp index 8c19aeba285..598dbce7b65 100644 --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/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) { |