forked from OSchip/llvm-project
[lldb] Eliminate unneeded value parameters in Utility (NFC)
Eliminates value parameter for types that are not trivially copyable.
This commit is contained in:
parent
8b56b03f5a
commit
0d5fc82245
|
@ -505,7 +505,7 @@ public:
|
|||
|
||||
void SetFlags(uint32_t flags) { m_flags = flags; }
|
||||
|
||||
void SetFlags(std::string elf_abi);
|
||||
void SetFlags(const std::string &elf_abi);
|
||||
|
||||
protected:
|
||||
bool IsEqualTo(const ArchSpec &rhs, bool exact_match) const;
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace lldb_private {
|
|||
/// Debugger maintains a list of BroadcastEventSpec's and when it is made
|
||||
class BroadcastEventSpec {
|
||||
public:
|
||||
BroadcastEventSpec(ConstString broadcaster_class, uint32_t event_bits)
|
||||
BroadcastEventSpec(const ConstString &broadcaster_class, uint32_t event_bits)
|
||||
: m_broadcaster_class(broadcaster_class), m_event_bits(event_bits) {}
|
||||
|
||||
~BroadcastEventSpec() = default;
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
|
||||
class BroadcasterClassMatches {
|
||||
public:
|
||||
BroadcasterClassMatches(ConstString broadcaster_class)
|
||||
BroadcasterClassMatches(const ConstString &broadcaster_class)
|
||||
: m_broadcaster_class(broadcaster_class) {}
|
||||
|
||||
~BroadcasterClassMatches() = default;
|
||||
|
|
|
@ -133,7 +133,7 @@ public:
|
|||
///
|
||||
/// \return
|
||||
/// A const reference to this object.
|
||||
ConstString operator=(ConstString rhs) {
|
||||
ConstString operator=(const ConstString &rhs) {
|
||||
m_string = rhs.m_string;
|
||||
return *this;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public:
|
|||
/// \return
|
||||
/// true if this object is equal to \a rhs.
|
||||
/// false if this object is not equal to \a rhs.
|
||||
bool operator==(ConstString rhs) const {
|
||||
bool operator==(const ConstString &rhs) const {
|
||||
// We can do a pointer compare to compare these strings since they must
|
||||
// come from the same pool in order to be equal.
|
||||
return m_string == rhs.m_string;
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
/// \return
|
||||
/// \b true if this object is not equal to \a rhs.
|
||||
/// \b false if this object is equal to \a rhs.
|
||||
bool operator!=(ConstString rhs) const {
|
||||
bool operator!=(const ConstString &rhs) const {
|
||||
return m_string != rhs.m_string;
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ public:
|
|||
/// \return \b true if this object is not equal to \a rhs, false otherwise.
|
||||
bool operator!=(const char *rhs) const { return !(*this == rhs); }
|
||||
|
||||
bool operator<(ConstString rhs) const;
|
||||
bool operator<(const ConstString &rhs) const;
|
||||
|
||||
/// Get the string value as a C string.
|
||||
///
|
||||
|
@ -279,7 +279,7 @@ public:
|
|||
/// will be tested, otherwise character case will be ignored
|
||||
///
|
||||
/// \return \b true if this object is equal to \a rhs, \b false otherwise.
|
||||
static bool Equals(ConstString lhs, ConstString rhs,
|
||||
static bool Equals(const ConstString &lhs, const ConstString &rhs,
|
||||
const bool case_sensitive = true);
|
||||
|
||||
/// Compare two string objects.
|
||||
|
@ -303,7 +303,7 @@ public:
|
|||
/// will be performed, otherwise character case will be ignored
|
||||
///
|
||||
/// \return -1 if lhs < rhs, 0 if lhs == rhs, 1 if lhs > rhs
|
||||
static int Compare(ConstString lhs, ConstString rhs,
|
||||
static int Compare(const ConstString &lhs, const ConstString &rhs,
|
||||
const bool case_sensitive = true);
|
||||
|
||||
/// Dump the object description to a stream.
|
||||
|
@ -371,7 +371,7 @@ public:
|
|||
/// The already uniqued mangled ConstString to correlate the
|
||||
/// soon to be uniqued version of \a demangled.
|
||||
void SetStringWithMangledCounterpart(llvm::StringRef demangled,
|
||||
ConstString mangled);
|
||||
const ConstString &mangled);
|
||||
|
||||
/// Retrieve the mangled or demangled counterpart for a mangled or demangled
|
||||
/// ConstString.
|
||||
|
@ -452,7 +452,7 @@ protected:
|
|||
};
|
||||
|
||||
/// Stream the string value \a str to the stream \a s
|
||||
Stream &operator<<(Stream &s, ConstString str);
|
||||
Stream &operator<<(Stream &s, const ConstString &str);
|
||||
|
||||
} // namespace lldb_private
|
||||
|
||||
|
@ -473,11 +473,11 @@ template <> struct DenseMapInfo<lldb_private::ConstString> {
|
|||
return lldb_private::ConstString::FromStringPoolPointer(
|
||||
DenseMapInfo<const char *>::getTombstoneKey());
|
||||
}
|
||||
static unsigned getHashValue(lldb_private::ConstString val) {
|
||||
static unsigned getHashValue(const lldb_private::ConstString &val) {
|
||||
return DenseMapInfo<const char *>::getHashValue(val.m_string);
|
||||
}
|
||||
static bool isEqual(lldb_private::ConstString LHS,
|
||||
lldb_private::ConstString RHS) {
|
||||
static bool isEqual(const lldb_private::ConstString &LHS,
|
||||
const lldb_private::ConstString &RHS) {
|
||||
return LHS == RHS;
|
||||
}
|
||||
};
|
||||
|
@ -491,7 +491,8 @@ template <> struct ScalarTraits<lldb_private::ConstString> {
|
|||
};
|
||||
} // namespace yaml
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &os, lldb_private::ConstString s) {
|
||||
inline raw_ostream &operator<<(raw_ostream &os,
|
||||
const lldb_private::ConstString &s) {
|
||||
os << s.GetStringRef();
|
||||
return os;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "llvm/ADT/StringRef.h"
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <utility>
|
||||
|
||||
namespace lldb_private {
|
||||
class DataExtractor;
|
||||
|
@ -60,7 +61,7 @@ public:
|
|||
}
|
||||
|
||||
explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) {
|
||||
m_scalar = llvm::APInt(inst);
|
||||
m_scalar = llvm::APInt(std::move(inst));
|
||||
}
|
||||
|
||||
explicit RegisterValue(float value) : m_type(eTypeFloat) { m_scalar = value; }
|
||||
|
@ -169,7 +170,7 @@ public:
|
|||
|
||||
void operator=(llvm::APInt uint) {
|
||||
m_type = eTypeUInt128;
|
||||
m_scalar = llvm::APInt(uint);
|
||||
m_scalar = llvm::APInt(std::move(uint));
|
||||
}
|
||||
|
||||
void operator=(float f) {
|
||||
|
@ -209,7 +210,7 @@ public:
|
|||
|
||||
void SetUInt128(llvm::APInt uint) {
|
||||
m_type = eTypeUInt128;
|
||||
m_scalar = uint;
|
||||
m_scalar = std::move(uint);
|
||||
}
|
||||
|
||||
bool SetUInt(uint64_t uint, uint32_t byte_size);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace lldb_private {
|
||||
|
@ -435,7 +436,7 @@ private:
|
|||
/// return the path to the files in the index.
|
||||
template <typename T> class MultiLoader {
|
||||
public:
|
||||
MultiLoader(std::vector<std::string> files) : m_files(files) {}
|
||||
MultiLoader(std::vector<std::string> files) : m_files(std::move(files)) {}
|
||||
|
||||
static std::unique_ptr<MultiLoader> Create(Loader *loader) {
|
||||
if (!loader)
|
||||
|
|
|
@ -9,14 +9,15 @@
|
|||
#ifndef LLDB_UTILITY_SCALAR_H
|
||||
#define LLDB_UTILITY_SCALAR_H
|
||||
|
||||
#include "lldb/Utility/LLDBAssert.h"
|
||||
#include "lldb/Utility/Status.h"
|
||||
#include "lldb/lldb-enumerations.h"
|
||||
#include "lldb/lldb-private-types.h"
|
||||
#include "lldb/Utility/LLDBAssert.h"
|
||||
#include "llvm/ADT/APFloat.h"
|
||||
#include "llvm/ADT/APInt.h"
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
namespace lldb_private {
|
||||
class DataExtractor;
|
||||
|
@ -89,7 +90,7 @@ public:
|
|||
llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
|
||||
(reinterpret_cast<type128 *>(&v))->x)) {}
|
||||
Scalar(llvm::APInt v) : m_type(), m_float(static_cast<float>(0)) {
|
||||
m_integer = llvm::APInt(v);
|
||||
m_integer = llvm::APInt(std::move(v));
|
||||
m_type = GetBestTypeForBitSize(m_integer.getBitWidth(), true);
|
||||
}
|
||||
// Scalar(const RegisterValue& reg_value);
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
|
||||
StringList &operator<<(const std::string &s);
|
||||
|
||||
StringList &operator<<(StringList strings);
|
||||
StringList &operator<<(const StringList &strings);
|
||||
|
||||
// Copy assignment for a vector of strings
|
||||
StringList &operator=(const std::vector<std::string> &rhs);
|
||||
|
|
|
@ -271,9 +271,9 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
void Push(ObjectSP item) { m_items.push_back(item); }
|
||||
void Push(const ObjectSP &item) { m_items.push_back(item); }
|
||||
|
||||
void AddItem(ObjectSP item) { m_items.push_back(item); }
|
||||
void AddItem(const ObjectSP &item) { m_items.push_back(item); }
|
||||
|
||||
void Serialize(llvm::json::OStream &s) const override;
|
||||
|
||||
|
@ -493,7 +493,7 @@ public:
|
|||
|
||||
void AddItem(llvm::StringRef key, ObjectSP value_sp) {
|
||||
ConstString key_cs(key);
|
||||
m_dict[key_cs] = value_sp;
|
||||
m_dict[key_cs] = std::move(value_sp);
|
||||
}
|
||||
|
||||
void AddIntegerItem(llvm::StringRef key, uint64_t value) {
|
||||
|
@ -547,7 +547,7 @@ public:
|
|||
void *m_object;
|
||||
};
|
||||
|
||||
static ObjectSP ParseJSON(std::string json_text);
|
||||
static ObjectSP ParseJSON(const std::string &json_text);
|
||||
static ObjectSP ParseJSONFromFile(const FileSpec &file, Status &error);
|
||||
};
|
||||
|
||||
|
|
|
@ -65,11 +65,11 @@ public:
|
|||
/// The merge function follows a strict order to maintain monotonicity:
|
||||
/// 1. SDK with the higher SDKType wins.
|
||||
/// 2. The newer SDK wins.
|
||||
void Merge(XcodeSDK other);
|
||||
void Merge(const XcodeSDK &other);
|
||||
|
||||
XcodeSDK &operator=(XcodeSDK other);
|
||||
XcodeSDK &operator=(const XcodeSDK &other);
|
||||
XcodeSDK(const XcodeSDK&) = default;
|
||||
bool operator==(XcodeSDK other);
|
||||
bool operator==(const XcodeSDK &other);
|
||||
|
||||
/// Return parsed SDK type and version number.
|
||||
Info Parse() const;
|
||||
|
|
|
@ -613,7 +613,7 @@ std::string ArchSpec::GetTargetABI() const {
|
|||
return abi;
|
||||
}
|
||||
|
||||
void ArchSpec::SetFlags(std::string elf_abi) {
|
||||
void ArchSpec::SetFlags(const std::string &elf_abi) {
|
||||
|
||||
uint32_t flag = GetFlags();
|
||||
if (IsMIPS()) {
|
||||
|
|
|
@ -212,7 +212,7 @@ ConstString::ConstString(const char *cstr, size_t cstr_len)
|
|||
ConstString::ConstString(const llvm::StringRef &s)
|
||||
: m_string(StringPool().GetConstCStringWithStringRef(s)) {}
|
||||
|
||||
bool ConstString::operator<(ConstString rhs) const {
|
||||
bool ConstString::operator<(const ConstString &rhs) const {
|
||||
if (m_string == rhs.m_string)
|
||||
return false;
|
||||
|
||||
|
@ -227,7 +227,7 @@ bool ConstString::operator<(ConstString rhs) const {
|
|||
return lhs_string_ref.data() == nullptr;
|
||||
}
|
||||
|
||||
Stream &lldb_private::operator<<(Stream &s, ConstString str) {
|
||||
Stream &lldb_private::operator<<(Stream &s, const ConstString &str) {
|
||||
const char *cstr = str.GetCString();
|
||||
if (cstr != nullptr)
|
||||
s << cstr;
|
||||
|
@ -239,7 +239,7 @@ size_t ConstString::GetLength() const {
|
|||
return Pool::GetConstCStringLength(m_string);
|
||||
}
|
||||
|
||||
bool ConstString::Equals(ConstString lhs, ConstString rhs,
|
||||
bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs,
|
||||
const bool case_sensitive) {
|
||||
if (lhs.m_string == rhs.m_string)
|
||||
return true;
|
||||
|
@ -256,7 +256,7 @@ bool ConstString::Equals(ConstString lhs, ConstString rhs,
|
|||
return lhs_string_ref.equals_lower(rhs_string_ref);
|
||||
}
|
||||
|
||||
int ConstString::Compare(ConstString lhs, ConstString rhs,
|
||||
int ConstString::Compare(const ConstString &lhs, const ConstString &rhs,
|
||||
const bool case_sensitive) {
|
||||
// If the iterators are the same, this is the same string
|
||||
const char *lhs_cstr = lhs.m_string;
|
||||
|
@ -308,7 +308,7 @@ void ConstString::SetString(const llvm::StringRef &s) {
|
|||
}
|
||||
|
||||
void ConstString::SetStringWithMangledCounterpart(llvm::StringRef demangled,
|
||||
ConstString mangled) {
|
||||
const ConstString &mangled) {
|
||||
m_string = StringPool().GetConstCStringAndSetMangledCounterPart(
|
||||
demangled, mangled.m_string);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,7 @@ FileSpec Reproducer::GetReproducerPath() const {
|
|||
return {};
|
||||
}
|
||||
|
||||
static FileSpec MakeAbsolute(FileSpec file_spec) {
|
||||
static FileSpec MakeAbsolute(const FileSpec &file_spec) {
|
||||
SmallString<128> path;
|
||||
file_spec.GetPath(path, false);
|
||||
llvm::sys::fs::make_absolute(path);
|
||||
|
|
|
@ -160,7 +160,7 @@ bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const {
|
|||
void Scalar::GetBytes(llvm::MutableArrayRef<uint8_t> storage) const {
|
||||
assert(storage.size() >= GetByteSize());
|
||||
|
||||
const auto &store = [&](const llvm::APInt val) {
|
||||
const auto &store = [&](const llvm::APInt &val) {
|
||||
StoreIntToMemory(val, storage.data(), (val.getBitWidth() + 7) / 8);
|
||||
};
|
||||
switch (GetCategory(m_type)) {
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <utility>
|
||||
|
||||
using namespace lldb_private;
|
||||
|
||||
StringLexer::StringLexer(std::string s) : m_data(s), m_position(0) {}
|
||||
StringLexer::StringLexer(std::string s) : m_data(std::move(s)), m_position(0) {}
|
||||
|
||||
StringLexer::Character StringLexer::Peek() { return m_data[m_position]; }
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ StringList &StringList::operator<<(const std::string &str) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
StringList &StringList::operator<<(StringList strings) {
|
||||
StringList &StringList::operator<<(const StringList &strings) {
|
||||
AppendList(strings);
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ static StructuredData::ObjectSP ParseJSONValue(json::Value &value);
|
|||
static StructuredData::ObjectSP ParseJSONObject(json::Object *object);
|
||||
static StructuredData::ObjectSP ParseJSONArray(json::Array *array);
|
||||
|
||||
StructuredData::ObjectSP StructuredData::ParseJSON(std::string json_text) {
|
||||
StructuredData::ObjectSP
|
||||
StructuredData::ParseJSON(const std::string &json_text) {
|
||||
llvm::Expected<json::Value> value = json::parse(json_text);
|
||||
if (!value) {
|
||||
llvm::consumeError(value.takeError());
|
||||
|
|
|
@ -54,12 +54,12 @@ XcodeSDK::XcodeSDK(XcodeSDK::Info info) : m_name(GetName(info.type).str()) {
|
|||
}
|
||||
}
|
||||
|
||||
XcodeSDK &XcodeSDK::operator=(XcodeSDK other) {
|
||||
XcodeSDK &XcodeSDK::operator=(const XcodeSDK &other) {
|
||||
m_name = other.m_name;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool XcodeSDK::operator==(XcodeSDK other) {
|
||||
bool XcodeSDK::operator==(const XcodeSDK &other) {
|
||||
return m_name == other.m_name;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ bool XcodeSDK::Info::operator==(const Info &other) const {
|
|||
std::tie(other.type, other.version, other.internal);
|
||||
}
|
||||
|
||||
void XcodeSDK::Merge(XcodeSDK other) {
|
||||
void XcodeSDK::Merge(const XcodeSDK &other) {
|
||||
// The "bigger" SDK always wins.
|
||||
auto l = Parse();
|
||||
auto r = other.Parse();
|
||||
|
|
Loading…
Reference in New Issue