Add an options parameter to clang_saveTranslationUnit, because we'll want it later

llvm-svn: 111016
This commit is contained in:
Douglas Gregor 2010-08-13 15:35:05 +00:00
parent c852cef1f2
commit 6bb92ecc0a
5 changed files with 41 additions and 3 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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;

View File

@ -17,6 +17,7 @@ _clang_defaultCodeCompleteOptions
_clang_defaultEditingTranslationUnitOptions
_clang_defaultDiagnosticDisplayOptions
_clang_defaultReparseOptions
_clang_defaultSaveOptions
_clang_disposeCodeCompleteResults
_clang_disposeDiagnostic
_clang_disposeIndex

View File

@ -17,6 +17,7 @@ clang_defaultCodeCompleteOptions
clang_defaultEditingTranslationUnitOptions
clang_defaultDiagnosticDisplayOptions
clang_defaultReparseOptions
clang_defaultSaveOptions
clang_disposeCodeCompleteResults
clang_disposeDiagnostic
clang_disposeIndex