[cfe-commits] r156092 - /cfe/trunk/lib/Sema/SemaChecking.cpp

Jean-Daniel Dupas devlists at shadowlab.org
Fri May 4 06:11:09 PDT 2012


When I updated -Wformat to works with NSString methods, I had to include a similar workaround for NSLocalizedString.
At that time, I wasn't aware of the existence of isInSystemMacro().

I wrote a patch to use this method instead of disabling the warning in all macros in my existing workaround, 
and wrote a test that check for both NSLocalizedString and NSAssert cases.

If you're OK with this patch, I will commit it.

Le 3 mai 2012 à 21:47, Bob Wilson a écrit :

> Author: bwilson
> Date: Thu May  3 14:47:19 2012
> New Revision: 156092
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=156092&view=rev
> Log:
> Disable -Wformat-extra-args for arguments defined in system headers.
> 
> 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!
> 
> Modified:
>    cfe/trunk/lib/Sema/SemaChecking.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=156092&r1=156091&r2=156092&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu May  3 14:47:19 2012
> @@ -1975,9 +1975,12 @@
>     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());
> +      }
>     }
>   }
> }
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-- Jean-Daniel



-------------- next part --------------
A non-text attachment was scrubbed...
Name: system.patch
Type: application/octet-stream
Size: 2311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120504/b9a68d9c/attachment.obj>


More information about the cfe-commits mailing list