2017-08-19 17:36:14 +08:00
|
|
|
// RUN: clang-diff -ast-dump %s -- -std=c++11 | FileCheck %s
|
|
|
|
|
|
|
|
|
|
|
|
// CHECK: {{^}}TranslationUnitDecl(0)
|
|
|
|
// CHECK: {{^}} NamespaceDecl: test;(
|
|
|
|
namespace test {
|
|
|
|
|
2017-08-22 16:56:26 +08:00
|
|
|
// CHECK: {{^}} FunctionDecl: :f(
|
2017-08-19 17:36:14 +08:00
|
|
|
// CHECK: CompoundStmt(
|
|
|
|
void f() {
|
|
|
|
// CHECK: VarDecl: i(int)(
|
|
|
|
// CHECK: IntegerLiteral: 1
|
|
|
|
auto i = 1;
|
2017-08-21 00:18:43 +08:00
|
|
|
// CHECK: FloatingLiteral: 1.5(
|
|
|
|
auto r = 1.5;
|
|
|
|
// CHECK: CXXBoolLiteralExpr: true(
|
|
|
|
auto b = true;
|
2017-08-19 17:36:14 +08:00
|
|
|
// CHECK: CallExpr(
|
2017-08-20 18:22:32 +08:00
|
|
|
// CHECK-NOT: ImplicitCastExpr
|
2017-08-22 16:56:26 +08:00
|
|
|
// CHECK: DeclRefExpr: :f(
|
2017-08-19 17:36:14 +08:00
|
|
|
f();
|
2017-08-21 00:18:43 +08:00
|
|
|
// CHECK: UnaryOperator: ++(
|
|
|
|
++i;
|
2017-08-19 17:36:14 +08:00
|
|
|
// CHECK: BinaryOperator: =(
|
|
|
|
i = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace test
|
|
|
|
|
2017-08-21 00:18:43 +08:00
|
|
|
// CHECK: UsingDirectiveDecl: test(
|
|
|
|
using namespace test;
|
|
|
|
|
2017-08-19 17:36:14 +08:00
|
|
|
// CHECK: TypedefDecl: nat;unsigned int;(
|
|
|
|
typedef unsigned nat;
|
|
|
|
// CHECK: TypeAliasDecl: real;double;(
|
|
|
|
using real = double;
|
|
|
|
|
|
|
|
class Base {
|
|
|
|
};
|
|
|
|
|
2017-08-21 00:18:43 +08:00
|
|
|
// CHECK: CXXRecordDecl: X;X;(
|
2017-08-19 17:36:14 +08:00
|
|
|
class X : Base {
|
|
|
|
int m;
|
2017-08-22 16:56:26 +08:00
|
|
|
// CHECK: CXXMethodDecl: :foo(const char *(int)
|
2017-08-19 17:36:14 +08:00
|
|
|
// CHECK: ParmVarDecl: i(int)(
|
|
|
|
const char *foo(int i) {
|
|
|
|
if (i == 0)
|
|
|
|
// CHECK: StringLiteral: foo(
|
|
|
|
return "foo";
|
2017-08-20 18:22:32 +08:00
|
|
|
// CHECK-NOT: ImplicitCastExpr
|
2017-08-19 17:36:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: AccessSpecDecl: public(
|
|
|
|
public:
|
2017-08-21 00:18:43 +08:00
|
|
|
int not_initialized;
|
2017-08-28 06:52:20 +08:00
|
|
|
// CHECK: CXXConstructorDecl: :X(void (char, int){{( __attribute__\(\(thiscall\)\))?}})(
|
|
|
|
// CHECK-NEXT: ParmVarDecl: s(char)
|
|
|
|
// CHECK-NEXT: ParmVarDecl: (int)
|
|
|
|
// CHECK-NEXT: CXXCtorInitializer: Base
|
|
|
|
// CHECK-NEXT: CXXConstructExpr
|
|
|
|
// CHECK-NEXT: CXXCtorInitializer: m
|
|
|
|
// CHECK-NEXT: IntegerLiteral: 0
|
|
|
|
X(char s, int) : Base(), m(0) {
|
|
|
|
// CHECK-NEXT: CompoundStmt
|
2017-08-22 16:56:26 +08:00
|
|
|
// CHECK: MemberExpr: :m(
|
2017-08-19 17:36:14 +08:00
|
|
|
int x = m;
|
|
|
|
}
|
2017-08-28 06:52:20 +08:00
|
|
|
// CHECK: CXXConstructorDecl: :X(void (char){{( __attribute__\(\(thiscall\)\))?}})(
|
|
|
|
// CHECK: CXXCtorInitializer: X
|
2017-08-21 00:18:43 +08:00
|
|
|
X(char s) : X(s, 4) {}
|
2017-08-19 17:36:14 +08:00
|
|
|
};
|
2017-08-20 18:22:32 +08:00
|
|
|
|
|
|
|
#define M (void)1
|
|
|
|
#define MA(a, b) (void)a, b
|
|
|
|
// CHECK: FunctionDecl
|
|
|
|
// CHECK-NEXT: CompoundStmt
|
|
|
|
void macros() {
|
|
|
|
M;
|
|
|
|
MA(1, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef GUARD
|
|
|
|
#define GUARD
|
|
|
|
// CHECK-NEXT: NamespaceDecl
|
|
|
|
namespace world {
|
|
|
|
// nodes from other files are excluded, there should be no output here
|
|
|
|
#include "clang-diff-ast.cpp"
|
|
|
|
}
|
|
|
|
// CHECK-NEXT: FunctionDecl: sentinel
|
|
|
|
void sentinel();
|
|
|
|
#endif
|