[llvm] r315229 - Fix some C++ value / reference semantics issues.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 11:50:29 PDT 2017
Author: zturner
Date: Mon Oct 9 11:50:29 2017
New Revision: 315229
URL: http://llvm.org/viewvc/llvm-project?rev=315229&view=rev
Log:
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.
Modified:
llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
llvm/trunk/tools/llvm-rc/ResourceFileWriter.h
llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp
llvm/trunk/tools/llvm-rc/ResourceScriptParser.h
Modified: llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp?rev=315229&r1=315228&r2=315229&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.cpp Mon Oct 9 11:50:29 2017
@@ -380,7 +380,7 @@ void ResourceFileWriter::padStream(uint6
writeInt<uint8_t>(0);
}
-Error ResourceFileWriter::handleError(Error &&Err, const RCResource *Res) {
+Error ResourceFileWriter::handleError(Error Err, const RCResource *Res) {
if (Err)
return joinErrors(createError("Error in " + Res->getResourceTypeName() +
" statement (ID " + Twine(Res->ResName) +
Modified: llvm/trunk/tools/llvm-rc/ResourceFileWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceFileWriter.h?rev=315229&r1=315228&r2=315229&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceFileWriter.h (original)
+++ llvm/trunk/tools/llvm-rc/ResourceFileWriter.h Mon Oct 9 11:50:29 2017
@@ -88,7 +88,7 @@ public:
} StringTableData;
private:
- Error handleError(Error &&Err, const RCResource *Res);
+ Error handleError(Error Err, const RCResource *Res);
Error
writeResource(const RCResource *Res,
Modified: llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp?rev=315229&r1=315228&r2=315229&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp (original)
+++ llvm/trunk/tools/llvm-rc/ResourceScriptParser.cpp Mon Oct 9 11:50:29 2017
@@ -28,7 +28,7 @@
namespace llvm {
namespace rc {
-RCParser::ParserError::ParserError(const Twine Expected, const LocIter CurLoc,
+RCParser::ParserError::ParserError(const Twine &Expected, const LocIter CurLoc,
const LocIter End)
: ErrorLoc(CurLoc), FileEnd(End) {
CurMessage = "Error parsing file: expected " + Expected.str() + ", got " +
@@ -37,10 +37,7 @@ RCParser::ParserError::ParserError(const
char RCParser::ParserError::ID = 0;
-RCParser::RCParser(const std::vector<RCToken> &TokenList)
- : Tokens(TokenList), CurLoc(Tokens.begin()), End(Tokens.end()) {}
-
-RCParser::RCParser(std::vector<RCToken> &&TokenList)
+RCParser::RCParser(std::vector<RCToken> TokenList)
: Tokens(std::move(TokenList)), CurLoc(Tokens.begin()), End(Tokens.end()) {}
bool RCParser::isEof() const { return CurLoc == End; }
@@ -706,7 +703,7 @@ RCParser::ParseOptionType RCParser::pars
return llvm::make_unique<StyleStmt>(*Arg);
}
-Error RCParser::getExpectedError(const Twine Message, bool IsAlreadyRead) {
+Error RCParser::getExpectedError(const Twine &Message, bool IsAlreadyRead) {
return make_error<ParserError>(
Message, IsAlreadyRead ? std::prev(CurLoc) : CurLoc, End);
}
Modified: llvm/trunk/tools/llvm-rc/ResourceScriptParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rc/ResourceScriptParser.h?rev=315229&r1=315228&r2=315229&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rc/ResourceScriptParser.h (original)
+++ llvm/trunk/tools/llvm-rc/ResourceScriptParser.h Mon Oct 9 11:50:29 2017
@@ -36,7 +36,7 @@ public:
// Class describing a single failure of parser.
class ParserError : public ErrorInfo<ParserError> {
public:
- ParserError(Twine Expected, const LocIter CurLoc, const LocIter End);
+ ParserError(const Twine &Expected, const LocIter CurLoc, const LocIter End);
void log(raw_ostream &OS) const override { OS << CurMessage; }
std::error_code convertToErrorCode() const override {
@@ -51,8 +51,7 @@ public:
LocIter ErrorLoc, FileEnd;
};
- RCParser(const std::vector<RCToken> &TokenList);
- RCParser(std::vector<RCToken> &&TokenList);
+ RCParser(std::vector<RCToken> TokenList);
// Reads and returns a single resource definition, or error message if any
// occurred.
@@ -172,7 +171,7 @@ private:
// the token that couldn't be parsed. If the flag is on, this complains about
// the correctly read token that makes no sense (that is, the current parser
// state is beyond the erroneous token.)
- Error getExpectedError(const Twine Message, bool IsAlreadyRead = false);
+ Error getExpectedError(const Twine &Message, bool IsAlreadyRead = false);
std::vector<RCToken> Tokens;
LocIter CurLoc;
More information about the llvm-commits
mailing list