Turn copies into references as suggested by clang-tidy's performance-unnecessary-copy-initialization.

llvm-svn: 270994
This commit is contained in:
Benjamin Kramer 2016-05-27 13:36:58 +00:00
parent df9db45c94
commit 2e018efa9b
6 changed files with 13 additions and 12 deletions

View File

@ -825,7 +825,7 @@ private:
// * Variable x is equal to the largest literal.
// * Variable x is greater than largest literal.
bool AlwaysTrue = true, AlwaysFalse = true;
for (llvm::APSInt Value : Values) {
for (const llvm::APSInt &Value : Values) {
TryResult Res1, Res2;
Res1 = analyzeLogicOperatorCondition(BO1, Value, L1);
Res2 = analyzeLogicOperatorCondition(BO2, Value, L2);

View File

@ -6541,7 +6541,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
}
}
const std::string customGCCName = D.getCCCGenericGCCName();
const std::string &customGCCName = D.getCCCGenericGCCName();
const char *GCCName;
if (!customGCCName.empty())
GCCName = customGCCName.c_str();

View File

@ -2416,7 +2416,7 @@ std::string CompilerInvocation::getModuleHash() const {
// Extend the signature with the module file extensions.
const FrontendOptions &frontendOpts = getFrontendOpts();
for (auto ext : frontendOpts.ModuleFileExtensions) {
for (const auto &ext : frontendOpts.ModuleFileExtensions) {
code = ext->hashExtension(code);
}

View File

@ -177,7 +177,7 @@ public:
SeenMissingHeader(false),
IncludeModuleFiles(Opts.IncludeModuleFiles),
OutputFormat(Opts.OutputFormat) {
for (auto ExtraDep : Opts.ExtraDeps) {
for (const auto &ExtraDep : Opts.ExtraDeps) {
AddFilename(ExtraDep);
}
}

View File

@ -4060,8 +4060,8 @@ retry_lookup:
void TypoCorrectionConsumer::performQualifiedLookups() {
unsigned TypoLen = Typo->getName().size();
for (auto QR : QualifiedResults) {
for (auto NSI : Namespaces) {
for (const TypoCorrection &QR : QualifiedResults) {
for (const auto &NSI : Namespaces) {
DeclContext *Ctx = NSI.DeclCtx;
const Type *NSType = NSI.NameSpecifier->getAsType();

View File

@ -1449,9 +1449,9 @@ CreateSemanticSpellings(const std::vector<FlattenedSpelling> &Spellings,
unsigned Idx = 0;
for (auto I = Spellings.begin(), E = Spellings.end(); I != E; ++I, ++Idx) {
const FlattenedSpelling &S = *I;
std::string Variety = S.variety();
std::string Spelling = S.name();
std::string Namespace = S.nameSpace();
const std::string &Variety = S.variety();
const std::string &Spelling = S.name();
const std::string &Namespace = S.nameSpace();
std::string EnumName;
EnumName += (Variety + "_");
@ -2298,7 +2298,7 @@ void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
for (auto *R : Attrs) {
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(*R);
for (const auto &SI : Spellings) {
std::string Variety = SI.variety();
const std::string &Variety = SI.variety();
if (Variety == "GNU")
GNU.push_back(R);
else if (Variety == "Declspec")
@ -2998,9 +2998,10 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
std::vector<FlattenedSpelling> Spellings = GetFlattenedSpellings(Attr);
for (const auto &S : Spellings) {
std::string RawSpelling = S.name();
const std::string &RawSpelling = S.name();
std::vector<StringMatcher::StringPair> *Matches = nullptr;
std::string Spelling, Variety = S.variety();
std::string Spelling;
const std::string &Variety = S.variety();
if (Variety == "CXX11") {
Matches = &CXX11;
Spelling += S.nameSpace();