[libclang] Move the check for errors in c-index-test before the TU gets disposed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144514 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 8ab7f94..ae970fb 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -709,6 +709,11 @@
PV(TU);
PrintDiagnostics(TU);
+ if (checkForErrors(TU) != 0) {
+ clang_disposeTranslationUnit(TU);
+ return -1;
+ }
+
clang_disposeTranslationUnit(TU);
return 0;
}
@@ -830,9 +835,6 @@
result = perform_test_load(Idx, TU, filter, NULL, Visitor, PV);
- if (checkForErrors(TU) != 0)
- return -1;
-
free_remapped_files(unsaved_files, num_unsaved_files);
clang_disposeIndex(Idx);
return result;