[cfe-commits] r110613 - in /cfe/trunk: 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

Douglas Gregor dgregor at apple.com
Mon Aug 9 15:28:58 PDT 2010


Author: dgregor
Date: Mon Aug  9 17:28:58 2010
New Revision: 110613

URL: http://llvm.org/viewvc/llvm-project?rev=110613&view=rev
Log:
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.

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

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=110613&r1=110612&r2=110613&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Aug  9 17:28:58 2010
@@ -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.
  *

Modified: cfe/trunk/lib/AST/AttrImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/AttrImpl.cpp?rev=110613&r1=110612&r2=110613&view=diff
==============================================================================
--- cfe/trunk/lib/AST/AttrImpl.cpp (original)
+++ cfe/trunk/lib/AST/AttrImpl.cpp Mon Aug  9 17:28:58 2010
@@ -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)
 

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=110613&r1=110612&r2=110613&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Mon Aug  9 17:28:58 2010
@@ -33,7 +33,7 @@
   unsigned options = CXTranslationUnit_DetailedPreprocessingRecord;
 
   if (getenv("CINDEXTEST_EDITING"))
-    options |= CXTranslationUnit_Editing;
+    options |= clang_defaultEditingTranslationUnitOptions();
   
   return options;
 }

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=110613&r1=110612&r2=110613&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Aug  9 17:28:58 2010
@@ -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);

Modified: cfe/trunk/tools/libclang/libclang.darwin.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.darwin.exports?rev=110613&r1=110612&r2=110613&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.darwin.exports (original)
+++ cfe/trunk/tools/libclang/libclang.darwin.exports Mon Aug  9 17:28:58 2010
@@ -14,6 +14,7 @@
 _clang_createTranslationUnit
 _clang_createTranslationUnitFromSourceFile
 _clang_defaultCodeCompleteOptions
+_clang_defaultEditingTranslationUnitOptions
 _clang_defaultDiagnosticDisplayOptions
 _clang_disposeCodeCompleteResults
 _clang_disposeDiagnostic

Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=110613&r1=110612&r2=110613&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Mon Aug  9 17:28:58 2010
@@ -14,6 +14,7 @@
 clang_createTranslationUnit
 clang_createTranslationUnitFromSourceFile
 clang_defaultCodeCompleteOptions
+clang_defaultEditingTranslationUnitOptions
 clang_defaultDiagnosticDisplayOptions
 clang_disposeCodeCompleteResults
 clang_disposeDiagnostic





More information about the cfe-commits mailing list