diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-07-06 16:43:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-07-06 16:43:36 +0000 |
commit | 39c411fa229b2a6747b92f945d1702ee674d3470 (patch) | |
tree | 621b36eacc4db3fa450851563953e3267a90b501 /tools/c-index-test/c-index-test.c | |
parent | 5d98994c7749312a43ce6adf45537979a98e7afd (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 'tools/c-index-test/c-index-test.c')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 837fc8929e..d1bdf96e71 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -1517,12 +1517,36 @@ int write_pch_file(const char *filename, int argc, const char *argv[]) { return 1; } - if (clang_saveTranslationUnit(TU, filename, clang_defaultSaveOptions(TU))) - fprintf(stderr, "Unable to write PCH file %s\n", filename); + int result = 0; + + switch (clang_saveTranslationUnit(TU, filename, + clang_defaultSaveOptions(TU))) { + case CXSaveError_None: + break; + + case CXSaveError_TranslationErrors: + fprintf(stderr, "Unable to write PCH file %s: translation errors\n", + filename); + result = 2; + break; + + case CXSaveError_InvalidTU: + fprintf(stderr, "Unable to write PCH file %s: invalid translation unit\n", + filename); + result = 3; + break; + + case CXSaveError_Unknown: + default: + fprintf(stderr, "Unable to write PCH file %s: unknown error \n", filename); + result = 1; + break; + } + clang_disposeTranslationUnit(TU); free_remapped_files(unsaved_files, num_unsaved_files); clang_disposeIndex(Idx); - return 0; + return result; } /******************************************************************************/ |