[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / GH41441.cpp
blob7a6260fef91b568f130f3bef08612a46ed9d6f29
1 // RUN: %clang --target=x86_64-pc-linux -S -fno-discard-value-names -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 %s -fsyntax-only -verify
4 namespace std {
5 using size_t = decltype(sizeof(int));
6 };
7 void* operator new[](std::size_t, void*) noexcept;
9 // CHECK: call void @llvm.memset.p0.i64(ptr align 1 %x, i8 0, i64 8, i1 false)
10 // CHECK: call void @llvm.memset.p0.i64(ptr align 16 %x, i8 0, i64 32, i1 false)
11 template <typename TYPE>
12 void f()
14 typedef TYPE TArray[8];
16 TArray x;
17 new(&x) TArray();
20 template <typename T>
21 void f1() {
22 int (*x)[1] = new int[1][1];
24 template void f1<char>();
25 void f2() {
26 int (*x)[1] = new int[1][1];
29 int main()
31 f<char>();
32 f<int>();
35 // expected-no-diagnostics
36 template <typename T> struct unique_ptr {unique_ptr(T* p){}};
38 template <typename T>
39 unique_ptr<T> make_unique(unsigned long long n) {
40 return unique_ptr<T>(new T[n]());
43 auto boro(int n){
44 typedef double HistoryBuffer[4];
45 return make_unique<HistoryBuffer>(n);