[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg158.cpp
blob9301c790297e9d890735b2bf9301de74b5dcc140
1 // RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
3 // RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
4 // RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s
6 // cwg158: yes
8 // CHECK-LABEL: define {{.*}} @_Z1f
9 const int *f(const int * const *p, int **q) {
10 // CHECK: load ptr, {{.*}}, !tbaa ![[INTPTR_TBAA:[^,]*]]
11 const int *x = *p;
12 // CHECK: store ptr null, {{.*}}, !tbaa ![[INTPTR_TBAA]]
13 *q = 0;
14 return x;
17 struct A {};
19 // CHECK-LABEL: define {{.*}} @_Z1g
20 const int *(A::*const *g(const int *(A::* const **p)[3], int *(A::***q)[3]))[3] {
21 // CHECK: load ptr, {{.*}}, !tbaa ![[MEMPTR_TBAA:[^,]*]]
22 const int *(A::*const *x)[3] = *p;
23 // CHECK: store ptr null, {{.*}}, !tbaa ![[MEMPTR_TBAA]]
24 *q = 0;
25 return x;