From 6bb92ecc0a6326aa03e64c94a864b8915f61317f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 13 Aug 2010 15:35:05 +0000 Subject: [PATCH] Add an options parameter to clang_saveTranslationUnit, because we'll want it later llvm-svn: 111016 --- clang/include/clang-c/Index.h | 33 +++++++++++++++++++- clang/tools/c-index-test/c-index-test.c | 2 +- clang/tools/libclang/CIndex.cpp | 7 ++++- clang/tools/libclang/libclang.darwin.exports | 1 + clang/tools/libclang/libclang.exports | 1 + 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index 4216e96c604a..ff0d92a38c2f 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -764,6 +764,31 @@ CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx, unsigned num_unsaved_files, 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 @@ CINDEX_LINKAGE CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx, * 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/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c index 323469c0f063..ef6bfb8a7974 100644 --- a/clang/tools/c-index-test/c-index-test.c +++ b/clang/tools/c-index-test/c-index-test.c @@ -1306,7 +1306,7 @@ int write_pch_file(const char *filename, int argc, const char *argv[]) { 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/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 4ba41b55cbbe..93fdd96c2416 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -1454,7 +1454,12 @@ CXTranslationUnit clang_parseTranslationUnit(CXIndex CIdx, 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/clang/tools/libclang/libclang.darwin.exports b/clang/tools/libclang/libclang.darwin.exports index f8f440203885..444d669e67b3 100644 --- a/clang/tools/libclang/libclang.darwin.exports +++ b/clang/tools/libclang/libclang.darwin.exports @@ -17,6 +17,7 @@ _clang_defaultCodeCompleteOptions _clang_defaultEditingTranslationUnitOptions _clang_defaultDiagnosticDisplayOptions _clang_defaultReparseOptions +_clang_defaultSaveOptions _clang_disposeCodeCompleteResults _clang_disposeDiagnostic _clang_disposeIndex diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports index cdb04bc93463..a1e114afd919 100644 --- a/clang/tools/libclang/libclang.exports +++ b/clang/tools/libclang/libclang.exports @@ -17,6 +17,7 @@ clang_defaultCodeCompleteOptions clang_defaultEditingTranslationUnitOptions clang_defaultDiagnosticDisplayOptions clang_defaultReparseOptions +clang_defaultSaveOptions clang_disposeCodeCompleteResults clang_disposeDiagnostic clang_disposeIndex