[cfe-commits] [PATCH] Fix crash printing diagnostic range spanning macros

Jordan Rose jordan_rose at apple.com
Thu Oct 25 09:38:23 PDT 2012

I think that's the best we can do. Even if the range had the beginning before the end (say, by trying to highlight the entirety of both macros), it wouldn't be "correct".  We should not show ranges that don't correspond to something meaningful in the text.

...though arguably we could show a line with all macros expanded, and put the range there. But that's a big change in what you expect from diagnostic printing, and it wouldn't work in IDEs anyway.


On Oct 24, 2012, at 19:36 , Eli Friedman <eli.friedman at gmail.com> wrote:

> Patch attached.  Fixes a crash on a testcase like the following:
> +#define BAD_CONDITIONAL_OPERATOR (2<3)?4:5
> We try to print a source range which starts at the 5 in the first
> expansion, and ends just after the 3 in the second expansion. This
> causes an assertion failure in diagnostic emission because the
> beginning of the range appears to be after the end.
> My attempted fix is to try to suppress printing source ranges when the
> beginning and end point into different macro expansions (even if the
> physical locations happen to be on the same line).  I'm not confident
> this is the correct fix, but it seems to be roughly on the right
> track.  Any comments welcome.
> (This is <rdar://problem/12472249>.)
> -Eli
> <sourcerange_assert.txt>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121025/6a8befaf/attachment.html>

More information about the cfe-commits mailing list