Add an options parameter to clang_saveTranslationUnit, because we'll want it later
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111016 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 4216e96..ff0d92a 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -765,6 +765,31 @@
unsigned options);
/**
+ * \brief Flags that control how translation units are saved.
+ *
+ * The enumerators in this enumeration type are meant to be bitwise
+ * ORed together to specify which options should be used when
+ * saving the translation unit.
+ */
+enum CXSaveTranslationUnit_Flags {
+ /**
+ * \brief Used to indicate that no special saving options are needed.
+ */
+ CXSaveTranslationUnit_None = 0x0
+};
+
+/**
+ * \brief Returns the set of flags that is suitable for saving a translation
+ * unit.
+ *
+ * The set of flags returned provide options for
+ * \c clang_saveTranslationUnit() by default. The returned flag
+ * set contains an unspecified set of options that save translation units with
+ * the most commonly-requested data.
+ */
+CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
+
+/**
* \brief Saves a translation unit into a serialized representation of
* that translation unit on disk.
*
@@ -776,13 +801,19 @@
* units.
*
* \param TU The translation unit to save.
+ *
* \param FileName The file to which the translation unit will be saved.
*
+ * \param options A bitmask of options that affects how the translation unit
+ * is saved. This should be a bitwise OR of the
+ * CXSaveTranslationUnit_XXX flags.
+ *
* \returns Zero if the translation unit was saved successfully, a
* non-zero value otherwise.
*/
CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
- const char *FileName);
+ const char *FileName,
+ unsigned options);
/**
* \brief Destroy the specified CXTranslationUnit object.
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 323469c..ef6bfb8 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -1306,7 +1306,7 @@
return 1;
}
- if (clang_saveTranslationUnit(TU, filename))
+ if (clang_saveTranslationUnit(TU, filename, clang_defaultSaveOptions(TU)))
fprintf(stderr, "Unable to write PCH file %s\n", filename);
clang_disposeTranslationUnit(TU);
free_remapped_files(unsaved_files, num_unsaved_files);
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 4ba41b5..93fdd96 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1454,7 +1454,12 @@
return ATU;
}
-int clang_saveTranslationUnit(CXTranslationUnit TU, const char *FileName) {
+unsigned clang_defaultSaveOptions(CXTranslationUnit TU) {
+ return CXSaveTranslationUnit_None;
+}
+
+int clang_saveTranslationUnit(CXTranslationUnit TU, const char *FileName,
+ unsigned options) {
if (!TU)
return 1;
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index f8f4402..444d669 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -17,6 +17,7 @@
_clang_defaultEditingTranslationUnitOptions
_clang_defaultDiagnosticDisplayOptions
_clang_defaultReparseOptions
+_clang_defaultSaveOptions
_clang_disposeCodeCompleteResults
_clang_disposeDiagnostic
_clang_disposeIndex
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index cdb04bc..a1e114a 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -17,6 +17,7 @@
clang_defaultEditingTranslationUnitOptions
clang_defaultDiagnosticDisplayOptions
clang_defaultReparseOptions
+clang_defaultSaveOptions
clang_disposeCodeCompleteResults
clang_disposeDiagnostic
clang_disposeIndex