[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / AST / ast-dump-traits.cpp
blob99ad50f528eb796b1c35ebcae705680f19f633d9
1 // Test without serialization:
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s \
3 // RUN: | FileCheck -strict-whitespace %s
4 //
5 // Test with serialization:
6 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t %s
7 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -x c++ -include-pch %t -ast-dump-all /dev/null \
8 // RUN: | FileCheck -strict-whitespace %s
10 void test_type_trait() {
11 // An unary type trait.
12 enum E {};
13 (void) __is_enum(E);
14 // A binary type trait.
15 (void) __is_same(int ,float);
16 // An n-ary type trait.
17 (void) __is_constructible(int, int, int, int);
20 void test_array_type_trait() {
21 // An array type trait.
22 (void) __array_rank(int[10][20]);
25 void test_expression_trait() {
26 // An expression trait.
27 (void) __is_lvalue_expr(1);
30 void test_unary_expr_or_type_trait() {
31 // Some UETTs.
32 (void) sizeof(int);
33 (void) alignof(int);
34 (void) __alignof(int);
36 // CHECK: TranslationUnitDecl {{.*}} <<invalid sloc>> <invalid sloc>{{( <undeserialized declarations>)?}}
37 // CHECK: |-FunctionDecl {{.*}} <{{.*}}ast-dump-traits.cpp:10:1, line:18:1> line:10:6{{( imported)?}} test_type_trait 'void ()'
38 // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:24, line:18:1>
39 // CHECK-NEXT: | |-DeclStmt {{.*}} <line:12:3, col:12>
40 // CHECK-NEXT: | | `-EnumDecl {{.*}} <col:3, col:11> col:8{{( imported)?}} referenced E
41 // CHECK-NEXT: | |-CStyleCastExpr {{.*}} <line:13:3, col:21> 'void' <ToVoid>
42 // CHECK-NEXT: | | `-TypeTraitExpr {{.*}} <col:10, col:21> 'bool' __is_enum
43 // CHECK-NEXT: | |-CStyleCastExpr {{.*}} <line:15:3, col:30> 'void' <ToVoid>
44 // CHECK-NEXT: | | `-TypeTraitExpr {{.*}} <col:10, col:30> 'bool' __is_same
45 // CHECK-NEXT: | `-CStyleCastExpr {{.*}} <line:17:3, col:47> 'void' <ToVoid>
46 // CHECK-NEXT: | `-TypeTraitExpr {{.*}} <col:10, col:47> 'bool' __is_constructible
47 // CHECK-NEXT: |-FunctionDecl {{.*}} <line:20:1, line:23:1> line:20:6{{( imported)?}} test_array_type_trait 'void ()'
48 // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:30, line:23:1>
49 // CHECK-NEXT: | `-CStyleCastExpr {{.*}} <line:22:3, col:34> 'void' <ToVoid>
50 // CHECK-NEXT: | `-ArrayTypeTraitExpr {{.*}} <col:10, col:34> 'unsigned long' __array_rank
51 // CHECK-NEXT: |-FunctionDecl {{.*}} <line:25:1, line:28:1> line:25:6{{( imported)?}} test_expression_trait 'void ()'
52 // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:30, line:28:1>
53 // CHECK-NEXT: | `-CStyleCastExpr {{.*}} <line:27:3, col:28> 'void' <ToVoid>
54 // CHECK-NEXT: | `-ExpressionTraitExpr {{.*}} <col:10, col:28> 'bool' __is_lvalue_expr
55 // CHECK-NEXT: `-FunctionDecl {{.*}} <line:30:1, line:35:1> line:30:6{{( imported)?}} test_unary_expr_or_type_trait 'void ()'
56 // CHECK-NEXT: `-CompoundStmt {{.*}} <col:38, line:35:1>
57 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:32:3, col:20> 'void' <ToVoid>
58 // CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}} <col:10, col:20> 'unsigned long' sizeof 'int'
59 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:33:3, col:21> 'void' <ToVoid>
60 // CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}} <col:10, col:21> 'unsigned long' alignof 'int'
61 // CHECK-NEXT: `-CStyleCastExpr {{.*}} <line:34:3, col:23> 'void' <ToVoid>
62 // CHECK-NEXT: `-UnaryExprOrTypeTraitExpr {{.*}} <col:10, col:23> 'unsigned long' __alignof 'int'