Skip to content

Commit 205fd45

Browse files
[SYCL][NFC] Remove PropertyValue::copy() (#18945)
This commit removes the PropertyValue::copy() foot-gun. This function simply copies the values from one PropertyValue to the other, but for byte arrays, this means the caller of the copy need to ensure that the underlying memory isn't managed by both the original and the copy. Removing the function makes it clearer at the call-sites that this ownership relation has to be maintained explicitly. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
1 parent e122423 commit 205fd45

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

llvm/include/llvm/Support/PropertySetIO.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ class PropertyValue {
171171

172172
private:
173173
template <typename T> T &getValueRef();
174-
void copy(const PropertyValue &P);
175174

176175
Type Ty = NONE;
177176
// TODO: replace this union with std::variant when uplifting to C++17

llvm/lib/Support/PropertySetIO.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,27 +176,24 @@ PropertyValue::PropertyValue(const PropertyValue &P) { *this = P; }
176176
PropertyValue::PropertyValue(PropertyValue &&P) { *this = std::move(P); }
177177

178178
PropertyValue &PropertyValue::operator=(PropertyValue &&P) {
179-
copy(P);
180-
179+
Ty = P.Ty;
180+
Val = P.Val;
181181
if (P.getType() == BYTE_ARRAY)
182182
P.Val.ByteArrayVal = nullptr;
183183
P.Ty = NONE;
184184
return *this;
185185
}
186186

187187
PropertyValue &PropertyValue::operator=(const PropertyValue &P) {
188-
if (P.getType() == BYTE_ARRAY)
188+
if (P.getType() == BYTE_ARRAY) {
189189
*this = PropertyValue(P.asByteArray(), P.getByteArraySizeInBits());
190-
else
191-
copy(P);
190+
} else {
191+
Ty = P.Ty;
192+
Val = P.Val;
193+
}
192194
return *this;
193195
}
194196

195-
void PropertyValue::copy(const PropertyValue &P) {
196-
Ty = P.Ty;
197-
Val = P.Val;
198-
}
199-
200197
constexpr char PropertySetRegistry::SYCL_SPECIALIZATION_CONSTANTS[];
201198
constexpr char PropertySetRegistry::SYCL_DEVICELIB_REQ_MASK[];
202199
constexpr char PropertySetRegistry::SYCL_SPEC_CONSTANTS_DEFAULT_VALUES[];

0 commit comments

Comments
 (0)