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