[lld] r326337 - [WebAssembly] Return a StringRef instead of std::string from getSectionName(). NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 09:33:04 PST 2018
Author: ruiu
Date: Wed Feb 28 09:33:04 2018
New Revision: 326337
URL: http://llvm.org/viewvc/llvm-project?rev=326337&view=rev
Log:
[WebAssembly] Return a StringRef instead of std::string from getSectionName(). NFC.
Differential Revision: https://reviews.llvm.org/D43854
Modified:
lld/trunk/wasm/OutputSections.cpp
lld/trunk/wasm/OutputSections.h
Modified: lld/trunk/wasm/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/OutputSections.cpp?rev=326337&r1=326336&r2=326337&view=diff
==============================================================================
--- lld/trunk/wasm/OutputSections.cpp (original)
+++ lld/trunk/wasm/OutputSections.cpp Wed Feb 28 09:33:04 2018
@@ -55,20 +55,20 @@ static StringRef sectionTypeToString(uin
}
}
-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();
Modified: lld/trunk/wasm/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/OutputSections.h?rev=326337&r1=326336&r2=326337&view=diff
==============================================================================
--- lld/trunk/wasm/OutputSections.h (original)
+++ lld/trunk/wasm/OutputSections.h Wed Feb 28 09:33:04 2018
@@ -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;
More information about the llvm-commits
mailing list