Commit c9ec5793 by Jan Voung

Convert a few getName() methods to return a const string ref.

Followup to a previous code review. Saves 2KB from the minimal build =) BUG=none R=stichnot@chromium.org Review URL: https://codereview.chromium.org/904783002
parent 7ad1bed9
...@@ -541,7 +541,7 @@ void ELFObjectWriter::writeAllRelocationSections(bool IsELF64) { ...@@ -541,7 +541,7 @@ void ELFObjectWriter::writeAllRelocationSections(bool IsELF64) {
void ELFObjectWriter::setUndefinedSyms(const ConstantList &UndefSyms) { void ELFObjectWriter::setUndefinedSyms(const ConstantList &UndefSyms) {
for (const Constant *S : UndefSyms) { for (const Constant *S : UndefSyms) {
const auto Sym = llvm::cast<ConstantRelocatable>(S); const auto Sym = llvm::cast<ConstantRelocatable>(S);
IceString Name = Sym->getName(); const IceString &Name = Sym->getName();
assert(Sym->getOffset() == 0); assert(Sym->getOffset() == 0);
assert(Sym->getSuppressMangling()); assert(Sym->getSuppressMangling());
SymTab->noteUndefinedSym(Name, NullSection); SymTab->noteUndefinedSym(Name, NullSection);
......
...@@ -66,7 +66,7 @@ public: ...@@ -66,7 +66,7 @@ public:
void setNameStrIndex(Elf64_Word sh_name) { Header.sh_name = sh_name; } void setNameStrIndex(Elf64_Word sh_name) { Header.sh_name = sh_name; }
IceString getName() const { return Name; } const IceString &getName() const { return Name; }
void setLinkNum(Elf64_Word sh_link) { Header.sh_link = sh_link; } void setLinkNum(Elf64_Word sh_link) { Header.sh_link = sh_link; }
...@@ -84,7 +84,7 @@ protected: ...@@ -84,7 +84,7 @@ protected:
// Name of the section in convenient string form (instead of a index // Name of the section in convenient string form (instead of a index
// into the Section Header String Table, which is not known till later). // into the Section Header String Table, which is not known till later).
IceString Name; const IceString Name;
// The fields of the header. May only be partially initialized, but should // The fields of the header. May only be partially initialized, but should
// be fully initialized before writing. // be fully initialized before writing.
......
...@@ -223,7 +223,7 @@ public: ...@@ -223,7 +223,7 @@ public:
} }
RelocOffsetT getOffset() const { return Offset; } RelocOffsetT getOffset() const { return Offset; }
IceString getName() const { return Name; } const IceString &getName() const { return Name; }
void setSuppressMangling(bool Value) { SuppressMangling = Value; } void setSuppressMangling(bool Value) { SuppressMangling = Value; }
bool getSuppressMangling() const { return SuppressMangling; } bool getSuppressMangling() const { return SuppressMangling; }
using Constant::emit; using Constant::emit;
......
...@@ -294,7 +294,7 @@ public: ...@@ -294,7 +294,7 @@ public:
const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl); const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl);
IsUndefined = !Var->hasInitializer(); IsUndefined = !Var->hasInitializer();
} }
std::string Name; Ice::IceString Name;
bool SuppressMangling; bool SuppressMangling;
if (Decl) { if (Decl) {
Name = Decl->getName(); Name = Decl->getName();
...@@ -1508,7 +1508,7 @@ private: ...@@ -1508,7 +1508,7 @@ private:
} }
// Returns true if the Str begins with Prefix. // Returns true if the Str begins with Prefix.
bool isStringPrefix(Ice::IceString &Str, Ice::IceString &Prefix) { bool isStringPrefix(const Ice::IceString &Str, const Ice::IceString &Prefix) {
const size_t PrefixSize = Prefix.size(); const size_t PrefixSize = Prefix.size();
if (Str.size() < PrefixSize) if (Str.size() < PrefixSize)
return false; return false;
...@@ -2446,7 +2446,7 @@ void FunctionParser::ProcessRecord() { ...@@ -2446,7 +2446,7 @@ void FunctionParser::ProcessRecord() {
// Check if this direct call is to an Intrinsic (starts with "llvm.") // Check if this direct call is to an Intrinsic (starts with "llvm.")
static Ice::IceString LLVMPrefix("llvm."); static Ice::IceString LLVMPrefix("llvm.");
Ice::IceString Name = Fcn->getName(); const Ice::IceString &Name = Fcn->getName();
if (isStringPrefix(Name, LLVMPrefix)) { if (isStringPrefix(Name, LLVMPrefix)) {
Ice::IceString Suffix = Name.substr(LLVMPrefix.size()); Ice::IceString Suffix = Name.substr(LLVMPrefix.size());
IntrinsicInfo = IntrinsicInfo =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment