[libclang] Introduce options to control the priority for the threads
that libclang creates.
-Introduce CXGlobalOptFlags enum for the new options that can be
set on the CXIndex object.
-CXGlobalOpt_ThreadBackgroundPriorityForIndexing affects:
clang_indexSourceFile
clang_indexTranslationUnit
clang_parseTranslationUnit
clang_saveTranslationUnit
-CXGlobalOpt_ThreadBackgroundPriorityForEditing affects:
clang_reparseTranslationUnit
clang_codeCompleteAt
clang_annotateTokens
rdar://9075282
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153562 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp
index 85b6385..905569d 100644
--- a/tools/libclang/Indexing.cpp
+++ b/tools/libclang/Indexing.cpp
@@ -275,6 +275,9 @@
CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
+ if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForIndexing))
+ setBackGroundPriority();
+
CaptureDiagnosticConsumer *CaptureDiag = new CaptureDiagnosticConsumer();
// Configure the diagnostics.
@@ -351,7 +354,7 @@
ASTUnit *Unit = ASTUnit::create(CInvok.getPtr(), Diags,
/*CaptureDiagnostics=*/true);
- OwningPtr<CXTUOwner> CXTU(new CXTUOwner(MakeCXTranslationUnit(Unit)));
+ OwningPtr<CXTUOwner> CXTU(new CXTUOwner(MakeCXTranslationUnit(CXXIdx, Unit)));
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<CXTUOwner>
@@ -502,6 +505,10 @@
if (!client_index_callbacks || index_callbacks_size == 0)
return;
+ CIndexer *CXXIdx = (CIndexer*)TU->CIdx;
+ if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForIndexing))
+ setBackGroundPriority();
+
IndexerCallbacks CB;
memset(&CB, 0, sizeof(CB));
unsigned ClientCBSize = index_callbacks_size < sizeof(CB)