Skip to content

Commit e966a5d

Browse files
committed
[lldb] Remove Scalar operator= overloads
The are not needed as Scalar is implicitly constructible from all of these types (so the compiler will use a combination of a constructor + move assignment instead), and they make it very easy for implementations of assignment and construction operations to diverge.
1 parent f79e6a8 commit e966a5d

File tree

2 files changed

+0
-105
lines changed

2 files changed

+0
-105
lines changed

lldb/include/lldb/Utility/Scalar.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,6 @@ class Scalar {
153153
// automagically by the compiler, so no temporary objects will need to be
154154
// created. As a result, we currently don't need a variety of overloaded set
155155
// value accessors.
156-
Scalar &operator=(const int i);
157-
Scalar &operator=(unsigned int v);
158-
Scalar &operator=(long v);
159-
Scalar &operator=(unsigned long v);
160-
Scalar &operator=(long long v);
161-
Scalar &operator=(unsigned long long v);
162-
Scalar &operator=(float v);
163-
Scalar &operator=(double v);
164-
Scalar &operator=(long double v);
165-
Scalar &operator=(llvm::APInt v);
166156
Scalar &operator+=(const Scalar &rhs);
167157
Scalar &operator<<=(const Scalar &rhs); // Shift left
168158
Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic)

lldb/source/Utility/Scalar.cpp

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -305,101 +305,6 @@ const char *Scalar::GetTypeAsCString() const {
305305
return "<invalid Scalar type>";
306306
}
307307

308-
Scalar &Scalar::operator=(const int v) {
309-
m_type = e_sint;
310-
m_integer = llvm::APInt(sizeof(int) * 8, v, true);
311-
return *this;
312-
}
313-
314-
Scalar &Scalar::operator=(unsigned int v) {
315-
m_type = e_uint;
316-
m_integer = llvm::APInt(sizeof(int) * 8, v);
317-
return *this;
318-
}
319-
320-
Scalar &Scalar::operator=(long v) {
321-
m_type = e_slong;
322-
m_integer = llvm::APInt(sizeof(long) * 8, v, true);
323-
return *this;
324-
}
325-
326-
Scalar &Scalar::operator=(unsigned long v) {
327-
m_type = e_ulong;
328-
m_integer = llvm::APInt(sizeof(long) * 8, v);
329-
return *this;
330-
}
331-
332-
Scalar &Scalar::operator=(long long v) {
333-
m_type = e_slonglong;
334-
m_integer = llvm::APInt(sizeof(long long) * 8, v, true);
335-
return *this;
336-
}
337-
338-
Scalar &Scalar::operator=(unsigned long long v) {
339-
m_type = e_ulonglong;
340-
m_integer = llvm::APInt(sizeof(long long) * 8, v);
341-
return *this;
342-
}
343-
344-
Scalar &Scalar::operator=(float v) {
345-
m_type = e_float;
346-
m_float = llvm::APFloat(v);
347-
return *this;
348-
}
349-
350-
Scalar &Scalar::operator=(double v) {
351-
m_type = e_double;
352-
m_float = llvm::APFloat(v);
353-
return *this;
354-
}
355-
356-
Scalar &Scalar::operator=(long double v) {
357-
m_type = e_long_double;
358-
m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
359-
llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
360-
(reinterpret_cast<type128 *>(&v))->x));
361-
return *this;
362-
}
363-
364-
Scalar &Scalar::operator=(llvm::APInt rhs) {
365-
m_integer = llvm::APInt(rhs);
366-
switch (m_integer.getBitWidth()) {
367-
case 8:
368-
case 16:
369-
case 32:
370-
if (m_integer.isSignedIntN(sizeof(sint_t) * 8))
371-
m_type = e_sint;
372-
else
373-
m_type = e_uint;
374-
break;
375-
case 64:
376-
if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
377-
m_type = e_slonglong;
378-
else
379-
m_type = e_ulonglong;
380-
break;
381-
case 128:
382-
if (m_integer.isSignedIntN(BITWIDTH_INT128))
383-
m_type = e_sint128;
384-
else
385-
m_type = e_uint128;
386-
break;
387-
case 256:
388-
if (m_integer.isSignedIntN(BITWIDTH_INT256))
389-
m_type = e_sint256;
390-
else
391-
m_type = e_uint256;
392-
break;
393-
case 512:
394-
if (m_integer.isSignedIntN(BITWIDTH_INT512))
395-
m_type = e_sint512;
396-
else
397-
m_type = e_uint512;
398-
break;
399-
}
400-
return *this;
401-
}
402-
403308
Scalar::~Scalar() = default;
404309

405310
Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) {

0 commit comments

Comments
 (0)