Skip to content

Commit d16e49e

Browse files
committed
Address some review comments.
1 parent 1bfc36e commit d16e49e

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

clang/test/CXX/drs/cwg0xx.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,7 @@ namespace cwg5 { // cwg5: 3.1
9090
const C c = e;
9191
} // namespace cwg5
9292

93-
namespace cwg6 { // cwg6 codegen is tested in cwg6.cpp
94-
#if __cplusplus >= 201103L
95-
struct Counter {
96-
int copies;
97-
constexpr Counter(int copies) : copies(copies) {}
98-
constexpr Counter(const Counter& other) : copies(other.copies + 1) {}
99-
};
100-
101-
// Passing an lvalue by value makes a non-elidable copy.
102-
constexpr int PassByValue(Counter c) { return c.copies; }
103-
constexpr int PassByValue2(Counter c) { return PassByValue(c); }
104-
constexpr int PassByValue3(Counter c) { return PassByValue2(c); }
105-
static_assert(PassByValue(Counter(0)) == 0, "expect no copies");
106-
static_assert(PassByValue2(Counter(0)) == 1, "expect 1 copy");
107-
static_assert(PassByValue3(Counter(0)) == 2, "expect 2 copies");
108-
#endif
109-
} // namespace cwg6
93+
// cwg6 is in cwg6.cpp
11094

11195
namespace cwg7 { // cwg7: 3.4
11296
class A { public: ~A(); };

clang/test/CXX/drs/cwg6.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,46 @@
66
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s --check-prefixes CHECK
77
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s --check-prefixes CHECK
88

9+
#if __cplusplus == 199711L
10+
#define static_assert(expr) __extension__ _Static_assert(expr)
11+
#define noexcept throw()
12+
#endif
13+
914
namespace cwg6 { // cwg6: yes
15+
#if __cplusplus >= 201103L
16+
struct Counter {
17+
int copies;
18+
constexpr Counter(int copies) : copies(copies) {}
19+
constexpr Counter(const Counter& other) : copies(other.copies + 1) {}
20+
};
21+
22+
// Passing an lvalue by value makes a non-elidable copy.
23+
constexpr int PassByValue(Counter c) { return c.copies; }
24+
constexpr int PassByValue2(Counter c) { return PassByValue(c); }
25+
constexpr int PassByValue3(Counter c) { return PassByValue2(c); }
26+
static_assert(PassByValue(Counter(0)) == 0, "expect no copies");
27+
static_assert(PassByValue2(Counter(0)) == 1, "expect 1 copy");
28+
static_assert(PassByValue3(Counter(0)) == 2, "expect 2 copies");
29+
#endif
1030

1131
struct A {
12-
A();
13-
A(const A&);
14-
~A();
32+
A() noexcept;
33+
A(const A&) noexcept;
34+
~A() noexcept;
1535
};
1636

17-
inline void f(A a) {}
37+
inline void f(A a) noexcept {}
1838

1939
// CHECK-LABEL: define {{.*}} @_ZN4cwg64callEv
2040
void call() {
2141
A a;
2242
// We copy the parameter here, even though object is not mutated by f and
2343
// otherwise satisfies the criteria for the proposed CWG6 optimization.
24-
// CHECK: {{call|invoke}} {{.*}} @_ZN4cwg61AC1ERKS0_
25-
// CHECK: {{call|invoke}} {{.*}} @_ZN4cwg61fE
44+
// CHECK: call {{.*}} @_ZN4cwg61AC1ERKS0_(
45+
// CHECK: call {{.*}} @_ZN4cwg61fENS_1AE(
2646
f(a);
27-
// CHECK: {{call|invoke}} {{.*}} @_ZN4cwg61AD1Ev
28-
// CHECK: {{call|invoke}} {{.*}} @_ZN4cwg61AD1Ev
47+
// CHECK: call {{.*}} @_ZN4cwg61AD1Ev(
48+
// CHECK: call {{.*}} @_ZN4cwg61AD1Ev(
2949
}
3050

3151
} // namespace cwg6

0 commit comments

Comments
 (0)