diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-17 11:48:34 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2014-09-17 11:48:34 +0000 |
commit | ae8fc5223780204dd8dcd17066b791996402d75f (patch) | |
tree | cb12f9d1f3e960f4d3412cb43f6cac3c65c1b041 /clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp | |
parent | 5b92b4971a49afc5ab1e405d834bbeef29eabd72 (diff) | |
download | bcm5719-llvm-ae8fc5223780204dd8dcd17066b791996402d75f.tar.gz bcm5719-llvm-ae8fc5223780204dd8dcd17066b791996402d75f.zip |
[clang-tidy] Don't emit the same fixit multiple times.
If we had many header files we would attach the fix-it for all files to all
warnings, oops. This is harmless 99.9% of the time but can confuse the rewriter
in some edge cases. Sadly I failed to create a small test case for this.
While there move fix-its instead of copying.
llvm-svn: 217951
Diffstat (limited to 'clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp index cf187c25a27..d18cf1603ed 100644 --- a/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp +++ b/clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp @@ -125,15 +125,16 @@ public: if (CurHeaderGuard != NewGuard) { auto D = Check->diag(Ifndef, "header guard does not follow preferred style"); - for (const FixItHint Fix : FixIts) - D.AddFixItHint(Fix); + for (FixItHint &Fix : FixIts) + D.AddFixItHint(std::move(Fix)); } else { auto D = Check->diag(EndIf, "#endif for a header guard should " "reference the guard macro in a comment"); - for (const FixItHint Fix : FixIts) - D.AddFixItHint(Fix); + for (FixItHint &Fix : FixIts) + D.AddFixItHint(std::move(Fix)); } } + FixIts.clear(); } // Emit warnings for headers that are missing guards. @@ -144,7 +145,6 @@ public: Files.clear(); Ifndefs.clear(); EndIfs.clear(); - FixIts.clear(); } bool wouldFixEndifComment(StringRef FileName, SourceLocation EndIf, |