[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/CIndexCodeCompletion.cpp b/tools/libclang/CIndexCodeCompletion.cpp
index 1b4a7e4..c5bc8c8 100644
--- a/tools/libclang/CIndexCodeCompletion.cpp
+++ b/tools/libclang/CIndexCodeCompletion.cpp
@@ -666,6 +666,10 @@
   if (!AST)
     return;
 
+  CIndexer *CXXIdx = (CIndexer*)TU->CIdx;
+  if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForEditing))
+    setBackGroundPriority();
+
   ASTUnit::ConcurrencyCheck Check(*AST);
 
   // Perform the remapping of source files.