Skip to content

[clang] Add some CodeGen tests for CWG 1xx issues #80338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions clang/test/CXX/drs/dr185.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

namespace dr185 { // dr185: 2.7
struct A {
mutable int value;
explicit A(int i) : value(i) {}
void mutate(int i) const { value = i; }
};

int foo() {
A const& t = A(1);
A n(t);
t.mutate(2);
return n.value;
}

// CHECK-LABEL: define {{.*}} i32 @dr185::foo()
// CHECK: call void @dr185::A::A(int)(ptr {{[^,]*}} %ref.tmp, {{.*}})
// CHECK: store ptr %ref.tmp, ptr %t
// CHECK-NOT: %t =
// CHECK: [[DR185_T:%.+]] = load ptr, ptr %t
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{[^,]*}} %n, ptr {{[^,]*}} [[DR185_T]], {{.*}})
// CHECK-LABEL: }
} // namespace dr185
46 changes: 46 additions & 0 deletions clang/test/CXX/drs/dr193.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

#if __cplusplus == 199711L
#define NOTHROW throw()
#else
#define NOTHROW noexcept(true)
#endif

namespace dr193 { // dr193: 2.7
struct A {
~A() NOTHROW {}
};

struct B {
~B() NOTHROW {}
};

struct C {
~C() NOTHROW {}
};

struct D : A {
B b;
~D() NOTHROW { C c; }
};

void foo() {
D d;
}

// skipping over D1 (complete object destructor)
// CHECK-LABEL: define {{.*}} void @dr193::D::~D(){{.*}}
// CHECK-LABEL: define {{.*}} void @dr193::D::~D(){{.*}}
// CHECK-NOT: call void @dr193::A::~A()
// CHECK-NOT: call void @dr193::B::~B()
// CHECK: call void @dr193::C::~C()
// CHECK: call void @dr193::B::~B()
// CHECK: call void @dr193::A::~A()
// CHECK-LABEL: }
} // namespace dr193
33 changes: 33 additions & 0 deletions clang/test/CXX/drs/dr199.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK

#if __cplusplus == 199711L
#define NOTHROW throw()
#else
#define NOTHROW noexcept(true)
#endif

namespace dr199 { // dr199: 2.8
struct A {
~A() NOTHROW {}
};

struct B {
~B() NOTHROW {}
};

void foo() {
A(), B();
}

// CHECK-LABEL: define {{.*}} void @dr199::foo()
// CHECK-NOT: call void @dr199::A::~A()
// CHECK: call void @dr199::B::~B()
// CHECK: call void @dr199::A::~A()
// CHECK-LABEL: }
} // namespace dr199
7 changes: 4 additions & 3 deletions clang/test/CXX/drs/dr1xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ namespace dr184 { // dr184: yes
void h() { A<B>().g(); }
}

// dr185 FIXME: add codegen test
// dr185 is in dr185.cpp

namespace dr187 { // dr187: sup 481
const int Z = 1;
Expand All @@ -1184,6 +1184,7 @@ namespace dr188 { // dr188: yes
}

// dr190 FIXME: add codegen test for tbaa
// or implement C++20 std::is_layout_compatible and test it this way

int dr191_j;
namespace dr191 { // dr191: yes
Expand Down Expand Up @@ -1215,7 +1216,7 @@ namespace dr191 { // dr191: yes
}
}

// dr193 FIXME: add codegen test
// dr193 is in dr193.cpp

namespace dr194 { // dr194: yes
struct A {
Expand Down Expand Up @@ -1290,4 +1291,4 @@ namespace dr198 { // dr198: yes
};
}

// dr199 FIXME: add codegen test
// dr199 is in dr199.cpp
6 changes: 3 additions & 3 deletions clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/185.html">185</a></td>
<td>TC1</td>
<td>"Named" temporaries and copy elision</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr class="open" id="186">
<td><a href="https://cplusplus.github.io/CWG/issues/186.html">186</a></td>
Expand Down Expand Up @@ -1196,7 +1196,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/193.html">193</a></td>
<td>TC1</td>
<td>Order of destruction of local automatics of destructor</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.7</td>
</tr>
<tr id="194">
<td><a href="https://cplusplus.github.io/CWG/issues/194.html">194</a></td>
Expand Down Expand Up @@ -1232,7 +1232,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/199.html">199</a></td>
<td>CD1</td>
<td>Order of destruction of temporaries</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Clang 2.8</td>
</tr>
<tr id="200">
<td><a href="https://cplusplus.github.io/CWG/issues/200.html">200</a></td>
Expand Down