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

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents
children c4bab56944e8
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 -std=c++20 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter Test %s \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // RUN: | FileCheck --strict-whitespace --match-full-lines %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 -std=c++20 -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 -x c++ -std=c++20 -triple x86_64-unknown-unknown -include-pch %t \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 // RUN: -ast-dump-all -ast-dump-filter Test /dev/null \
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 // FIXME: ASTRecordReader::readAPValue and ASTRecordWriter::AddAPValue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 // just give up on some APValue kinds! This *really* should be fixed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 struct array_holder {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 int i[2];
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 struct S {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 int i = 42;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 union U {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 int i = 42;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 float f;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 struct SU {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 S s[2];
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 U u[3];
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 consteval int test_Int() { return 42; }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 consteval float test_Float() { return 1.0f; }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 consteval _Complex int test_ComplexInt() { return 1+2i; }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 consteval _Complex float test_ComplexFloat() { return 1.2f+3.4fi; }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 consteval __int128 test_Int128() { return (__int128)0xFFFFFFFFFFFFFFFF + (__int128)1; }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 // FIXME: consteval array_holder test_Array() { return array_holder(); }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 // FIXME: consteval S test_Struct() { return S(); }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 // FIXME: consteval U test_Union() { return U(); }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 // FIXME: consteval SU test_SU() { return SU(); }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 void Test() {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 (void) test_Int();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 (void) test_Float();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 (void) test_ComplexInt();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 (void) test_ComplexFloat();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 (void) test_Int128();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 //(void) test_Array();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 //(void) test_Struct();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 //(void) test_Union();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 //(void) test_SU();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 // CHECK:Dumping Test:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 // CHECK-NEXT:FunctionDecl {{.*}} <{{.*}}ast-dump-constant-expr.cpp:42:1, line:52:1> line:42:6{{( imported)?}} Test 'void ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 // CHECK-NEXT:`-CompoundStmt {{.*}} <col:13, line:52:1>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:43:3, col:19> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 // CHECK-NEXT: | `-ConstantExpr {{.*}} <col:10, col:19> 'int'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 // CHECK-NEXT: | |-value: Int 42
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 // CHECK-NEXT: | `-CallExpr {{.*}} <col:10, col:19> 'int'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:10> 'int (*)()' <FunctionToPointerDecay>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:10> 'int ()' lvalue Function {{.*}} 'test_Int' 'int ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:44:3, col:21> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 // CHECK-NEXT: | `-ConstantExpr {{.*}} <col:10, col:21> 'float'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 // CHECK-NEXT: | |-value: Float 1.000000e+00
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 // CHECK-NEXT: | `-CallExpr {{.*}} <col:10, col:21> 'float'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:10> 'float (*)()' <FunctionToPointerDecay>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:10> 'float ()' lvalue Function {{.*}} 'test_Float' 'float ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:45:3, col:26> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 // CHECK-NEXT: | `-ConstantExpr {{.*}} <col:10, col:26> '_Complex int'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 // CHECK-NEXT: | |-value: ComplexInt 1 + 2i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 // CHECK-NEXT: | `-CallExpr {{.*}} <col:10, col:26> '_Complex int'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:10> '_Complex int (*)()' <FunctionToPointerDecay>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:10> '_Complex int ()' lvalue Function {{.*}} 'test_ComplexInt' '_Complex int ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 // CHECK-NEXT: |-CStyleCastExpr {{.*}} <line:46:3, col:28> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 // CHECK-NEXT: | `-ConstantExpr {{.*}} <col:10, col:28> '_Complex float'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 // CHECK-NEXT: | |-value: ComplexFloat 1.200000e+00 + 3.400000e+00i
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 // CHECK-NEXT: | `-CallExpr {{.*}} <col:10, col:28> '_Complex float'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} <col:10> '_Complex float (*)()' <FunctionToPointerDecay>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 // CHECK-NEXT: | `-DeclRefExpr {{.*}} <col:10> '_Complex float ()' lvalue Function {{.*}} 'test_ComplexFloat' '_Complex float ()'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 // CHECK-NEXT: `-CStyleCastExpr {{.*}} <line:47:3, col:22> 'void' <ToVoid>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 // CHECK-NEXT: `-ConstantExpr {{.*}} <col:10, col:22> '__int128'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 // CHECK-NEXT: |-value: Int 18446744073709551616
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 // CHECK-NEXT: `-CallExpr {{.*}} <col:10, col:22> '__int128'
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 // CHECK-NEXT: `-ImplicitCastExpr {{.*}} <col:10> '__int128 (*)()' <FunctionToPointerDecay>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 // CHECK-NEXT: `-DeclRefExpr {{.*}} <col:10> '__int128 ()' lvalue Function {{.*}} 'test_Int128' '__int128 ()'