]> granicus.if.org Git - clang/commitdiff
Instead of having a specific CXTranslationUnit_* option flag for
authorDouglas Gregor <dgregor@apple.com>
Mon, 9 Aug 2010 22:28:58 +0000 (22:28 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 9 Aug 2010 22:28:58 +0000 (22:28 +0000)
"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

include/clang-c/Index.h
lib/AST/AttrImpl.cpp
tools/c-index-test/c-index-test.c
tools/libclang/CIndex.cpp
tools/libclang/libclang.darwin.exports
tools/libclang/libclang.exports

index 08850373214792a5be6b58c7537ffe89f0ae69b6..ff1f89c17fc700931dc4df478d6896f2c3345620 100644 (file)
@@ -661,16 +661,17 @@ enum CXTranslationUnit_Flags {
   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,21 +687,23 @@ enum CXTranslationUnit_Flags {
    * 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.
index d9c0b5af437473a6f5e0bdb284ae2ea4f372852e..d4d6bfe06634807bbf5f2964b08fb781b5284525 100644 (file)
@@ -130,6 +130,7 @@ DEF_SIMPLE_ATTR_CLONE(VecReturn)
 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)
 
index c3ef7942352657237f67608574999b743975a259..be5084b7b6979b4d2d55ea53fe2d440a66b8a4d9 100644 (file)
@@ -33,7 +33,7 @@ static unsigned getDefaultParsingOptions() {
   unsigned options = CXTranslationUnit_DetailedPreprocessingRecord;
 
   if (getenv("CINDEXTEST_EDITING"))
-    options |= CXTranslationUnit_Editing;
+    options |= clang_defaultEditingTranslationUnitOptions();
   
   return options;
 }
index 344960f813c70ffda68e3ba3fbed65f4d4a78f3c..e8d2cad84973dde5c2549e561012fbe446d90f03 100644 (file)
@@ -1169,6 +1169,10 @@ CXTranslationUnit clang_createTranslationUnit(CXIndex CIdx,
                                   0, 0, true);
 }
 
+unsigned clang_defaultEditingTranslationUnitOptions() {
+  return CXTranslationUnit_PrecompiledPreamble;
+}
+  
 CXTranslationUnit
 clang_createTranslationUnitFromSourceFile(CXIndex CIdx,
                                           const char *source_filename,
@@ -1194,9 +1198,6 @@ CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
 
   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);
index 8ebdf9916e266dfab2e4986f8ef653c7552712ba..a53595b7cbb355e6da7563bd35c3962a2985d47c 100644 (file)
@@ -14,6 +14,7 @@ _clang_createIndex
 _clang_createTranslationUnit
 _clang_createTranslationUnitFromSourceFile
 _clang_defaultCodeCompleteOptions
+_clang_defaultEditingTranslationUnitOptions
 _clang_defaultDiagnosticDisplayOptions
 _clang_disposeCodeCompleteResults
 _clang_disposeDiagnostic
index 793b04280810092e947d6df323fc0609593e5d0a..70aad533155b5da899cb25835bc1e525e86fedc9 100644 (file)
@@ -14,6 +14,7 @@ clang_createIndex
 clang_createTranslationUnit
 clang_createTranslationUnitFromSourceFile
 clang_defaultCodeCompleteOptions
+clang_defaultEditingTranslationUnitOptions
 clang_defaultDiagnosticDisplayOptions
 clang_disposeCodeCompleteResults
 clang_disposeDiagnostic