AndyG added a comment.

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.


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