[clang-tools-extra] r217952 - Make a variable local so it's lifetime becomes more obvious.

Benjamin Kramer benny.kra at googlemail.com
Wed Sep 17 06:12:52 PDT 2014


Author: d0k
Date: Wed Sep 17 08:12:51 2014
New Revision: 217952

URL: http://llvm.org/viewvc/llvm-project?rev=217952&view=rev
Log:
Make a variable local so it's lifetime becomes more obvious.

NFC

Modified:
    clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp

Modified: clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp?rev=217952&r1=217951&r2=217952&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp Wed Sep 17 08:12:51 2014
@@ -112,12 +112,13 @@ public:
       // the #ifndef and #define.
       StringRef CurHeaderGuard =
           MacroEntry.first.getIdentifierInfo()->getName();
+      std::vector<FixItHint> FixIts;
       std::string NewGuard = checkHeaderGuardDefinition(
-          Ifndef, Define, EndIf, FileName, CurHeaderGuard);
+          Ifndef, Define, EndIf, FileName, CurHeaderGuard, FixIts);
 
       // Now look at the #endif. We want a comment with the header guard. Fix it
       // at the slightest deviation.
-      checkEndifComment(FileName, EndIf, NewGuard);
+      checkEndifComment(FileName, EndIf, NewGuard, FixIts);
 
       // Bundle all fix-its into one warning. The message depends on whether we
       // changed the header guard or not.
@@ -134,7 +135,6 @@ public:
             D.AddFixItHint(std::move(Fix));
         }
       }
-      FixIts.clear();
     }
 
     // Emit warnings for headers that are missing guards.
@@ -177,7 +177,8 @@ public:
                                          SourceLocation Define,
                                          SourceLocation EndIf,
                                          StringRef FileName,
-                                         StringRef CurHeaderGuard) {
+                                         StringRef CurHeaderGuard,
+                                         std::vector<FixItHint> &FixIts) {
     std::string CPPVar = Check->getHeaderGuard(FileName, CurHeaderGuard);
     std::string CPPVarUnder = CPPVar + '_';
 
@@ -202,7 +203,8 @@ public:
   /// \brief Checks the comment after the #endif of a header guard and fixes it
   /// if it doesn't match \c HeaderGuard.
   void checkEndifComment(StringRef FileName, SourceLocation EndIf,
-                         StringRef HeaderGuard) {
+                         StringRef HeaderGuard,
+                         std::vector<FixItHint> &FixIts) {
     size_t EndIfLen;
     if (wouldFixEndifComment(FileName, EndIf, HeaderGuard, &EndIfLen)) {
       std::string Correct = "endif  // " + HeaderGuard.str();
@@ -270,7 +272,6 @@ private:
   std::map<const IdentifierInfo *, std::pair<SourceLocation, SourceLocation>>
       Ifndefs;
   std::map<SourceLocation, SourceLocation> EndIfs;
-  std::vector<FixItHint> FixIts;
 
   Preprocessor *PP;
   HeaderGuardCheck *Check;





More information about the cfe-commits mailing list