summaryrefslogtreecommitdiff
path: root/test/Tooling
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2017-08-19 09:36:14 +0000
committerJohannes Altmanninger <aclopte@gmail.com>2017-08-19 09:36:14 +0000
commitd9cea6adc496c110f6f2c0775f32d169ae78ee18 (patch)
tree982ff7d06f7156e278d7810453baed0c0b2eddb0 /test/Tooling
parent477f579e67f1eb7da7e9df0b6d01e3ae70508859 (diff)
downloadclang-d9cea6adc496c110f6f2c0775f32d169ae78ee18.tar.gz
[clang-diff] Add option to dump the AST, one node per line
Summary: This is done with -ast-dump; the JSON variant has been renamed to -ast-dump-json. Reviewers: arphaman Differential Revision: https://reviews.llvm.org/D36180 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311232 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Tooling')
-rw-r--r--test/Tooling/clang-diff-ast.cpp50
-rw-r--r--test/Tooling/clang-diff-json.cpp6
2 files changed, 53 insertions, 3 deletions
diff --git a/test/Tooling/clang-diff-ast.cpp b/test/Tooling/clang-diff-ast.cpp
new file mode 100644
index 0000000000..bfa90c6560
--- /dev/null
+++ b/test/Tooling/clang-diff-ast.cpp
@@ -0,0 +1,50 @@
+// RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s
+
+
+// CHECK: {{^}}TranslationUnitDecl(0)
+// CHECK: {{^}} NamespaceDecl: test;(
+namespace test {
+
+// CHECK: {{^}} FunctionDecl: f(
+// CHECK: CompoundStmt(
+void f() {
+ // CHECK: VarDecl: i(int)(
+ // CHECK: IntegerLiteral: 1
+ auto i = 1;
+ // CHECK: CallExpr(
+ // CHECK: DeclRefExpr: f(
+ f();
+ // CHECK: BinaryOperator: =(
+ i = i;
+}
+
+} // end namespace test
+
+// CHECK: TypedefDecl: nat;unsigned int;(
+typedef unsigned nat;
+// CHECK: TypeAliasDecl: real;double;(
+using real = double;
+
+class Base {
+};
+
+// CHECK: CXXRecordDecl: X;class X;(
+class X : Base {
+ int m;
+ // CHECK: CXXMethodDecl: foo(const char *(int))(
+ // CHECK: ParmVarDecl: i(int)(
+ const char *foo(int i) {
+ if (i == 0)
+ // CHECK: StringLiteral: foo(
+ return "foo";
+ return 0;
+ }
+
+ // CHECK: AccessSpecDecl: public(
+public:
+ // CHECK: CXXConstructorDecl: X(void (char, int))(
+ X(char, int) : Base(), m(0) {
+ // CHECK: MemberExpr(
+ int x = m;
+ }
+};
diff --git a/test/Tooling/clang-diff-json.cpp b/test/Tooling/clang-diff-json.cpp
index e4a971bf42..cbbd48ea84 100644
--- a/test/Tooling/clang-diff-json.cpp
+++ b/test/Tooling/clang-diff-json.cpp
@@ -1,11 +1,11 @@
-// RUN: clang-diff -ast-dump %s -- \
+// RUN: clang-diff -ast-dump-json %s -- \
// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
// RUN: | FileCheck %s
-// CHECK: "begin": 294,
+// CHECK: "begin": 299,
// CHECK: "type": "CXXRecordDecl",
// CHECK: "type": "FieldDecl",
-// CHECK: "end": 314,
+// CHECK: "end": 319,
class A {
int x;
};