From 73da590134d55cf3d0d5df25d332286c1d420dab Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 17 Dec 2007 17:50:07 +0000 Subject: [PATCH] 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 --- Driver/clang.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 8224743211..fba375f353 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -385,6 +385,10 @@ static llvm::cl::opt WarnFloatEqual("Wfloat-equal", llvm::cl::desc("Warn about equality comparisons of floating point values.")); +static llvm::cl::opt +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 @@ static void InitializeDiagnostics(Diagnostic &Diags) { // 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); + } //===----------------------------------------------------------------------===// -- 2.40.0