annotate clang/test/AST/ast-dump-traits.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 // Test without serialization:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // RUN: | FileCheck -strict-whitespace %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 //
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // Test with serialization:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -x c++ -include-pch %t -ast-dump-all /dev/null \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 // RUN: | FileCheck -strict-whitespace %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 void test_type_trait() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 // An unary type trait.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 enum E {};
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 (void) __is_enum(E);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 // A binary type trait.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 (void) __is_same(int ,float);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 // An n-ary type trait.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 (void) __is_constructible(int, int, int, int);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 void test_array_type_trait() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 // An array type trait.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 (void) __array_rank(int[10][20]);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 void test_expression_trait() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 // An expression trait.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 (void) __is_lvalue_expr(1);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 void test_unary_expr_or_type_trait() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 // Some UETTs.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 (void) sizeof(int);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 (void) alignof(int);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 (void) __alignof(int);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 // CHECK: TranslationUnitDecl {{.*}} <<invalid sloc>> <invalid sloc>{{( <undeserialized declarations>)?}}
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 // CHECK: |-FunctionDecl {{.*}} <{{.*}}ast-dump-traits.cpp:10:1, line:18:1> line:10:6{{( imported)?}} test_type_trait 'void ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:24, line:18:1>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 // CHECK-NEXT: | |-DeclStmt {{.*}} <line:12:3, col:12>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 // CHECK-NEXT: | | `-EnumDecl {{.*}} <col:3, col:11> col:8{{( imported)?}} referenced E
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 // CHECK-NEXT: | |-CStyleCastExpr {{.*}} <line:13:3, col:21> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 // CHECK-NEXT: | | `-TypeTraitExpr {{.*}} <col:10, col:21> 'bool' __is_enum
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 // CHECK-NEXT: | |-CStyleCastExpr {{.*}} <line:15:3, col:30> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 // CHECK-NEXT: | | `-TypeTraitExpr {{.*}} <col:10, col:30> 'bool' __is_same
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 // CHECK-NEXT: | `-CStyleCastExpr {{.*}} <line:17:3, col:47> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 // CHECK-NEXT: | `-TypeTraitExpr {{.*}} <col:10, col:47> 'bool' __is_constructible
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 // CHECK-NEXT: |-FunctionDecl {{.*}} <line:20:1, line:23:1> line:20:6{{( imported)?}} test_array_type_trait 'void ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:30, line:23:1>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 // CHECK-NEXT: | `-CStyleCastExpr {{.*}} <line:22:3, col:34> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 // CHECK-NEXT: | `-ArrayTypeTraitExpr {{.*}} <col:10, col:34> 'unsigned long' __array_rank
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 // CHECK-NEXT: |-FunctionDecl {{.*}} <line:25:1, line:28:1> line:25:6{{( imported)?}} test_expression_trait 'void ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 // CHECK-NEXT: | `-CompoundStmt {{.*}} <col:30, line:28:1>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 // CHECK-NEXT: | `-CStyleCastExpr {{.*}} <line:27:3, col:28> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 // CHECK-NEXT: | `-ExpressionTraitExpr {{.*}} <col:10, col:28> 'bool' __is_lvalue_expr
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 // CHECK-NEXT: `-FunctionDecl {{.*}} <line:30:1, line:35:1> line:30:6{{( imported)?}} test_unary_expr_or_type_trait 'void ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 // CHECK-NEXT: `-CompoundStmt {{.*}} <col:38, line:35:1>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:32:3, col:20> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 // CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}} <col:10, col:20> 'unsigned long' sizeof 'int'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:33:3, col:21> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 // CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}} <col:10, col:21> 'unsigned long' alignof 'int'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 // CHECK-NEXT: `-CStyleCastExpr {{.*}} <line:34:3, col:23> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 // CHECK-NEXT: `-UnaryExprOrTypeTraitExpr {{.*}} <col:10, col:23> 'unsigned long' __alignof 'int'