Skip to content

Commit 3911fdd

Browse files
authored
fixed some Variable copied when it could be moved Coverity warnings (#495)
1 parent 0689d83 commit 3911fdd

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

simplecpp.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ static void portabilityBackslash(simplecpp::OutputList *outputList, const std::v
611611
err.type = simplecpp::Output::PORTABILITY_BACKSLASH;
612612
err.location = location;
613613
err.msg = "Combination 'backslash space newline' is not portable.";
614-
outputList->push_back(err);
614+
outputList->push_back(std::move(err));
615615
}
616616

617617
static bool isStringLiteralPrefix(const std::string &str)
@@ -855,7 +855,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
855855
err.type = Output::SYNTAX_ERROR;
856856
err.location = location;
857857
err.msg = "Raw string missing terminating delimiter.";
858-
outputList->push_back(err);
858+
outputList->push_back(std::move(err));
859859
}
860860
return;
861861
}
@@ -1397,7 +1397,7 @@ std::string simplecpp::TokenList::readUntil(Stream &stream, const Location &loca
13971397
err.type = Output::SYNTAX_ERROR;
13981398
err.location = location;
13991399
err.msg = std::string("No pair for character (") + start + "). Can't process file. File is either invalid or unicode, which is currently not supported.";
1400-
outputList->push_back(err);
1400+
outputList->push_back(std::move(err));
14011401
}
14021402
return "";
14031403
}
@@ -2178,7 +2178,7 @@ namespace simplecpp {
21782178
if (it != macros.end() && !partok->isExpandedFrom(&it->second) && (partok->str() == name() || expandedmacros.find(partok->str()) == expandedmacros.end())) {
21792179
std::set<TokenString> expandedmacros2(expandedmacros); // temporary amnesia to allow reexpansion of currently expanding macros during argument evaluation
21802180
expandedmacros2.erase(name());
2181-
partok = it->second.expand(output, loc, partok, macros, expandedmacros2);
2181+
partok = it->second.expand(output, loc, partok, macros, std::move(expandedmacros2));
21822182
} else {
21832183
output->push_back(newMacroToken(partok->str(), loc, isReplaced(expandedmacros), partok));
21842184
output->back()->macro = partok->macro;
@@ -3137,7 +3137,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31373137
err.type = simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND;
31383138
err.location = Location(filenames);
31393139
err.msg = "Can not open include file '" + filename + "' that is explicitly included.";
3140-
outputList->push_back(err);
3140+
outputList->push_back(std::move(err));
31413141
}
31423142
continue;
31433143
}
@@ -3210,7 +3210,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
32103210
out.type = simplecpp::Output::SYNTAX_ERROR;
32113211
out.location = err.location;
32123212
out.msg = "failed to expand \'" + tok->str() + "\', " + err.what;
3213-
outputList->push_back(out);
3213+
outputList->push_back(std::move(out));
32143214
}
32153215
return false;
32163216
}
@@ -3397,7 +3397,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33973397
err.msg += tok->str();
33983398
}
33993399
err.msg = '#' + rawtok->str() + ' ' + err.msg;
3400-
outputList->push_back(err);
3400+
outputList->push_back(std::move(err));
34013401
}
34023402
if (rawtok->str() == ERROR) {
34033403
output.clear();
@@ -3557,7 +3557,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35573557
out.type = Output::SYNTAX_ERROR;
35583558
out.location = rawtok->location;
35593559
out.msg = "failed to evaluate " + std::string(rawtok->str() == IF ? "#if" : "#elif") + " condition";
3560-
outputList->push_back(out);
3560+
outputList->push_back(std::move(out));
35613561
}
35623562
output.clear();
35633563
return;
@@ -3736,7 +3736,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37363736
mu.macroName = macro.name();
37373737
mu.macroLocation = macro.defineLocation();
37383738
mu.useLocation = *usageIt;
3739-
macroUsage->push_back(mu);
3739+
macroUsage->push_back(std::move(mu));
37403740
}
37413741
}
37423742
}

0 commit comments

Comments
 (0)