[WebAssembly] Return a StringRef instead of std::string from getSectionName(). NFC.

Differential Revision: https://reviews.llvm.org/D43854

llvm-svn: 326337
This commit is contained in:
Rui Ueyama 2018-02-28 17:33:04 +00:00
parent ba16baccf1
commit 22c8f33a9b
2 changed files with 8 additions and 8 deletions

View File

@ -55,20 +55,20 @@ static StringRef sectionTypeToString(uint32_t SectionType) {
}
}
std::string lld::toString(const OutputSection &Section) {
std::string rtn = Section.getSectionName();
if (!Section.Name.empty())
rtn += "(" + Section.Name + ")";
return rtn;
// Returns a string, e.g. "FUNCTION(.text)".
std::string lld::toString(const OutputSection &Sec) {
if (!Sec.Name.empty())
return (Sec.getSectionName() + "(" + Sec.Name + ")").str();
return Sec.getSectionName();
}
std::string OutputSection::getSectionName() const {
StringRef OutputSection::getSectionName() const {
return sectionTypeToString(Type);
}
void OutputSection::createHeader(size_t BodySize) {
raw_string_ostream OS(Header);
debugWrite(OS.tell(), "section type [" + Twine(getSectionName()) + "]");
debugWrite(OS.tell(), "section type [" + getSectionName() + "]");
encodeULEB128(Type, OS);
writeUleb128(OS, BodySize, "section size");
OS.flush();

View File

@ -35,7 +35,7 @@ public:
: Type(Type), Name(Name) {}
virtual ~OutputSection() = default;
std::string getSectionName() const;
StringRef getSectionName() const;
void setOffset(size_t NewOffset) {
log("setOffset: " + toString(*this) + ": " + Twine(NewOffset));
Offset = NewOffset;