Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1825)

Unified Diff: tools/clang/plugins/ChromeClassTester.cpp

Issue 1117163002: Clang style plugin: add warn-only option and use it on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/clang/plugins/ChromeClassTester.cpp
diff --git a/tools/clang/plugins/ChromeClassTester.cpp b/tools/clang/plugins/ChromeClassTester.cpp
index 931da02f3ff54e352a1cbec4337433abb38e449f..69309e823911d1936bdfd35320ce133e36f6f088 100644
--- a/tools/clang/plugins/ChromeClassTester.cpp
+++ b/tools/clang/plugins/ChromeClassTester.cpp
@@ -18,6 +18,7 @@
#endif
using namespace clang;
+using chrome_checker::Options;
namespace {
@@ -30,8 +31,10 @@ bool ends_with(const std::string& one, const std::string& two) {
} // namespace
-ChromeClassTester::ChromeClassTester(CompilerInstance& instance)
- : instance_(instance),
+ChromeClassTester::ChromeClassTester(CompilerInstance& instance,
+ const Options& options)
+ : options_(options),
+ instance_(instance),
diagnostic_(instance.getDiagnostics()) {
BuildBannedLists();
}
@@ -95,16 +98,13 @@ void ChromeClassTester::emitWarning(SourceLocation loc,
std::string err;
err = "[chromium-style] ";
err += raw_error;
- // TODO(dcheng): Re-enable -Werror for these diagnostics on Windows once all
- // the pre-existing warnings are cleaned up. https://crbug.com/467287
- DiagnosticIDs::Level level =
-#if !defined(LLVM_ON_WIN32)
- diagnostic().getWarningsAsErrors() ?
- DiagnosticIDs::Error :
-#endif
- DiagnosticIDs::Warning;
+
+ DiagnosticIDs::Level level = getErrorLevel() == DiagnosticsEngine::Error
+ ? DiagnosticIDs::Error : DiagnosticIDs::Warning;
+
unsigned id = diagnostic().getDiagnosticIDs()->getCustomDiagID(level, err);
DiagnosticBuilder builder = diagnostic().Report(full, id);
+
}
bool ChromeClassTester::InBannedDirectory(SourceLocation loc) {
@@ -304,3 +304,11 @@ bool ChromeClassTester::GetFilename(SourceLocation loc,
*filename = ploc.getFilename();
return true;
}
+
+DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() {
+ if (options_.warn_only)
+ return DiagnosticsEngine::Warning;
+
+ return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error
+ : DiagnosticsEngine::Warning;
+}

Powered by Google App Engine
This is Rietveld 408576698