[Remarks] String tables should be move-only
Copying them is expensive. This allows the tables to be moved around at
lower cost, and allows a remarks::StringTable to be constructed from
a remarks::ParsedStringTable.
llvm-svn: 366864
diff --git a/llvm/lib/Remarks/RemarkParser.cpp b/llvm/lib/Remarks/RemarkParser.cpp
index 96a4b42..ac46ae3 100644
--- a/llvm/lib/Remarks/RemarkParser.cpp
+++ b/llvm/lib/Remarks/RemarkParser.cpp
@@ -64,14 +64,14 @@
Expected<std::unique_ptr<Parser>>
llvm::remarks::createRemarkParser(Format ParserFormat, StringRef Buf,
- const ParsedStringTable &StrTab) {
+ ParsedStringTable StrTab) {
switch (ParserFormat) {
case Format::YAML:
return createStringError(std::make_error_code(std::errc::invalid_argument),
"The YAML format can't be used with a string "
"table. Use yaml-strtab instead.");
case Format::YAMLStrTab:
- return llvm::make_unique<YAMLStrTabRemarkParser>(Buf, StrTab);
+ return llvm::make_unique<YAMLStrTabRemarkParser>(Buf, std::move(StrTab));
case Format::Unknown:
return createStringError(std::make_error_code(std::errc::invalid_argument),
"Unknown remark parser format.");
@@ -84,10 +84,10 @@
Optional<std::string> Err;
CParser(Format ParserFormat, StringRef Buf,
- Optional<const ParsedStringTable *> StrTab = None)
- : TheParser(cantFail(StrTab
- ? createRemarkParser(ParserFormat, Buf, **StrTab)
- : createRemarkParser(ParserFormat, Buf))) {}
+ Optional<ParsedStringTable> StrTab = None)
+ : TheParser(cantFail(
+ StrTab ? createRemarkParser(ParserFormat, Buf, std::move(*StrTab))
+ : createRemarkParser(ParserFormat, Buf))) {}
void handleError(Error E) { Err.emplace(toString(std::move(E))); }
bool hasError() const { return Err.hasValue(); }