summaryrefslogtreecommitdiffstats
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-01-26 17:55:33 +0000
committerTed Kremenek <kremenek@apple.com>2010-01-26 17:55:33 +0000
commita97a5cd59ee5413b457906be416f241a43b42d54 (patch)
treee85196c205e720507ad7d03bb10294c6b23c5cef /clang/tools/c-index-test/c-index-test.c
parentca4a5459d8034123868fd3cee7fb190d90c1414b (diff)
downloadbcm5719-llvm-a97a5cd59ee5413b457906be416f241a43b42d54.tar.gz
bcm5719-llvm-a97a5cd59ee5413b457906be416f241a43b42d54.zip
Allow the 'visitor' argument to 'perform_test_load()' to be NULL. The
utility of this change will be made clearer in a subsequent patch when perform_test_load()' does more than stream the AST. llvm-svn: 94556
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 222ffbaa635..a5b2f9166b2 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -303,29 +303,33 @@ enum CXChildVisitResult USRVisitor(CXCursor C, CXCursor parent,
static int perform_test_load(CXIndex Idx, CXTranslationUnit TU,
const char *filter, const char *prefix,
CXCursorVisitor Visitor) {
- enum CXCursorKind K = CXCursor_NotImplemented;
- enum CXCursorKind *ck = &K;
- VisitorData Data;
if (prefix)
FileCheckPrefix = prefix;
+
+ if (Visitor) {
+ enum CXCursorKind K = CXCursor_NotImplemented;
+ enum CXCursorKind *ck = &K;
+ VisitorData Data;
- /* Perform some simple filtering. */
- if (!strcmp(filter, "all") || !strcmp(filter, "local")) ck = NULL;
- else if (!strcmp(filter, "category")) K = CXCursor_ObjCCategoryDecl;
- else if (!strcmp(filter, "interface")) K = CXCursor_ObjCInterfaceDecl;
- else if (!strcmp(filter, "protocol")) K = CXCursor_ObjCProtocolDecl;
- else if (!strcmp(filter, "function")) K = CXCursor_FunctionDecl;
- else if (!strcmp(filter, "typedef")) K = CXCursor_TypedefDecl;
- else if (!strcmp(filter, "scan-function")) Visitor = FunctionScanVisitor;
- else {
- fprintf(stderr, "Unknown filter for -test-load-tu: %s\n", filter);
- return 1;
- }
+ /* Perform some simple filtering. */
+ if (!strcmp(filter, "all") || !strcmp(filter, "local")) ck = NULL;
+ else if (!strcmp(filter, "category")) K = CXCursor_ObjCCategoryDecl;
+ else if (!strcmp(filter, "interface")) K = CXCursor_ObjCInterfaceDecl;
+ else if (!strcmp(filter, "protocol")) K = CXCursor_ObjCProtocolDecl;
+ else if (!strcmp(filter, "function")) K = CXCursor_FunctionDecl;
+ else if (!strcmp(filter, "typedef")) K = CXCursor_TypedefDecl;
+ else if (!strcmp(filter, "scan-function")) Visitor = FunctionScanVisitor;
+ else {
+ fprintf(stderr, "Unknown filter for -test-load-tu: %s\n", filter);
+ return 1;
+ }
- Data.TU = TU;
- Data.Filter = ck;
- clang_visitChildren(clang_getTranslationUnitCursor(TU), Visitor, &Data);
+ Data.TU = TU;
+ Data.Filter = ck;
+ clang_visitChildren(clang_getTranslationUnitCursor(TU), Visitor, &Data);
+ }
+
clang_disposeTranslationUnit(TU);
return 0;
}
OpenPOWER on IntegriCloud