From b089c1de5521b43b4050268565e621a4c7fd164e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 23 Dec 2009 18:53:37 +0000 Subject: [PATCH] switch -Werror/-Wfatal-errors error conditions to use diagnostics instead of printf, patch by Christian Adaker! llvm-svn: 92019 --- clang/TODO.txt | 1 - .../clang/Basic/DiagnosticFrontendKinds.td | 3 +++ clang/lib/Frontend/Warnings.cpp | 16 +++++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clang/TODO.txt b/clang/TODO.txt index 067f07b9d323..c63b1b33d6d6 100644 --- a/clang/TODO.txt +++ b/clang/TODO.txt @@ -69,7 +69,6 @@ More ideas for code modification hints: //===---------------------------------------------------------------------===// Options to support: - -Wfatal-errors -ftabstop=width -fpreprocessed mode. -nostdinc++ diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 252900d18b3f..66a841a8afae 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -219,4 +219,7 @@ def err_not_a_pch_file : Error< def warn_unknown_warning_option : Warning< "unknown warning option '%0'">, InGroup >; +def warn_unknown_warning_specifier : Warning< + "unknown %0 warning specifier: '%1'">, + InGroup >; } diff --git a/clang/lib/Frontend/Warnings.cpp b/clang/lib/Frontend/Warnings.cpp index 4d12bcf7e0f9..4bf507d48dca 100644 --- a/clang/lib/Frontend/Warnings.cpp +++ b/clang/lib/Frontend/Warnings.cpp @@ -13,12 +13,12 @@ // // This file is responsible for handling all warning options. This includes // a number of -Wfoo options and their variants, which are driven by TableGen- -// generated data, and the special cases -pedantic, -pedantic-errors, -w and -// -Werror. +// generated data, and the special cases -pedantic, -pedantic-errors, -w, +// -Werror and -Wfatal-errors. // // Each warning option controls any number of actual warnings. // Given a warning option 'foo', the following are valid: -// -Wfoo, -Wno-foo, -Werror=foo +// -Wfoo, -Wno-foo, -Werror=foo, -Wfatal-errors=foo // #include "clang/Frontend/Utils.h" #include "clang/Basic/Diagnostic.h" @@ -26,7 +26,6 @@ #include "clang/Lex/LexDiagnostic.h" #include "clang/Frontend/DiagnosticOptions.h" #include "clang/Frontend/FrontendDiagnostic.h" -#include #include #include #include @@ -79,8 +78,8 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags, if (OptEnd-OptStart != 5) { // Specifier must be present. if ((OptStart[5] != '=' && OptStart[5] != '-') || OptEnd-OptStart == 6) { - fprintf(stderr, "warning: unknown -Werror warning specifier: -W%s\n", - Opt.c_str()); + Diags.Report(diag::warn_unknown_warning_specifier) + << "-Werror" << ("-W" + Opt); continue; } Specifier = OptStart+6; @@ -102,9 +101,8 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags, if (OptEnd-OptStart != 12) { if ((OptStart[12] != '=' && OptStart[12] != '-') || OptEnd-OptStart == 13) { - fprintf(stderr, - "warning: unknown -Wfatal-errors warning specifier: -W%s\n", - Opt.c_str()); + Diags.Report(diag::warn_unknown_warning_specifier) + << "-Wfatal-errors" << ("-W" + Opt); continue; } Specifier = OptStart + 13;