aboutsummaryrefslogtreecommitdiff
path: root/include/clang-c
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-06 16:43:36 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-06 16:43:36 +0000
commit39c411fa229b2a6747b92f945d1702ee674d3470 (patch)
tree621b36eacc4db3fa450851563953e3267a90b501 /include/clang-c
parent5d98994c7749312a43ce6adf45537979a98e7afd (diff)
libclang: Allow callers of clang_saveTranslationUnit() to distinguish
between different classes of errors. Addresses most of <rdar://problem/9660328>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134495 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang-c')
-rw-r--r--include/clang-c/Index.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index 01e7bce6bd..5bf20316b1 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -933,6 +933,41 @@ enum CXSaveTranslationUnit_Flags {
CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
/**
+ * \brief Describes the kind of error that occurred (if any) in a call to
+ * \c clang_saveTranslationUnit().
+ */
+enum CXSaveError {
+ /**
+ * \brief Indicates that no error occurred while saving a translation unit.
+ */
+ CXSaveError_None = 0,
+
+ /**
+ * \brief Indicates that an unknown error occurred while attempting to save
+ * the file.
+ *
+ * This error typically indicates that file I/O failed when attempting to
+ * write the file.
+ */
+ CXSaveError_Unknown = 1,
+
+ /**
+ * \brief Indicates that errors during translation prevented this attempt
+ * to save the translation unit.
+ *
+ * Errors that prevent the translation unit from being saved can be
+ * extracted using \c clang_getNumDiagnostics() and \c clang_getDiagnostic().
+ */
+ CXSaveError_TranslationErrors = 2,
+
+ /**
+ * \brief Indicates that the translation unit to be saved was somehow
+ * invalid (e.g., NULL).
+ */
+ CXSaveError_InvalidTU = 3
+};
+
+/**
* \brief Saves a translation unit into a serialized representation of
* that translation unit on disk.
*
@@ -951,8 +986,9 @@ CINDEX_LINKAGE unsigned clang_defaultSaveOptions(CXTranslationUnit TU);
* 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.
+ * \returns A value that will match one of the enumerators of the CXSaveError
+ * enumeration. Zero (CXSaveError_None) indicates that the translation unit was
+ * saved successfully, while a non-zero value indicates that a problem occurred.
*/
CINDEX_LINKAGE int clang_saveTranslationUnit(CXTranslationUnit TU,
const char *FileName,