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