On Wed, Sep 17, 2014 at 1:48 PM, Benjamin Kramer <[email protected]> wrote:
> Author: d0k > Date: Wed Sep 17 06:48:34 2014 > New Revision: 217951 > > URL: http://llvm.org/viewvc/llvm-project?rev=217951&view=rev > Log: > [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. > > 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=217951&r1=217950&r2=217951&view=diff > > ============================================================================== > --- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp (original) > +++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp Wed Sep 17 > 06:48:34 2014 > @@ -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(); > >From how it is used, FixIts could also be a local variable. > } > > // 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, > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
