xref: /minix3/external/bsd/llvm/dist/clang/test/Tooling/clang-check-ast-dump.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: clang-check -ast-dump "%s" -- 2>&1 | FileCheck %s
2*f4a2713aSLionel Sambuc // CHECK: NamespaceDecl{{.*}}test_namespace
3*f4a2713aSLionel Sambuc // CHECK-NEXT: CXXRecordDecl{{.*}}TheClass
4*f4a2713aSLionel Sambuc // CHECK: CXXMethodDecl{{.*}}theMethod
5*f4a2713aSLionel Sambuc // CHECK-NEXT: ParmVarDecl{{.*}}x
6*f4a2713aSLionel Sambuc // CHECK-NEXT: CompoundStmt
7*f4a2713aSLionel Sambuc // CHECK-NEXT:   ReturnStmt
8*f4a2713aSLionel Sambuc // CHECK-NEXT:     BinaryOperator
9*f4a2713aSLionel Sambuc //
10*f4a2713aSLionel Sambuc // RUN: clang-check -ast-dump -ast-dump-filter test_namespace::TheClass::theMethod "%s" -- 2>&1 | FileCheck -check-prefix CHECK-FILTER %s
11*f4a2713aSLionel Sambuc // CHECK-FILTER-NOT: NamespaceDecl
12*f4a2713aSLionel Sambuc // CHECK-FILTER-NOT: CXXRecordDecl
13*f4a2713aSLionel Sambuc // CHECK-FILTER: {{^}}Dumping test_namespace::TheClass::theMethod
14*f4a2713aSLionel Sambuc // CHECK-FILTER-NEXT: {{^}}CXXMethodDecl{{.*}}theMethod
15*f4a2713aSLionel Sambuc // CHECK-FILTER-NEXT: ParmVarDecl{{.*}}x
16*f4a2713aSLionel Sambuc // CHECK-FILTER-NEXT: CompoundStmt
17*f4a2713aSLionel Sambuc // CHECK-FILTER-NEXT:   ReturnStmt
18*f4a2713aSLionel Sambuc // CHECK-FILTER-NEXT:     BinaryOperator
19*f4a2713aSLionel Sambuc //
20*f4a2713aSLionel Sambuc // RUN: clang-check -ast-print "%s" -- 2>&1 | FileCheck -check-prefix CHECK-PRINT %s
21*f4a2713aSLionel Sambuc // CHECK-PRINT: namespace test_namespace
22*f4a2713aSLionel Sambuc // CHECK-PRINT: class TheClass
23*f4a2713aSLionel Sambuc // CHECK-PRINT: int theMethod(int x)
24*f4a2713aSLionel Sambuc //
25*f4a2713aSLionel Sambuc // RUN: clang-check -ast-list "%s" -- 2>&1 | FileCheck -check-prefix CHECK-LIST %s
26*f4a2713aSLionel Sambuc // CHECK-LIST: test_namespace
27*f4a2713aSLionel Sambuc // CHECK-LIST-NEXT: test_namespace::TheClass
28*f4a2713aSLionel Sambuc // CHECK-LIST-NEXT: test_namespace::TheClass::theMethod
29*f4a2713aSLionel Sambuc // CHECK-LIST-NEXT: x
30*f4a2713aSLionel Sambuc //
31*f4a2713aSLionel Sambuc // RUN: clang-check -ast-dump -ast-dump-filter test_namespace::TheClass::n "%s" -- 2>&1 | FileCheck -check-prefix CHECK-ATTR %s
32*f4a2713aSLionel Sambuc // CHECK-ATTR: test_namespace
33*f4a2713aSLionel Sambuc // CHECK-ATTR-NEXT: FieldDecl{{.*}}n
34*f4a2713aSLionel Sambuc // CHECK-ATTR-NEXT:   AlignedAttr
35*f4a2713aSLionel Sambuc // CHECK-ATTR-NEXT:     BinaryOperator
36*f4a2713aSLionel Sambuc //
37*f4a2713aSLionel Sambuc // RUN: clang-check -ast-dump -ast-dump-filter test_namespace::AfterNullNode "%s" -- 2>&1 | FileCheck -check-prefix CHECK-AFTER-NULL %s
38*f4a2713aSLionel Sambuc // CHECK-AFTER-NULL: class AfterNullNode
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc namespace test_namespace {
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc class TheClass {
43*f4a2713aSLionel Sambuc public:
theMethod(int x)44*f4a2713aSLionel Sambuc   int theMethod(int x) {
45*f4a2713aSLionel Sambuc     return x + x;
46*f4a2713aSLionel Sambuc   }
47*f4a2713aSLionel Sambuc   int n __attribute__((aligned(1+1)));
48*f4a2713aSLionel Sambuc };
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc // Used to fail with -ast-dump-filter X
51*f4a2713aSLionel Sambuc template<template<typename T> class C> class Z {};
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc // Check that traversal continues after the previous construct.
54*f4a2713aSLionel Sambuc class AfterNullNode {};
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc }
57