[cfe-commits] r110811 - in /cfe/trunk: 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
Douglas Gregor
dgregor at apple.com
Wed Aug 11 08:58:42 PDT 2010
Author: dgregor
Date: Wed Aug 11 10:58:42 2010
New Revision: 110811
URL: http://llvm.org/viewvc/llvm-project?rev=110811&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang-c/Index.h
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=110811&r1=110810&r2=110811&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Aug 11 10:58:42 2010
@@ -687,7 +687,17 @@
* 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 @@
* 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 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 @@
* 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 int clang_reparseTranslationUnit(CXTranslationUnit TU,
unsigned num_unsaved_files,
- struct CXUnsavedFile *unsaved_files);
+ struct CXUnsavedFile *unsaved_files,
+ unsigned options);
/**
* @}
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=110811&r1=110810&r2=110811&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Aug 11 10:58:42 2010
@@ -639,7 +639,8 @@
}
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);
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=110811&r1=110810&r2=110811&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Aug 11 10:58:42 2010
@@ -1459,9 +1459,14 @@
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;
Modified: cfe/trunk/tools/libclang/libclang.darwin.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.darwin.exports?rev=110811&r1=110810&r2=110811&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.darwin.exports (original)
+++ cfe/trunk/tools/libclang/libclang.darwin.exports Wed Aug 11 10:58:42 2010
@@ -16,6 +16,7 @@
_clang_defaultCodeCompleteOptions
_clang_defaultEditingTranslationUnitOptions
_clang_defaultDiagnosticDisplayOptions
+_clang_defaultReparseOptions
_clang_disposeCodeCompleteResults
_clang_disposeDiagnostic
_clang_disposeIndex
Modified: cfe/trunk/tools/libclang/libclang.exports
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=110811&r1=110810&r2=110811&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Wed Aug 11 10:58:42 2010
@@ -16,6 +16,7 @@
clang_defaultCodeCompleteOptions
clang_defaultEditingTranslationUnitOptions
clang_defaultDiagnosticDisplayOptions
+clang_defaultReparseOptions
clang_disposeCodeCompleteResults
clang_disposeDiagnostic
clang_disposeIndex
More information about the cfe-commits
mailing list