Use the new source ranges tracking feature to highlight the important pieces
of a subexpression when emitting a diagnostic. Consider this example: struct A { int X; }; void test1(void *P, int C) { return ((C*40) + *P) / 42+P; } void test2(struct A friendlystruct, int C) { return (C *40) + friendlystruct; } void test3(struct A friendlystruct, int C) { return friendlystruct + test2(friendlystruct , C); } clang now produces this output: t.c:4:18: error: invalid operands to binary expression ('int' and 'void') return ((C*40) + *P) / 42+P; ~~~~~~ ^ ~~ This shows the important pieces of a nested (and potentially very complex) expression. t.c:8:18: error: invalid operands to binary expression ('int' and 'struct A') return (C *40) + friendlystruct; ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~ This shows that tabs in source files (after the 'C') and multichar tokens (friendlystruct) are handled correctly. t.c:12:25: error: invalid operands to binary expression ('struct A' and 'void') return friendlystruct + test2(friendlystruct ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~ This shows how multiline ranges are printed. Any part of the range that is not on the same line as the carat is just ignored. This also shows that trailing spaces on the line aren't highlighted. llvm-svn: 39459
Loading
Please register or sign in to comment