brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · a8efda5 Raw
93 lines · cpp
1// RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s2 3 4// CHECK: {{^}}TranslationUnitDecl(0)5// CHECK: {{^}} NamespaceDecl: test;(6namespace test {7 8// CHECK: {{^}} FunctionDecl: :f(9// CHECK: CompoundStmt(10void f() {11  // CHECK: VarDecl: i(int)(12  // CHECK: IntegerLiteral: 113  auto i = 1;14  // CHECK: FloatingLiteral: 1.5(15  auto r = 1.5;16  // CHECK: CXXBoolLiteralExpr: true(17  auto b = true;18  // CHECK: CallExpr(19  // CHECK-NOT: ImplicitCastExpr20  // CHECK: DeclRefExpr: :f(21  f();22  // CHECK: UnaryOperator: ++(23  ++i;24  // CHECK: BinaryOperator: =(25  i = i;26}27 28} // end namespace test29 30// CHECK: UsingDirectiveDecl: test(31using namespace test;32 33// CHECK: TypedefDecl: nat;unsigned int;(34typedef unsigned nat;35// CHECK: TypeAliasDecl: real;double;(36using real = double;37 38class Base {39};40 41// CHECK: CXXRecordDecl: X;X;(42class X : Base {43  int m;44  // CHECK: CXXMethodDecl: :foo(const char *(int)45  // CHECK: ParmVarDecl: i(int)(46  const char *foo(int i) {47    if (i == 0)48      // CHECK: StringLiteral: foo(49      return "foo";50    // CHECK-NOT: ImplicitCastExpr51    return 0;52  }53 54  // CHECK: AccessSpecDecl: public(55public:56  int not_initialized;57  // CHECK: CXXConstructorDecl: :X(void (char, int){{( __attribute__\(\(thiscall\)\))?}})(58  // CHECK-NEXT: ParmVarDecl: s(char)59  // CHECK-NEXT: ParmVarDecl: (int)60  // CHECK-NEXT: CXXCtorInitializer: Base61  // CHECK-NEXT: CXXConstructExpr62  // CHECK-NEXT: CXXCtorInitializer: m63  // CHECK-NEXT: IntegerLiteral: 064  X(char s, int) : Base(), m(0) {65    // CHECK-NEXT: CompoundStmt66    // CHECK: MemberExpr: :m(67    int x = m;68  }69  // CHECK: CXXConstructorDecl: :X(void (char){{( __attribute__\(\(thiscall\)\))?}})(70  // CHECK: CXXCtorInitializer: X71  X(char s) : X(s, 4) {}72};73 74#define M (void)175#define MA(a, b) (void)a, b76// CHECK: FunctionDecl77// CHECK-NEXT: CompoundStmt78void macros() {79  M;80  MA(1, 2);81}82 83#ifndef GUARD84#define GUARD85// CHECK-NEXT: NamespaceDecl86namespace world {87// nodes from other files are excluded, there should be no output here88#include "clang-diff-ast.cpp"89}90// CHECK-NEXT: FunctionDecl: sentinel91void sentinel();92#endif93