aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/Indexing.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-28 04:56:00 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-28 04:56:00 +0000
commit6f3ce979a7748fd117e6473d6272b16d643b6262 (patch)
treede0942a2ca83386321511f21b544289d0862330f /tools/libclang/Indexing.cpp
parent991bf49f68e8caeb900dd9738712b861073363d9 (diff)
[libclang] Indexing API: If the client requested to get a CXTranslationUnit after
indexing, honor all the TU options. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145229 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/Indexing.cpp')
-rw-r--r--tools/libclang/Indexing.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 5af1d50e72..222e301d46 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -244,9 +244,6 @@ static void clang_indexSourceFile_Impl(void *UserData) {
CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
- (void)CXXIdx;
- (void)TU_options;
-
CaptureDiagnosticConsumer *CaptureDiag = new CaptureDiagnosticConsumer();
// Configure the diagnostics.
@@ -333,9 +330,38 @@ static void clang_indexSourceFile_Impl(void *UserData) {
llvm::CrashRecoveryContextCleanupRegistrar<IndexingFrontendAction>
IndexActionCleanup(IndexAction.get());
+ bool Persistent = requestedToGetTU;
+ StringRef ResourceFilesPath = CXXIdx->getClangResourcesPath();
+ bool OnlyLocalDecls = false;
+ bool CaptureDiagnostics = true;
+ bool PrecompilePreamble = false;
+ bool CacheCodeCompletionResults = false;
+ PreprocessorOptions &PPOpts = CInvok->getPreprocessorOpts();
+ PPOpts.DetailedRecord = false;
+ PPOpts.DetailedRecordIncludesNestedMacroExpansions = false;
+
+ if (requestedToGetTU) {
+ OnlyLocalDecls = CXXIdx->getOnlyLocalDecls();
+ PrecompilePreamble = TU_options & CXTranslationUnit_PrecompiledPreamble;
+ // FIXME: Add a flag for modules.
+ CacheCodeCompletionResults
+ = TU_options & CXTranslationUnit_CacheCompletionResults;
+ if (TU_options & CXTranslationUnit_DetailedPreprocessingRecord) {
+ PPOpts.DetailedRecord = true;
+ PPOpts.DetailedRecordIncludesNestedMacroExpansions
+ = (TU_options & CXTranslationUnit_NestedMacroExpansions);
+ }
+ }
+
Unit = ASTUnit::LoadFromCompilerInvocationAction(CInvok.getPtr(), Diags,
IndexAction.get(),
- Unit);
+ Unit,
+ Persistent,
+ ResourceFilesPath,
+ OnlyLocalDecls,
+ CaptureDiagnostics,
+ PrecompilePreamble,
+ CacheCodeCompletionResults);
if (!Unit)
return;