]> granicus.if.org Git - clang/commitdiff
Add a (currently unused) "options" parameter to
authorDouglas Gregor <dgregor@apple.com>
Wed, 11 Aug 2010 15:58:42 +0000 (15:58 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 11 Aug 2010 15:58:42 +0000 (15:58 +0000)
clang_reparseTranslationUnit(), along with a function to retrieve the
default recommended reparsing options for a translation unit.

Also, add the CXTranslationUnit_CacheCompletionResults flag, which is
also currently unused.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110811 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ff1f89c17fc700931dc4df478d6896f2c3345620..b3141f2dfe97f807fea738631fd8cf869e68bd84 100644 (file)
@@ -687,7 +687,17 @@ enum CXTranslationUnit_Flags {
    * clang_reparseTranslationUnit() will re-use the implicit
    * precompiled header to improve parsing performance.
    */
-  CXTranslationUnit_PrecompiledPreamble = 0x04
+  CXTranslationUnit_PrecompiledPreamble = 0x04,
+  
+  /**
+   * \brief Used to indicate that the translation unit should cache some
+   * code-completion results with each reparse of the source file.
+   *
+   * Caching of code-completion results is a performance optimization that
+   * introduces some overhead to reparsing but improves the performance of
+   * code-completion operations.
+   */
+  CXTranslationUnit_CacheCompletionResults = 0x08
 };
 
 /**
@@ -702,7 +712,7 @@ enum CXTranslationUnit_Flags {
  * 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();
+CINDEX_LINKAGE unsigned clang_defaultEditingTranslationUnitOptions(void);
   
 /**
  * \brief Parse the given source file and the translation unit corresponding
@@ -759,6 +769,32 @@ CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx,
  */
 CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
 
+/**
+ * \brief Flags that control the reparsing of translation units.
+ *
+ * The enumerators in this enumeration type are meant to be bitwise
+ * ORed together to specify which options should be used when
+ * reparsing the translation unit.
+ */
+enum CXReparse_Flags {
+  /**
+   * \brief Used to indicate that no special reparsing options are needed.
+   */
+  CXReparse_None = 0x0
+};
+/**
+ * \brief Returns the set of flags that is suitable for reparsing a translation
+ * unit.
+ *
+ * The set of flags returned provide options for
+ * \c clang_reparseTranslationUnit() by default. The returned flag
+ * set contains an unspecified set of optimizations geared toward common uses
+ * of reparsing. The set of optimizations enabled may change from one version 
+ * to the next.
+ */
+CINDEX_LINKAGE unsigned clang_defaultReparseOptions(CXTranslationUnit TU);
+
 /**
  * \brief Reparse the source files that produced this translation unit.
  *
@@ -788,6 +824,10 @@ CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
  * CXUnsavedFile) are copied when necessary, so the client only needs to
  * guarantee their validity until the call to this function returns.
  * 
+ * \param options A bitset of options composed of the flags in CXReparse_Flags.
+ * The function \c clang_defaultReparseOptions() produces a default set of
+ * options recommended for most uses, based on the translation unit.
+ *
  * \returns 0 if the sources could be reparsed. A non-zero value will be
  * returned if reparsing was impossible, such that the translation unit is
  * invalid. In such cases, the only valid call for \p TU is 
@@ -795,7 +835,8 @@ CINDEX_LINKAGE void clang_disposeTranslationUnit(CXTranslationUnit);
  */
 CINDEX_LINKAGE int clang_reparseTranslationUnit(CXTranslationUnit TU,
                                                 unsigned num_unsaved_files,
-                                          struct CXUnsavedFile *unsaved_files);
+                                          struct CXUnsavedFile *unsaved_files,
+                                                unsigned options);
   
 /**
  * @}
index be5084b7b6979b4d2d55ea53fe2d440a66b8a4d9..f95829b95ac06ee7ff0151748317958e50923a3a 100644 (file)
@@ -639,7 +639,8 @@ int perform_test_reparse_source(int argc, const char **argv, int trials,
   }
   
   for (trial = 0; trial < trials; ++trial) {
-    if (clang_reparseTranslationUnit(TU, num_unsaved_files, unsaved_files)) {
+    if (clang_reparseTranslationUnit(TU, num_unsaved_files, unsaved_files,
+                                     clang_defaultReparseOptions(TU))) {
       clang_disposeTranslationUnit(TU);
       free_remapped_files(unsaved_files, num_unsaved_files);
       clang_disposeIndex(Idx);
index 34de78ca1cccc3cca5f8edcb3b7ee5230c903364..0f43cf635911ab0ab1e5d432dce49cabef43529b 100644 (file)
@@ -1459,9 +1459,14 @@ void clang_disposeTranslationUnit(CXTranslationUnit CTUnit) {
     delete static_cast<ASTUnit *>(CTUnit);
 }
 
+unsigned clang_defaultReparseOptions(CXTranslationUnit TU) {
+  return CXReparse_None;
+}
+
 int clang_reparseTranslationUnit(CXTranslationUnit TU,
                                  unsigned num_unsaved_files,
-                                 struct CXUnsavedFile *unsaved_files) {
+                                 struct CXUnsavedFile *unsaved_files,
+                                 unsigned options) {
   if (!TU)
     return 1;
   
index a53595b7cbb355e6da7563bd35c3962a2985d47c..671d376a86e30f36f9f759a3fd7587628d7c0154 100644 (file)
@@ -16,6 +16,7 @@ _clang_createTranslationUnitFromSourceFile
 _clang_defaultCodeCompleteOptions
 _clang_defaultEditingTranslationUnitOptions
 _clang_defaultDiagnosticDisplayOptions
+_clang_defaultReparseOptions
 _clang_disposeCodeCompleteResults
 _clang_disposeDiagnostic
 _clang_disposeIndex
index 70aad533155b5da899cb25835bc1e525e86fedc9..9b2d0ad4694162e1066efe20302d7ee65eba2c6c 100644 (file)
@@ -16,6 +16,7 @@ clang_createTranslationUnitFromSourceFile
 clang_defaultCodeCompleteOptions
 clang_defaultEditingTranslationUnitOptions
 clang_defaultDiagnosticDisplayOptions
+clang_defaultReparseOptions
 clang_disposeCodeCompleteResults
 clang_disposeDiagnostic
 clang_disposeIndex