[cfe-commits] r45103 - /cfe/trunk/Driver/clang.cpp

Ted Kremenek kremenek at apple.com
Mon Dec 17 09:50:07 PST 2007


Author: kremenek
Date: Mon Dec 17 11:50:07 2007
New Revision: 45103

URL: http://llvm.org/viewvc/llvm-project?rev=45103&view=rev
Log:
Added driver option -Wno-format-nonliteral to silence format string related
warnings. This flag is the inverse of to GCC's -Wformat-nonliteral option (in
the clang driver, these warnings are on by default).

Patch provided by Shantonu Sen.

Modified:
    cfe/trunk/Driver/clang.cpp

Modified: cfe/trunk/Driver/clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=45103&r1=45102&r2=45103&view=diff

==============================================================================
--- cfe/trunk/Driver/clang.cpp (original)
+++ cfe/trunk/Driver/clang.cpp Mon Dec 17 11:50:07 2007
@@ -385,6 +385,10 @@
 WarnFloatEqual("Wfloat-equal",
    llvm::cl::desc("Warn about equality comparisons of floating point values."));
 
+static llvm::cl::opt<bool>
+WarnNoFormatNonLiteral("Wno-format-nonliteral",
+   llvm::cl::desc("Do not warn about non-literal format strings."));
+
 /// InitializeDiagnostics - Initialize the diagnostic object, based on the
 /// current command line option settings.
 static void InitializeDiagnostics(Diagnostic &Diags) {
@@ -399,6 +403,11 @@
   // Silence "floating point comparison" warnings unless requested.
   if (!WarnFloatEqual)
     Diags.setDiagnosticMapping(diag::warn_floatingpoint_eq, diag::MAP_IGNORE);
+
+  // Silence "format string is not a string literal" warnings if requested
+  if (WarnNoFormatNonLiteral)
+    Diags.setDiagnosticMapping(diag::warn_printf_not_string_constant, diag::MAP_IGNORE);
+
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list