[cfe-dev] Assertion on valid use of highlighting whitespace
Tom Care
tcare at apple.com
Thu Jun 17 19:47:45 PDT 2010
I think there might be other things broken in this function too.
I'm having problems trying to get highlighting/fixits working for parts of printf statements (rather than the whole thing).
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:
/tmp/fixit.c:13:15: warning: precision used with 'n' conversion specifier,
resulting in undefined behavior [-Wformat]
printf("%100.100n", (int*) 0);
^~~~~
When what I expect is:
/tmp/fixit.c:13:15: warning: precision used with 'n' conversion specifier,
resulting in undefined behavior [-Wformat]
printf("%100.100n", (int*) 0);
^~~~
This ends up breaking the fixits, which delete the rest of the format string rather than the invalid part.
The offending line is lib/Frontend/TextDiagnosticPrinter.cpp:116
// Add in the length of the token, so that we cover multi-char tokens.
EndColNo += Lexer::MeasureTokenLength(End, SM, *LangOpts);
I'm sure this line has importance, but I don't think it is correct.
I'm a bit lost in this section! Does anyone have any ideas?
Tom
On Jun 17, 2010, at 12:05 PM, Tom Care wrote:
> Hi all,
>
> Whilst fixing bug 7377, I ran into an assertion when trying to highlight code in the following warning:
>
> flag ' ' results in undefined behavior in 'p' conversion specifier
>
> triggered by: printf("% p", p);
>
> 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.
>
> The assertion is triggered by trying to highlight the format specifier ("% p")
>
> This assertion seems valid, except for this rare case. Maybe there are others?
>
> Any ideas on how to fix this?
>
> Tom
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100617/9cca1d0b/attachment.html>
More information about the cfe-dev
mailing list