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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45103 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 8224743..fba375f 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -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);
+
 }
 
 //===----------------------------------------------------------------------===//