rtrieu added a comment.

In http://reviews.llvm.org/D15636#343856, @AndyG wrote:

> In your case, the first string would be highlighted only.  Yes, I see what 
> you mean.  Is it possible to have multiple ranges for the diagnostic?  By 
> which I mean, to produce the following:
>
>   test.cpp:x:y: warning: data argument not used by format string 
> [-Wformat-extra-args]
>       printf(condition ? "first message: %d" : "second message: %d", 5, 10);
>                          ~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~     ^
>
>
> If so, I think the diagnostic should still track just the strings utilising 
> the most arguments, so this would be the case with three messages, missing 
> out the middle string since it is already using a sub-set of the arguments 
> anyway:
>
>   test.cpp:x:y: warning: data argument not used by format string 
> [-Wformat-extra-args]
>       printf(a ? "%d %d" : b ? "%d" : "%d %d", 5, 10, 20);
>                   ~~~~~                ~~~~~          ^
>  
>
>
> If you think this isn't sufficient, then my suggestion would be to make the 
> range of the diagnostic the complete format expression, and let the 
> programmer assess it themselves.


I believe your two examples are the way to go, highlighting all the format 
strings using the most arguments.  You can pass multiple SourceRange's to a 
diagnostic.  To do that, in your Diagnose function, store the result of P.Diag 
in a local reference, then pass in the extra SourceRange's, then pass that 
reference to EmitFormatDiagnostic.


http://reviews.llvm.org/D15636



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to