Skip to content

Commit 0d5fc82

Browse files
committed
[lldb] Eliminate unneeded value parameters in Utility (NFC)
Eliminates value parameter for types that are not trivially copyable.
1 parent 8b56b03 commit 0d5fc82

File tree

17 files changed

+49
-43
lines changed

17 files changed

+49
-43
lines changed

lldb/include/lldb/Utility/ArchSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class ArchSpec {
505505

506506
void SetFlags(uint32_t flags) { m_flags = flags; }
507507

508-
void SetFlags(std::string elf_abi);
508+
void SetFlags(const std::string &elf_abi);
509509

510510
protected:
511511
bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const;

lldb/include/lldb/Utility/Broadcaster.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace lldb_private {
3939
/// Debugger maintains a list of BroadcastEventSpec's and when it is made
4040
class BroadcastEventSpec {
4141
public:
42-
BroadcastEventSpec(ConstString broadcaster_class, uint32_t event_bits)
42+
BroadcastEventSpec(const ConstString &broadcaster_class, uint32_t event_bits)
4343
: m_broadcaster_class(broadcaster_class), m_event_bits(event_bits) {}
4444

4545
~BroadcastEventSpec() = default;
@@ -117,7 +117,7 @@ class BroadcasterManager
117117

118118
class BroadcasterClassMatches {
119119
public:
120-
BroadcasterClassMatches(ConstString broadcaster_class)
120+
BroadcasterClassMatches(const ConstString &broadcaster_class)
121121
: m_broadcaster_class(broadcaster_class) {}
122122

123123
~BroadcasterClassMatches() = default;

lldb/include/lldb/Utility/ConstString.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ConstString {
133133
///
134134
/// \return
135135
/// A const reference to this object.
136-
ConstString operator=(ConstString rhs) {
136+
ConstString operator=(const ConstString &rhs) {
137137
m_string = rhs.m_string;
138138
return *this;
139139
}
@@ -150,7 +150,7 @@ class ConstString {
150150
/// \return
151151
/// true if this object is equal to \a rhs.
152152
/// false if this object is not equal to \a rhs.
153-
bool operator==(ConstString rhs) const {
153+
bool operator==(const ConstString &rhs) const {
154154
// We can do a pointer compare to compare these strings since they must
155155
// come from the same pool in order to be equal.
156156
return m_string == rhs.m_string;
@@ -192,7 +192,7 @@ class ConstString {
192192
/// \return
193193
/// \b true if this object is not equal to \a rhs.
194194
/// \b false if this object is equal to \a rhs.
195-
bool operator!=(ConstString rhs) const {
195+
bool operator!=(const ConstString &rhs) const {
196196
return m_string != rhs.m_string;
197197
}
198198

@@ -209,7 +209,7 @@ class ConstString {
209209
/// \return \b true if this object is not equal to \a rhs, false otherwise.
210210
bool operator!=(const char *rhs) const { return !(*this == rhs); }
211211

212-
bool operator<(ConstString rhs) const;
212+
bool operator<(const ConstString &rhs) const;
213213

214214
/// Get the string value as a C string.
215215
///
@@ -279,7 +279,7 @@ class ConstString {
279279
/// will be tested, otherwise character case will be ignored
280280
///
281281
/// \return \b true if this object is equal to \a rhs, \b false otherwise.
282-
static bool Equals(ConstString lhs, ConstString rhs,
282+
static bool Equals(const ConstString &lhs, const ConstString &rhs,
283283
const bool case_sensitive = true);
284284

285285
/// Compare two string objects.
@@ -303,7 +303,7 @@ class ConstString {
303303
/// will be performed, otherwise character case will be ignored
304304
///
305305
/// \return -1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs
306-
static int Compare(ConstString lhs, ConstString rhs,
306+
static int Compare(const ConstString &lhs, const ConstString &rhs,
307307
const bool case_sensitive = true);
308308

309309
/// Dump the object description to a stream.
@@ -371,7 +371,7 @@ class ConstString {
371371
/// The already uniqued mangled ConstString to correlate the
372372
/// soon to be uniqued version of \a demangled.
373373
void SetStringWithMangledCounterpart(llvm::StringRef demangled,
374-
ConstString mangled);
374+
const ConstString &mangled);
375375

376376
/// Retrieve the mangled or demangled counterpart for a mangled or demangled
377377
/// ConstString.
@@ -452,7 +452,7 @@ class ConstString {
452452
};
453453

454454
/// Stream the string value \a str to the stream \a s
455-
Stream &operator<<(Stream &s, ConstString str);
455+
Stream &operator<<(Stream &s, const ConstString &str);
456456

457457
} // namespace lldb_private
458458

@@ -473,11 +473,11 @@ template <> struct DenseMapInfo<lldb_private::ConstString> {
473473
return lldb_private::ConstString::FromStringPoolPointer(
474474
DenseMapInfo<const char *>::getTombstoneKey());
475475
}
476-
static unsigned getHashValue(lldb_private::ConstString val) {
476+
static unsigned getHashValue(const lldb_private::ConstString &val) {
477477
return DenseMapInfo<const char *>::getHashValue(val.m_string);
478478
}
479-
static bool isEqual(lldb_private::ConstString LHS,
480-
lldb_private::ConstString RHS) {
479+
static bool isEqual(const lldb_private::ConstString &LHS,
480+
const lldb_private::ConstString &RHS) {
481481
return LHS == RHS;
482482
}
483483
};
@@ -491,7 +491,8 @@ template <> struct ScalarTraits<lldb_private::ConstString> {
491491
};
492492
} // namespace yaml
493493

494-
inline raw_ostream &operator<<(raw_ostream &os, lldb_private::ConstString s) {
494+
inline raw_ostream &operator<<(raw_ostream &os,
495+
const lldb_private::ConstString &s) {
495496
os << s.GetStringRef();
496497
return os;
497498
}

lldb/include/lldb/Utility/RegisterValue.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/StringRef.h"
1919
#include <cstdint>
2020
#include <cstring>
21+
#include <utility>
2122

2223
namespace lldb_private {
2324
class DataExtractor;
@@ -60,7 +61,7 @@ class RegisterValue {
6061
}
6162

6263
explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) {
63-
m_scalar = llvm::APInt(inst);
64+
m_scalar = llvm::APInt(std::move(inst));
6465
}
6566

6667
explicit RegisterValue(float value) : m_type(eTypeFloat) { m_scalar = value; }
@@ -169,7 +170,7 @@ class RegisterValue {
169170

170171
void operator=(llvm::APInt uint) {
171172
m_type = eTypeUInt128;
172-
m_scalar = llvm::APInt(uint);
173+
m_scalar = llvm::APInt(std::move(uint));
173174
}
174175

175176
void operator=(float f) {
@@ -209,7 +210,7 @@ class RegisterValue {
209210

210211
void SetUInt128(llvm::APInt uint) {
211212
m_type = eTypeUInt128;
212-
m_scalar = uint;
213+
m_scalar = std::move(uint);
213214
}
214215

215216
bool SetUInt(uint64_t uint, uint32_t byte_size);

lldb/include/lldb/Utility/Reproducer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <mutex>
2020
#include <string>
21+
#include <utility>
2122
#include <vector>
2223

2324
namespace lldb_private {
@@ -435,7 +436,7 @@ class Reproducer {
435436
/// return the path to the files in the index.
436437
template <typename T> class MultiLoader {
437438
public:
438-
MultiLoader(std::vector<std::string> files) : m_files(files) {}
439+
MultiLoader(std::vector<std::string> files) : m_files(std::move(files)) {}
439440

440441
static std::unique_ptr<MultiLoader> Create(Loader *loader) {
441442
if (!loader)

lldb/include/lldb/Utility/Scalar.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
#ifndef LLDB_UTILITY_SCALAR_H
1010
#define LLDB_UTILITY_SCALAR_H
1111

12+
#include "lldb/Utility/LLDBAssert.h"
1213
#include "lldb/Utility/Status.h"
1314
#include "lldb/lldb-enumerations.h"
1415
#include "lldb/lldb-private-types.h"
15-
#include "lldb/Utility/LLDBAssert.h"
1616
#include "llvm/ADT/APFloat.h"
1717
#include "llvm/ADT/APInt.h"
1818
#include <cstddef>
1919
#include <cstdint>
20+
#include <utility>
2021

2122
namespace lldb_private {
2223
class DataExtractor;
@@ -89,7 +90,7 @@ class Scalar {
8990
llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
9091
(reinterpret_cast<type128 *>(&v))->x)) {}
9192
Scalar(llvm::APInt v) : m_type(), m_float(static_cast<float>(0)) {
92-
m_integer = llvm::APInt(v);
93+
m_integer = llvm::APInt(std::move(v));
9394
m_type = GetBestTypeForBitSize(m_integer.getBitWidth(), true);
9495
}
9596
// Scalar(const RegisterValue& reg_value);

lldb/include/lldb/Utility/StringList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class StringList {
102102

103103
StringList &operator<<(const std::string &s);
104104

105-
StringList &operator<<(StringList strings);
105+
StringList &operator<<(const StringList &strings);
106106

107107
// Copy assignment for a vector of strings
108108
StringList &operator=(const std::vector<std::string> &rhs);

lldb/include/lldb/Utility/StructuredData.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ class StructuredData {
271271
return false;
272272
}
273273

274-
void Push(ObjectSP item) { m_items.push_back(item); }
274+
void Push(const ObjectSP &item) { m_items.push_back(item); }
275275

276-
void AddItem(ObjectSP item) { m_items.push_back(item); }
276+
void AddItem(const ObjectSP &item) { m_items.push_back(item); }
277277

278278
void Serialize(llvm::json::OStream &s) const override;
279279

@@ -493,7 +493,7 @@ class StructuredData {
493493

494494
void AddItem(llvm::StringRef key, ObjectSP value_sp) {
495495
ConstString key_cs(key);
496-
m_dict[key_cs] = value_sp;
496+
m_dict[key_cs] = std::move(value_sp);
497497
}
498498

499499
void AddIntegerItem(llvm::StringRef key, uint64_t value) {
@@ -547,7 +547,7 @@ class StructuredData {
547547
void *m_object;
548548
};
549549

550-
static ObjectSP ParseJSON(std::string json_text);
550+
static ObjectSP ParseJSON(const std::string &json_text);
551551
static ObjectSP ParseJSONFromFile(const FileSpec &file, Status &error);
552552
};
553553

lldb/include/lldb/Utility/XcodeSDK.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ class XcodeSDK {
6565
/// The merge function follows a strict order to maintain monotonicity:
6666
/// 1. SDK with the higher SDKType wins.
6767
/// 2. The newer SDK wins.
68-
void Merge(XcodeSDK other);
68+
void Merge(const XcodeSDK &other);
6969

70-
XcodeSDK &operator=(XcodeSDK other);
70+
XcodeSDK &operator=(const XcodeSDK &other);
7171
XcodeSDK(const XcodeSDK&) = default;
72-
bool operator==(XcodeSDK other);
72+
bool operator==(const XcodeSDK &other);
7373

7474
/// Return parsed SDK type and version number.
7575
Info Parse() const;

lldb/source/Utility/ArchSpec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ std::string ArchSpec::GetTargetABI() const {
613613
return abi;
614614
}
615615

616-
void ArchSpec::SetFlags(std::string elf_abi) {
616+
void ArchSpec::SetFlags(const std::string &elf_abi) {
617617

618618
uint32_t flag = GetFlags();
619619
if (IsMIPS()) {

0 commit comments

Comments
 (0)