Skip to content

Commit

Permalink
Turn copies into references as suggested by clang-tidy's performance-…
Browse files Browse the repository at this point in the history
…unnecessary-copy-initialization.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270994 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
d0k committed May 27, 2016
1 parent 3184cd2 commit 9d37176
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ class CFGBuilder {
// * 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);
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/DependencyFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class DFGImpl : public PPCallbacks {
SeenMissingHeader(false),
IncludeModuleFiles(Opts.IncludeModuleFiles),
OutputFormat(Opts.OutputFormat) {
for (auto ExtraDep : Opts.ExtraDeps) {
for (const auto &ExtraDep : Opts.ExtraDeps) {
AddFilename(ExtraDep);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/SemaLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4060,8 +4060,8 @@ bool TypoCorrectionConsumer::resolveCorrection(TypoCorrection &Candidate) {

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();

Expand Down
13 changes: 7 additions & 6 deletions utils/TableGen/ClangAttrEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "_");
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 9d37176

Please sign in to comment.