77 lines · cpp
1// Test without serialization:2// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \3// RUN: -ast-dump %s -ast-dump-filter Test \4// RUN: | FileCheck --strict-whitespace --match-full-lines %s5//6// Test with serialization:7// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s8// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \9// RUN: -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \10// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \11// RUN: | FileCheck --strict-whitespace --match-full-lines %s12 13int i;14struct S {15 int i;16 int ii;17};18S s;19 20struct F {21 char padding[12];22 S s;23};24F f;25 26namespace std {27 class type_info;28}29 30struct P {31 int x;32};33struct Q {34 float m;35};36struct MP : P, Q {37 int i;38};39 40void Test(int (&arr)[10]) {41 constexpr int *pi = &i;42 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pi 'int *const' constexpr cinit43 // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=0, Path=()44 45 constexpr int *psi = &s.i;46 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psi 'int *const' constexpr cinit47 // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=0, HasPath=1, PathLength=1, Path=({{.*}})48 49 constexpr int *psii = &s.ii;50 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} psii 'int *const' constexpr cinit51 // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=4, HasPath=1, PathLength=1, Path=({{.*}})52 53 constexpr int *pf = &f.s.ii;54 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pf 'int *const' constexpr cinit55 // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=16, HasPath=1, PathLength=2, Path=({{.*}}, {{.*}})56 57 constexpr char *pc = &f.padding[2];58 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pc 'char *const' constexpr cinit59 // CHECK-NEXT: | |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=2, HasPath=1, PathLength=2, Path=({{.*}}, 2)60 61 constexpr const int *n = nullptr;62 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} n 'const int *const' constexpr cinit63 // CHECK-NEXT: | |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, PathLength=0, Path=()64 65 constexpr const std::type_info* pti = &typeid(int);66 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pti 'const std::type_info *const' constexpr cinit67 // CHECK-NEXT: | |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, HasPath=1, PathLength=0, Path=()68 69 constexpr int(MP::*pmi) = (int MP::*)&P::x;70 // CHECK: | `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pmi 'int (MP::*const)' constexpr cinit71 // CHECK-NEXT: | |-value: MemberPointer MP::x72 73 constexpr int(MP::*pmn) = (int MP::*)nullptr;74 // CHECK: `-VarDecl {{.*}} <col:{{.*}}, col:{{.*}}> col:{{.*}} pmn 'int (MP::*const)' constexpr cinit75 // CHECK-NEXT: |-value: MemberPointer null76}77