blob: 3efcd098b370a20537dbe5e27351a804ae8083fc [file] [log] [blame]
Rafael Espindola3c4e4812013-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 Kornienkoc3cd2b02013-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 Trieue8d41192013-01-31 01:44:26 +000010// CHECK: {{^}}VarDecl{{.*TestIndent[^()]*$}}
11// CHECK-NEXT: {{^}}`-UnusedAttr{{[^()]*$}}
Alexander Kornienkoc3cd2b02013-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
32// CHECK-NEXT: AlignedAttr
33// CHECK-NEXT: <<<NULL>>>
34
35int TestAlignedExpr __attribute__((aligned(4)));
36// CHECK: VarDecl{{.*}}TestAlignedExpr
37// CHECK-NEXT: AlignedAttr
38// 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
66// CHECK: ArgumentWithTypeTagAttr{{.*}} ident1
67
68void TestBool(void *, int)
69__attribute__((pointer_with_type_tag(bool1,1,2)));
70// CHECK: FunctionDecl{{.*}}TestBool
71// CHECK: ArgumentWithTypeTagAttr{{.*}} IsPointer
72
73void TestUnsigned(void *, int)
74__attribute__((pointer_with_type_tag(unsigned1,1,2)));
75// CHECK: FunctionDecl{{.*}}TestUnsigned
76// CHECK: ArgumentWithTypeTagAttr{{.*}} 0 1
77
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
91void *TestVariadicUnsigned1(int) __attribute__((alloc_size(1)));
92// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned1
93// CHECK: AllocSizeAttr{{.*}} 0
94
95void *TestVariadicUnsigned2(int, int) __attribute__((alloc_size(1,2)));
96// CHECK: FunctionDecl{{.*}}TestVariadicUnsigned2
97// CHECK: AllocSizeAttr{{.*}} 0 1