blob: 1f0e780558fdb5a5414258a7c3c31de2017d3d0b [file] [log] [blame]
Rafael Espindolafe958412013-01-07 23:04:04 +00001// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck --strict-whitespace %s
Alexander Kornienko5bc364e2013-01-07 17:53:08 +00002
3int TestLocation
4__attribute__((unused));
5// CHECK: VarDecl{{.*}}TestLocation
6// CHECK-NEXT: UnusedAttr 0x{{[^ ]*}} <line:[[@LINE-2]]:16>
7
8int TestIndent
9__attribute__((unused));
Richard Trieude5cc7d2013-01-31 01:44:26 +000010// CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}}
11// CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}}
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000012
13void TestAttributedStmt() {
14 switch (1) {
15 case 1:
16 [[clang::fallthrough]];
17 case 2:
18 ;
19 }
20}
21// CHECK: FunctionDecl{{.*}}TestAttributedStmt
22// CHECK: AttributedStmt
23// CHECK-NEXT: FallThroughAttr
24// CHECK-NEXT: NullStmt
25
26[[clang::warn_unused_result]] int TestCXX11DeclAttr();
27// CHECK: FunctionDecl{{.*}}TestCXX11DeclAttr
28// CHECK-NEXT: WarnUnusedResultAttr
29
30int TestAlignedNull __attribute__((aligned));
31// CHECK: VarDecl{{.*}}TestAlignedNull
Aaron Ballmanbc909612014-01-22 21:51:20 +000032// CHECK-NEXT: AlignedAttr {{.*}} aligned
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000033// CHECK-NEXT: <<<NULL>>>
34
35int TestAlignedExpr __attribute__((aligned(4)));
36// CHECK: VarDecl{{.*}}TestAlignedExpr
Aaron Ballmanbc909612014-01-22 21:51:20 +000037// CHECK-NEXT: AlignedAttr {{.*}} aligned
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000038// CHECK-NEXT: IntegerLiteral
39
40int TestEnum __attribute__((visibility("default")));
41// CHECK: VarDecl{{.*}}TestEnum
42// CHECK-NEXT: VisibilityAttr{{.*}} Default
43
44class __attribute__((lockable)) Mutex {
45} mu1, mu2;
46int TestExpr __attribute__((guarded_by(mu1)));
47// CHECK: VarDecl{{.*}}TestExpr
48// CHECK-NEXT: GuardedByAttr
49// CHECK-NEXT: DeclRefExpr{{.*}}mu1
50
51class Mutex TestVariadicExpr __attribute__((acquired_after(mu1, mu2)));
52// CHECK: VarDecl{{.*}}TestVariadicExpr
53// CHECK: AcquiredAfterAttr
54// CHECK-NEXT: DeclRefExpr{{.*}}mu1
55// CHECK-NEXT: DeclRefExpr{{.*}}mu2
56
57void function1(void *) {
58 int TestFunction __attribute__((cleanup(function1)));
59}
60// CHECK: VarDecl{{.*}}TestFunction
61// CHECK-NEXT: CleanupAttr{{.*}} Function{{.*}}function1
62
63void TestIdentifier(void *, int)
64__attribute__((pointer_with_type_tag(ident1,1,2)));
65// CHECK: FunctionDecl{{.*}}TestIdentifier
Aaron Ballmanbc909612014-01-22 21:51:20 +000066// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag ident1
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000067
68void TestBool(void *, int)
69__attribute__((pointer_with_type_tag(bool1,1,2)));
70// CHECK: FunctionDecl{{.*}}TestBool
Aaron Ballmanbc909612014-01-22 21:51:20 +000071// CHECK: ArgumentWithTypeTagAttr{{.*}}pointer_with_type_tag bool1 0 1 IsPointer
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000072
73void TestUnsigned(void *, int)
74__attribute__((pointer_with_type_tag(unsigned1,1,2)));
75// CHECK: FunctionDecl{{.*}}TestUnsigned
Aaron Ballmanbc909612014-01-22 21:51:20 +000076// CHECK: ArgumentWithTypeTagAttr{{.*}} pointer_with_type_tag unsigned1 0 1
Alexander Kornienko5bc364e2013-01-07 17:53:08 +000077
78void TestInt(void) __attribute__((constructor(123)));
79// CHECK: FunctionDecl{{.*}}TestInt
80// CHECK-NEXT: ConstructorAttr{{.*}} 123
81
82int TestString __attribute__((alias("alias1")));
83// CHECK: VarDecl{{.*}}TestString
84// CHECK-NEXT: AliasAttr{{.*}} "alias1"
85
86extern struct s1 TestType
87__attribute__((type_tag_for_datatype(ident1,int)));
88// CHECK: VarDecl{{.*}}TestType
89// CHECK-NEXT: TypeTagForDatatypeAttr{{.*}} int
90
Richard Smitha3e01cf2013-11-15 22:45:29 +000091void TestLabel() {
92L: __attribute__((unused)) int i;
93// CHECK: LabelStmt{{.*}}'L'
94// CHECK: VarDecl{{.*}}i 'int'
95// CHECK-NEXT: UnusedAttr{{.*}}
96
97M: __attribute(()) int j;
98// CHECK: LabelStmt {{.*}} 'M'
99// CHECK-NEXT: DeclStmt
100// CHECK-NEXT: VarDecl {{.*}} j 'int'
101
102N: __attribute(()) ;
103// CHECK: LabelStmt {{.*}} 'N'
104// CHECK-NEXT: NullStmt
105}
Aaron Ballman36a53502014-01-16 13:03:14 +0000106
107namespace Test {
108extern "C" int printf(const char *format, ...);
109// CHECK: FunctionDecl{{.*}}printf
110// CHECK-NEXT: ParmVarDecl{{.*}}format{{.*}}'const char *'
111// CHECK-NEXT: FormatAttr{{.*}}printf 1 2 Implicit
112}