Instead of having a specific CXTranslationUnit_* option flag for
"editing" mode, introduce a separate function
clang_defaultEditingTranslationUnitOptions() that retrieves the set of
options. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110613 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 0885037..ff1f89c 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -661,16 +661,17 @@
   CXTranslationUnit_DetailedPreprocessingRecord = 0x01,
 
   /**
-   * \brief A flag that indicates that the intent of parsing the
-   * given translation unit is for live editing of the file.
+   * \brief Used to indicate that the translation unit is incomplete.
    *
-   * This flag is essentially a meta-flag that callers can use to indicate
-   * that the translation unit is being edited and, therefore, is likely to
-   * be reparsed many times. It enables an unspecified set of optimizations
-   * (e.g., the precompiled preamble) geared toward improving the performance
-   * of \c clang_reparseTranslationUnit().
+   * When a translation unit is considered "incomplete", semantic
+   * analysis that is typically performed at the end of the
+   * translation unit will be suppressed. For example, this suppresses
+   * the completion of tentative declarations in C and of
+   * instantiation of implicitly-instantiation function templates in
+   * C++. This option is typically used when parsing a header with the
+   * intent of producing a precompiled header.
    */
-  CXTranslationUnit_Editing = 0x02,
+  CXTranslationUnit_Incomplete = 0x02,
   
   /**
    * \brief Used to indicate that the translation unit should be built with an 
@@ -686,22 +687,24 @@
    * clang_reparseTranslationUnit() will re-use the implicit
    * precompiled header to improve parsing performance.
    */
-  CXTranslationUnit_PrecompiledPreamble = 0x04,
-  /**
-   * \brief Used to indicate that the translation unit is incomplete.
-   *
-   * When a translation unit is considered "incomplete", semantic
-   * analysis that is typically performed at the end of the
-   * translation unit will be suppressed. For example, this suppresses
-   * the completion of tentative declarations in C and of
-   * instantiation of implicitly-instantiation function templates in
-   * C++. This option is typically used when parsing a header with the
-   * intent of producing a precompiled header.
-   */
-  CXTranslationUnit_Incomplete = 0x08
+  CXTranslationUnit_PrecompiledPreamble = 0x04
 };
 
 /**
+ * \brief Returns the set of flags that is suitable for parsing a translation
+ * unit that is being edited.
+ *
+ * The set of flags returned provide options for \c clang_parseTranslationUnit()
+ * to indicate that the translation unit is likely to be reparsed many times,
+ * either explicitly (via \c clang_reparseTranslationUnit()) or implicitly
+ * (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag
+ * set contains an unspecified set of optimizations (e.g., the precompiled 
+ * preamble) geared toward improving the performance of these routines. The
+ * set of optimizations enabled may change from one version to the next.
+ */
+CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions();
+  
+/**
  * \brief Parse the given source file and the translation unit corresponding
  * to that file.
  *
diff --git a/lib/AST/AttrImpl.cpp b/lib/AST/AttrImpl.cpp
index d9c0b5a..d4d6bfe 100644
--- a/lib/AST/AttrImpl.cpp
+++ b/lib/AST/AttrImpl.cpp
@@ -130,6 +130,7 @@
 DEF_SIMPLE_ATTR_CLONE(WarnUnusedResult)
 DEF_SIMPLE_ATTR_CLONE(Weak)
 DEF_SIMPLE_ATTR_CLONE(WeakImport)
+
 DEF_SIMPLE_ATTR_CLONE(WeakRef)
 DEF_SIMPLE_ATTR_CLONE(X86ForceAlignArgPointer)
 
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index c3ef794..be5084b 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -33,7 +33,7 @@
   unsigned options = CXTranslationUnit_DetailedPreprocessingRecord;
 
   if (getenv("CINDEXTEST_EDITING"))
-    options |= CXTranslationUnit_Editing;
+    options |= clang_defaultEditingTranslationUnitOptions();
   
   return options;
 }
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 344960f8..e8d2cad 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1169,6 +1169,10 @@
                                   0, 0, true);
 }
 
+unsigned clang_defaultEditingTranslationUnitOptions() {
+  return CXTranslationUnit_PrecompiledPreamble;
+}
+  
 CXTranslationUnit
 clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
                                           const char *source_filename,
@@ -1194,9 +1198,6 @@
 
   CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
 
-  // The "editing" option implies other options.
-  if (options & CXTranslationUnit_Editing)
-    options |= CXTranslationUnit_PrecompiledPreamble;
   bool PrecompilePreamble = options & CXTranslationUnit_PrecompiledPreamble;
   bool CompleteTranslationUnit
     = ((options & CXTranslationUnit_Incomplete) == 0);
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index 8ebdf99..a53595b 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -14,6 +14,7 @@
 _clang_createTranslationUnit
 _clang_createTranslationUnitFromSourceFile
 _clang_defaultCodeCompleteOptions
+_clang_defaultEditingTranslationUnitOptions
 _clang_defaultDiagnosticDisplayOptions
 _clang_disposeCodeCompleteResults
 _clang_disposeDiagnostic
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index 793b042..70aad53 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -14,6 +14,7 @@
 clang_createTranslationUnit
 clang_createTranslationUnitFromSourceFile
 clang_defaultCodeCompleteOptions
+clang_defaultEditingTranslationUnitOptions
 clang_defaultDiagnosticDisplayOptions
 clang_disposeCodeCompleteResults
 clang_disposeDiagnostic