llvm.org GIT mirror llvm / 5d1b2d3
Fix some C++ value / reference semantics issues. Some functions were taking Twine's not by const&, these are all fixed to take by const&. We also had a case where some functions were overloaded to accept by const& and &&. Now there is only one version which accepts by value and move's the value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315229 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 2 years ago
4 changed file(s) with 8 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
379379 writeInt(0);
380380 }
381381
382 Error ResourceFileWriter::handleError(Error &&Err, const RCResource *Res) {
382 Error ResourceFileWriter::handleError(Error Err, const RCResource *Res) {
383383 if (Err)
384384 return joinErrors(createError("Error in " + Res->getResourceTypeName() +
385385 " statement (ID " + Twine(Res->ResName) +
8787 } StringTableData;
8888
8989 private:
90 Error handleError(Error &&Err, const RCResource *Res);
90 Error handleError(Error Err, const RCResource *Res);
9191
9292 Error
9393 writeResource(const RCResource *Res,
2727 namespace llvm {
2828 namespace rc {
2929
30 RCParser::ParserError::ParserError(const Twine Expected, const LocIter CurLoc,
30 RCParser::ParserError::ParserError(const Twine &Expected, const LocIter CurLoc,
3131 const LocIter End)
3232 : ErrorLoc(CurLoc), FileEnd(End) {
3333 CurMessage = "Error parsing file: expected " + Expected.str() + ", got " +
3636
3737 char RCParser::ParserError::ID = 0;
3838
39 RCParser::RCParser(const std::vector &TokenList)
40 : Tokens(TokenList), CurLoc(Tokens.begin()), End(Tokens.end()) {}
41
42 RCParser::RCParser(std::vector &&TokenList)
39 RCParser::RCParser(std::vector TokenList)
4340 : Tokens(std::move(TokenList)), CurLoc(Tokens.begin()), End(Tokens.end()) {}
4441
4542 bool RCParser::isEof() const { return CurLoc == End; }
705702 return llvm::make_unique(*Arg);
706703 }
707704
708 Error RCParser::getExpectedError(const Twine Message, bool IsAlreadyRead) {
705 Error RCParser::getExpectedError(const Twine &Message, bool IsAlreadyRead) {
709706 return make_error(
710707 Message, IsAlreadyRead ? std::prev(CurLoc) : CurLoc, End);
711708 }
3535 // Class describing a single failure of parser.
3636 class ParserError : public ErrorInfo {
3737 public:
38 ParserError(Twine Expected, const LocIter CurLoc, const LocIter End);
38 ParserError(const Twine &Expected, const LocIter CurLoc, const LocIter End);
3939
4040 void log(raw_ostream &OS) const override { OS << CurMessage; }
4141 std::error_code convertToErrorCode() const override {
5050 LocIter ErrorLoc, FileEnd;
5151 };
5252
53 RCParser(const std::vector &TokenList);
54 RCParser(std::vector &&TokenList);
53 RCParser(std::vector TokenList);
5554
5655 // Reads and returns a single resource definition, or error message if any
5756 // occurred.
171170 // the token that couldn't be parsed. If the flag is on, this complains about
172171 // the correctly read token that makes no sense (that is, the current parser
173172 // state is beyond the erroneous token.)
174 Error getExpectedError(const Twine Message, bool IsAlreadyRead = false);
173 Error getExpectedError(const Twine &Message, bool IsAlreadyRead = false);
175174
176175 std::vector Tokens;
177176 LocIter CurLoc;