[cfe-commits] r95864 - /cfe/trunk/tools/c-index-test/c-index-test.c

Ted Kremenek kremenek at apple.com
Wed Feb 10 23:41:25 PST 2010


Author: kremenek
Date: Thu Feb 11 01:41:25 2010
New Revision: 95864

URL: http://llvm.org/viewvc/llvm-project?rev=95864&view=rev
Log:
Attempt to always dispose of the CXIndex object in c-index-test.

Modified:
    cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=95864&r1=95863&r2=95864&view=diff

==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Feb 11 01:41:25 2010
@@ -493,13 +493,18 @@
                          PostVisitTU PV) {
   CXIndex Idx;
   CXTranslationUnit TU;
+  int result;
   Idx = clang_createIndex(/* excludeDeclsFromPCH */ 
                           !strcmp(filter, "local") ? 1 : 0);
   
-  if (!CreateTranslationUnit(Idx, file, &TU))
+  if (!CreateTranslationUnit(Idx, file, &TU)) {
+    clang_disposeIndex(Idx);
     return 1;
+  }
 
-  return perform_test_load(Idx, TU, filter, prefix, Visitor, PV);
+  result = perform_test_load(Idx, TU, filter, prefix, Visitor, PV);
+  clang_disposeIndex(Idx);
+  return result;
 }
 
 int perform_test_load_source(int argc, const char **argv,
@@ -519,8 +524,10 @@
   if (UseExternalASTs && strlen(UseExternalASTs))
     clang_setUseExternalASTGeneration(Idx, 1);
 
-  if (parse_remapped_files(argc, argv, 0, &unsaved_files, &num_unsaved_files))
+  if (parse_remapped_files(argc, argv, 0, &unsaved_files, &num_unsaved_files)) {
+    clang_disposeIndex(Idx);
     return -1;
+  }
 
   TU = clang_createTranslationUnitFromSourceFile(Idx, 0, 
                                                  argc - num_unsaved_files, 
@@ -531,11 +538,13 @@
                                                  stderr);
   if (!TU) {
     fprintf(stderr, "Unable to load translation unit!\n");
+    clang_disposeIndex(Idx);
     return 1;
   }
 
   result = perform_test_load(Idx, TU, filter, NULL, Visitor, PV);
   free_remapped_files(unsaved_files, num_unsaved_files);
+  clang_disposeIndex(Idx);
   return result;
 }
 





More information about the cfe-commits mailing list