Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp =================================================================== --- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -241,31 +241,36 @@ namespace tidy { static void printStats(const ClangTidyStats &Stats) { + std::string Msg; + llvm::raw_string_ostream ErrStream(Msg); + if (Stats.errorsIgnored()) { - llvm::errs() << "Suppressed " << Stats.errorsIgnored() << " warnings ("; + ErrStream << "Suppressed " << Stats.errorsIgnored() << " warnings ("; + StringRef Separator = ""; if (Stats.ErrorsIgnoredNonUserCode) { - llvm::errs() << Stats.ErrorsIgnoredNonUserCode << " in non-user code"; + ErrStream << Stats.ErrorsIgnoredNonUserCode << " in non-user code"; Separator = ", "; } if (Stats.ErrorsIgnoredLineFilter) { - llvm::errs() << Separator << Stats.ErrorsIgnoredLineFilter - << " due to line filter"; + ErrStream << Separator << Stats.ErrorsIgnoredLineFilter + << " due to line filter"; Separator = ", "; } if (Stats.ErrorsIgnoredNOLINT) { - llvm::errs() << Separator << Stats.ErrorsIgnoredNOLINT << " NOLINT"; + ErrStream << Separator << Stats.ErrorsIgnoredNOLINT << " NOLINT"; Separator = ", "; } if (Stats.ErrorsIgnoredCheckFilter) - llvm::errs() << Separator << Stats.ErrorsIgnoredCheckFilter - << " with check filters"; - llvm::errs() << ").\n"; + ErrStream << Separator << Stats.ErrorsIgnoredCheckFilter + << " with check filters"; + ErrStream << ").\n"; if (Stats.ErrorsIgnoredNonUserCode) - llvm::errs() << "Use -header-filter=.* to display errors from all " - "non-system headers. Use -system-headers to display " - "errors from system headers as well.\n"; + ErrStream << "Use -header-filter=.* to display errors from all " + "non-system headers. Use -system-headers to display " + "errors from system headers as well.\n"; } + llvm::errs() << ErrStream.str(); } static std::unique_ptr createOptionsProvider(