diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2013-11-08 00:08:23 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2013-11-08 00:08:23 +0000 |
| commit | 8b1265b353b027d90252f1a23c5c3121ee70f3a1 (patch) | |
| tree | 4d104d38960d01338209c32d106c9b6a764976e7 /clang-tools-extra/test/clang-query | |
| parent | 640830142100ea828ba54b42c68ccc4b3dd1d8ea (diff) | |
| download | bcm5719-llvm-8b1265b353b027d90252f1a23c5c3121ee70f3a1.tar.gz bcm5719-llvm-8b1265b353b027d90252f1a23c5c3121ee70f3a1.zip | |
Introduce clang-query tool.
This tool is for interactive exploration of the Clang AST using AST matchers.
It currently allows the user to enter a matcher at an interactive prompt
and view the resulting bindings as diagnostics, AST pretty prints or AST
dumps. Example session:
$ cat foo.c
void foo(void) {}
$ clang-query foo.c --
clang-query> match functionDecl()
Match #1:
foo.c:1:1: note: "root" binds here
void foo(void) {}
^~~~~~~~~~~~~~~~~
1 match.
Differential Revision: http://llvm-reviews.chandlerc.com/D2098
llvm-svn: 194227
Diffstat (limited to 'clang-tools-extra/test/clang-query')
| -rw-r--r-- | clang-tools-extra/test/clang-query/Inputs/foo.script | 2 | ||||
| -rw-r--r-- | clang-tools-extra/test/clang-query/errors.c | 11 | ||||
| -rw-r--r-- | clang-tools-extra/test/clang-query/function-decl.c | 5 |
3 files changed, 18 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-query/Inputs/foo.script b/clang-tools-extra/test/clang-query/Inputs/foo.script new file mode 100644 index 00000000000..3bd1f0e2974 --- /dev/null +++ b/clang-tools-extra/test/clang-query/Inputs/foo.script @@ -0,0 +1,2 @@ +foo +bar diff --git a/clang-tools-extra/test/clang-query/errors.c b/clang-tools-extra/test/clang-query/errors.c new file mode 100644 index 00000000000..96bb6bf216c --- /dev/null +++ b/clang-tools-extra/test/clang-query/errors.c @@ -0,0 +1,11 @@ +// RUN: not clang-query -c foo -c bar %s -- | FileCheck %s +// RUN: not clang-query -f %S/Inputs/foo.script %s -- | FileCheck %s +// RUN: not clang-query -f %S/Inputs/nonexistent.script %s -- 2>&1 | FileCheck --check-prefix=CHECK-NONEXISTENT %s +// RUN: not clang-query -c foo -f foo %s -- 2>&1 | FileCheck --check-prefix=CHECK-BOTH %s +// REQUIRES: libedit + +// CHECK: unknown command: foo +// CHECK-NOT: unknown command: bar + +// CHECK-NONEXISTENT: cannot open {{.*}}nonexistent.script +// CHECK-BOTH: cannot specify both -c and -f diff --git a/clang-tools-extra/test/clang-query/function-decl.c b/clang-tools-extra/test/clang-query/function-decl.c new file mode 100644 index 00000000000..8a2c4bf1201 --- /dev/null +++ b/clang-tools-extra/test/clang-query/function-decl.c @@ -0,0 +1,5 @@ +// RUN: clang-query -c "match functionDecl()" %s -- | FileCheck %s +// REQUIRES: libedit + +// CHECK: function-decl.c:5:1: note: "root" binds here +void foo(void) {} |

