]> granicus.if.org Git - clang/commitdiff
switch Warnings.cpp to use the diagnostics machinery to print diagnostics, not *fprintf*!
authorChris Lattner <sabre@nondot.org>
Tue, 23 Jun 2009 01:20:39 +0000 (01:20 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 23 Jun 2009 01:20:39 +0000 (01:20 +0000)
Among other things, this makes the warning about unknown warning options mappable.
For example:

$ clang t.c -Werror -Wfoo
error: unknown warning option '-Wfoo' [-Wunknown-warning-option]

For another thing, they are properly color coded now too :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73936 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticFrontendKinds.td
lib/Frontend/Warnings.cpp

index ae5246d7929a5b64b10155c65e5e38bbf4743c72..9c439851b1822c9283c77971c268e7ae901b843c 100644 (file)
@@ -136,4 +136,7 @@ def warn_pch_char_signed : Error<
 
 def err_not_a_pch_file : Error<
     "'%0' does not appear to be a precompiled header file">, DefaultFatal;
+def warn_unknown_warning_option : Warning<
+    "unknown warning option '%0'">,
+    InGroup<DiagGroup<"unknown-warning-option"> >;
 }
index 81f75bdf755cc198dfca0fa9aa61897b607666e8..c8fd5f6fcbc0636c0c589a8665e7b0eca9d466a3 100644 (file)
@@ -24,6 +24,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/Lex/LexDiagnostic.h"
+#include "clang/Frontend/FrontendDiagnostic.h"
 #include <cstdio>
 #include <cstring>
 #include <utility>
@@ -99,7 +100,8 @@ bool clang::ProcessWarningOptions(Diagnostic &Diags,
     }
     
     if (Diags.setDiagnosticGroupMapping(OptStart, Mapping))
-      fprintf(stderr, "warning: unknown warning option: -W%s\n", Opt.c_str());
+      Diags.Report(FullSourceLoc(), diag::warn_unknown_warning_option)
+        << ("-W" + Opt);
   }
   
   return false;