<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I think there might be other things broken in this function too.<div><br></div><div>I'm having problems trying to get highlighting/fixits working for parts of printf statements (rather than the whole thing).</div><div><br></div><div>Currently, if I give a SourceLocation within a printf formatting string, it will highlight it from the beginning until the end of the format string (rather than the end I specified). For example:</div><div><br></div><div><div><font class="Apple-style-span" face="'Courier New'"><div>/tmp/fixit.c:13:15: warning: precision used with 'n' conversion specifier,</div><div>      resulting in undefined behavior [-Wformat]</div><div>  printf("%100.100n", (int*) 0);</div><div>              ^~~~~</div><div><br></div></font></div><div>When what I expect is:</div><div><div><font class="Apple-style-span" face="'Courier New'"><div>/tmp/fixit.c:13:15: warning: precision used with 'n' conversion specifier,</div><div>      resulting in undefined behavior [-Wformat]</div><div>  printf("%100.100n", (int*) 0);</div><div>              ^~~~</div><div><br></div></font></div></div><div>This ends up breaking the fixits, which delete the rest of the format string rather than the invalid part.</div><div><br></div><div>The offending line is lib/Frontend/TextDiagnosticPrinter.cpp:116</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(82, 145, 114); "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(82, 145, 114); "><span style="color: #000000">      </span>// Add in the length of the token, so that we cover <span style="text-decoration: underline">multi</span>-char tokens.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(82, 145, 114); "><span style="color: #000000">      </span><font class="Apple-style-span" color="#000000">EndColNo += </font><span style="text-decoration: underline"><font class="Apple-style-span" color="#000000">Lexer</font></span><font class="Apple-style-span" color="#000000">::MeasureTokenLength(End, SM, *LangOpts);</font></div></div></div><div><br></div><div>I'm sure this line has importance, but I don't think it is correct.</div><div><br></div><div>I'm a bit lost in this section! Does anyone have any ideas?</div><div><br></div><div>Tom</div><div><div>On Jun 17, 2010, at 12:05 PM, Tom Care wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi all,<br><br>Whilst fixing bug 7377, I ran into an assertion when trying to highlight code in the following warning:<br><br>flag ' ' results in undefined behavior in 'p' conversion specifier<br><br>triggered by: printf("% p", p);<br><br>Assertion failed: (StartColNo <= EndColNo && "Trying to highlight whitespace??"), function HighlightRange, file /Volumes/Data/Users/tcare/Projects/llvm/tools/clang/lib/Frontend/TextDiagnosticPrinter.cpp, line 138.<br><br>The assertion is triggered by trying to highlight the format specifier ("% p")<br><br>This assertion seems valid, except for this rare case. Maybe there are others?<br><br>Any ideas on how to fix this?<br><br>Tom<br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></div></blockquote></div><br></div></body></html>