Hiralo created this revision.
Hiralo added reviewers: alexfh, njames93, hokein, DmitryPolukhin, djasper,
ilya-biryukov.
Hiralo added a project: clang-tools-extra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Hiralo requested review of this revision.
commit c3fa7da502d6cc77e5c0710b0e9308e6fbdd137c
Author: Hiral Oza <[email protected]>
Date: Thu Oct 22 22:06:25 2020 -0700
clang-tidy: Reduce number of stderr write calls
Making single write call in place of 7 small string write calls.
Thank you in advance for your kind review.
-Hiral
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90010
Files:
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
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<ClangTidyOptionsProvider> createOptionsProvider(
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<ClangTidyOptionsProvider> createOptionsProvider(
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits