diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-17 13:12:51 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-17 13:12:51 +0000 |
commit | ebdf90ca009b6ae97980ee6b43acba3b1638546e (patch) | |
tree | 6e6436ecb5a5cdfee7a96d58c4b519c4057a00ed /clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp | |
parent | ae8fc5223780204dd8dcd17066b791996402d75f (diff) | |
download | bcm5719-llvm-ebdf90ca009b6ae97980ee6b43acba3b1638546e.tar.gz bcm5719-llvm-ebdf90ca009b6ae97980ee6b43acba3b1638546e.zip |
Make a variable local so it's lifetime becomes more obvious.
NFC
llvm-svn: 217952
Diffstat (limited to 'clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp index d18cf1603ed..0a5fe988179 100644 --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp @@ -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; |