[PATCH] D43854: [WebAssembly] Return a StringRef instead of std::string from getSectionName(). NFC.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 09:35:33 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD326337: [WebAssembly] Return a StringRef instead of std::string from getSectionName(). (authored by ruiu, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43854?vs=136218&id=136314#toc
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D43854
Files:
wasm/OutputSections.cpp
wasm/OutputSections.h
Index: wasm/OutputSections.h
===================================================================
--- wasm/OutputSections.h
+++ wasm/OutputSections.h
@@ -35,7 +35,7 @@
: 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;
Index: wasm/OutputSections.cpp
===================================================================
--- wasm/OutputSections.cpp
+++ wasm/OutputSections.cpp
@@ -55,20 +55,20 @@
}
}
-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();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43854.136314.patch
Type: text/x-patch
Size: 1522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180228/f5d02acd/attachment.bin>
More information about the llvm-commits
mailing list