]> granicus.if.org Git - clang/commitdiff
Turn copies into references as suggested by clang-tidy's performance-unnecessary...
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 27 May 2016 13:36:58 +0000 (13:36 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 27 May 2016 13:36:58 +0000 (13:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270994 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/DependencyFile.cpp
lib/Sema/SemaLookup.cpp
utils/TableGen/ClangAttrEmitter.cpp

index 855017c7c1556a054bf3bfba8e77ea92587fe41f..d9349fc4092d5da02071800a74f63b03715c50f9 100644 (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);
index 1eac1d27edde3fccf087b74a708a88be228fe92d..39f78c30667167c99370fba536646cba20021817 100644 (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();
index 74e9fed7f1260c9a3cc874260b5d7220a98fd83d..a37e1cecae88e38552fb8f7fcf105200bb9cadb2 100644 (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);
   }
 
index 93d4a803469657ea35fdfd0ef2775b7134dd9db6..a9b61282378dd8c434ca9e0c49af57498eb4a808 100644 (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);
     }
   }
index 2afb13e1db1f8c23ae2dd5b2cf2f25aff0301aa5..e761436683e2b87327b7f791023428af45042fcf 100644 (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();
 
index edb613c092a8f2a056216a429de14b8879c5ed5a..cb29b21c4ab3c9fad73918f6b99a7714415e4fdd 100644 (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();