]> granicus.if.org Git - clang/commitdiff
Disable -Wformat-extra-args for arguments defined in system headers.
authorBob Wilson <bob.wilson@apple.com>
Thu, 3 May 2012 19:47:19 +0000 (19:47 +0000)
committerBob Wilson <bob.wilson@apple.com>
Thu, 3 May 2012 19:47:19 +0000 (19:47 +0000)
Some of the NSAssert macros in OS X 10.7 are implemented in a way that
adds extra arguments that trigger the -Wformat-extra-args warning.
Earlier versions of clang failed to detect those -Wformat issues, but now
that clang is reporting those problems, we need to quiet them since there's
nothing to be done to fix them.  <rdar://problem/11317765>

I don't know how to write a testcase for this.  Suggestions welcome.
Patch by Ted Kremenek!

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

lib/Sema/SemaChecking.cpp

index 002c985e0c5b183a4575a053ec424261fe86faee..dad082748827cf5a5a1df7a7846df7cc28437616 100644 (file)
@@ -1975,9 +1975,12 @@ void CheckFormatHandler::DoneProcessing() {
     signed notCoveredArg = CoveredArgs.find_first();
     if (notCoveredArg >= 0) {
       assert((unsigned)notCoveredArg < NumDataArgs);
-      EmitFormatDiagnostic(S.PDiag(diag::warn_printf_data_arg_not_used),
-                           getDataArg((unsigned) notCoveredArg)->getLocStart(),
-                           /*IsStringLocation*/false, getFormatStringRange());
+      SourceLocation Loc = getDataArg((unsigned) notCoveredArg)->getLocStart();
+      if (!S.getSourceManager().isInSystemMacro(Loc)) {
+        EmitFormatDiagnostic(S.PDiag(diag::warn_printf_data_arg_not_used),
+                             Loc,
+                             /*IsStringLocation*/false, getFormatStringRange());
+      }
     }
   }
 }