aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-11 15:58:42 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-11 15:58:42 +0000
commite1e13bf568a7e37c95eda6fcfa626659a06e67b1 (patch)
treef66841d4d4f82b76d1e0157f7ea7c179a2480324
parent30216ac9a95096d70a130991e71cc48fb302d268 (diff)
Add a (currently unused) "options" parameter to
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
-rw-r--r--include/clang-c/Index.h47
-rw-r--r--tools/c-index-test/c-index-test.c3
-rw-r--r--tools/libclang/CIndex.cpp7
-rw-r--r--tools/libclang/libclang.darwin.exports1
-rw-r--r--tools/libclang/libclang.exports1
5 files changed, 54 insertions, 5 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index ff1f89c17f..b3141f2dfe 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -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
@@ -760,6 +770,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.
*
* This routine can be used to re-parse the source files that originally
@@ -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);
/**
* @}
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index be5084b7b6..f95829b95a 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -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);
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 34de78ca1c..0f43cf6359 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -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;
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index a53595b7cb..671d376a86 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -16,6 +16,7 @@ _clang_createTranslationUnitFromSourceFile
_clang_defaultCodeCompleteOptions
_clang_defaultEditingTranslationUnitOptions
_clang_defaultDiagnosticDisplayOptions
+_clang_defaultReparseOptions
_clang_disposeCodeCompleteResults
_clang_disposeDiagnostic
_clang_disposeIndex
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index 70aad53315..9b2d0ad469 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -16,6 +16,7 @@ clang_createTranslationUnitFromSourceFile
clang_defaultCodeCompleteOptions
clang_defaultEditingTranslationUnitOptions
clang_defaultDiagnosticDisplayOptions
+clang_defaultReparseOptions
clang_disposeCodeCompleteResults
clang_disposeDiagnostic
clang_disposeIndex