diff options
| author | Jonathan Roelofs <jonathan@codesourcery.com> | 2016-01-13 17:36:41 +0000 |
|---|---|---|
| committer | Jonathan Roelofs <jonathan@codesourcery.com> | 2016-01-13 17:36:41 +0000 |
| commit | d60388a9852f4a1b40b863a4736e8c9b87c478b0 (patch) | |
| tree | 36a70b21061a7e475119405e155af2edfd03e047 /clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp | |
| parent | 3f01e7a62edbcde0c87164b24aa9da9ca04ab7bd (diff) | |
| download | bcm5719-llvm-d60388a9852f4a1b40b863a4736e8c9b87c478b0.tar.gz bcm5719-llvm-d60388a9852f4a1b40b863a4736e8c9b87c478b0.zip | |
Teach clang-tidy how to upgrade warnings into errors.
Similar in format to the `-checks=` argument, this new `-warnings-as-errors=`
argument upgrades any warnings emitted by the former to errors.
http://reviews.llvm.org/D15528
llvm-svn: 257642
Diffstat (limited to 'clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index ac216753fe9..320a50a97fe 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -115,8 +115,10 @@ ClangTidyMessage::ClangTidyMessage(StringRef Message, } ClangTidyError::ClangTidyError(StringRef CheckName, - ClangTidyError::Level DiagLevel) - : CheckName(CheckName), DiagLevel(DiagLevel) {} + ClangTidyError::Level DiagLevel, + bool IsWarningAsError) + : CheckName(CheckName), DiagLevel(DiagLevel), + IsWarningAsError(IsWarningAsError) {} // Returns true if GlobList starts with the negative indicator ('-'), removes it // from the GlobList. @@ -204,6 +206,7 @@ void ClangTidyContext::setCurrentFile(StringRef File) { CurrentFile = File; CurrentOptions = getOptionsForFile(CurrentFile); CheckFilter.reset(new GlobList(*getOptions().Checks)); + WarningAsErrorFilter.reset(new GlobList(*getOptions().WarningsAsErrors)); } void ClangTidyContext::setASTContext(ASTContext *Context) { @@ -237,6 +240,11 @@ bool ClangTidyContext::isCheckEnabled(StringRef CheckName) const { return CheckFilter->contains(CheckName); } +GlobList &ClangTidyContext::getWarningAsErrorFilter() { + assert(WarningAsErrorFilter != nullptr); + return *WarningAsErrorFilter; +} + /// \brief Store a \c ClangTidyError. void ClangTidyContext::storeError(const ClangTidyError &Error) { Errors.push_back(Error); @@ -324,7 +332,10 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic( LastErrorRelatesToUserCode = true; LastErrorPassesLineFilter = true; } - Errors.push_back(ClangTidyError(CheckName, Level)); + bool IsWarningAsError = + DiagLevel == DiagnosticsEngine::Warning && + Context.getWarningAsErrorFilter().contains(CheckName); + Errors.push_back(ClangTidyError(CheckName, Level, IsWarningAsError)); } // FIXME: Provide correct LangOptions for each file. |

