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

Ted Kremenek kremenek at apple.com
Tue Jan 26 09:59:49 PST 2010


Author: kremenek
Date: Tue Jan 26 11:59:48 2010
New Revision: 94557

URL: http://llvm.org/viewvc/llvm-project?rev=94557&view=rev
Log:
Add 'PostVisitTU' callback hook to 'perform_test_load()' to allow a special callback after the translation unit has been loaded (and streamed).

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=94557&r1=94556&r2=94557&view=diff

==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Jan 26 11:59:48 2010
@@ -172,6 +172,12 @@
 }
 
 /******************************************************************************/
+/* Callbacks.                                                                 */
+/******************************************************************************/
+
+typedef void (*PostVisitTU)(CXTranslationUnit);
+
+/******************************************************************************/
 /* Logic for testing traversal.                                               */
 /******************************************************************************/
 
@@ -302,7 +308,8 @@
 
 static int perform_test_load(CXIndex Idx, CXTranslationUnit TU,
                              const char *filter, const char *prefix,
-                             CXCursorVisitor Visitor) {
+                             CXCursorVisitor Visitor,
+                             PostVisitTU PV) {
   
   if (prefix)
     FileCheckPrefix = prefix;  
@@ -329,14 +336,17 @@
     Data.Filter = ck;
     clang_visitChildren(clang_getTranslationUnitCursor(TU), Visitor, &Data);
   }
+  
+  if (PV)
+    PV(TU);
 
   clang_disposeTranslationUnit(TU);
   return 0;
 }
 
 int perform_test_load_tu(const char *file, const char *filter,
-                         const char *prefix,
-                         CXCursorVisitor Visitor) {
+                         const char *prefix, CXCursorVisitor Visitor,
+                         PostVisitTU PV) {
   CXIndex Idx;
   CXTranslationUnit TU;
   Idx = clang_createIndex(/* excludeDeclsFromPCH */ 
@@ -346,11 +356,12 @@
   if (!CreateTranslationUnit(Idx, file, &TU))
     return 1;
 
-  return perform_test_load(Idx, TU, filter, prefix, Visitor);
+  return perform_test_load(Idx, TU, filter, prefix, Visitor, PV);
 }
 
-int perform_test_load_source(int argc, const char **argv, const char *filter,
-                             CXCursorVisitor Visitor) {
+int perform_test_load_source(int argc, const char **argv,
+                             const char *filter, CXCursorVisitor Visitor,
+                             PostVisitTU PV) {
   const char *UseExternalASTs =
     getenv("CINDEXTEST_USE_EXTERNAL_AST_GENERATION");
   CXIndex Idx;
@@ -379,7 +390,7 @@
     return 1;
   }
 
-  result = perform_test_load(Idx, TU, filter, NULL, Visitor);
+  result = perform_test_load(Idx, TU, filter, NULL, Visitor, PV);
   free_remapped_files(unsaved_files, num_unsaved_files);
   return result;
 }
@@ -857,12 +868,13 @@
   else if (argc >= 4 && strncmp(argv[1], "-test-load-tu", 13) == 0) {
     CXCursorVisitor I = GetVisitor(argv[1] + 13);
     if (I)
-      return perform_test_load_tu(argv[2], argv[3], argc >= 5 ? argv[4] : 0, I);
+      return perform_test_load_tu(argv[2], argv[3], argc >= 5 ? argv[4] : 0, I,
+                                  NULL);
   }
   else if (argc >= 4 && strncmp(argv[1], "-test-load-source", 17) == 0) {
     CXCursorVisitor I = GetVisitor(argv[1] + 17);
     if (I)
-      return perform_test_load_source(argc - 3, argv + 3, argv[2], I);
+      return perform_test_load_source(argc - 3, argv + 3, argv[2], I, NULL);
   }
   else if (argc >= 4 && strcmp(argv[1], "-test-file-scan") == 0)
     return perform_file_scan(argv[2], argv[3],





More information about the cfe-commits mailing list