[cfe-commits] [PATCH] PR6101: Preprocessor doesn't honor #line directives
clattner at apple.com
Mon Apr 12 19:03:44 CDT 2010
On Apr 10, 2010, at 10:13 PM, Jordy Rose wrote:
> PR6101 is a little misleading; #line directives /are/ honored, but not by
> PrintPreprocessorOutput.cpp (-E mode). (Unless there is a separate problem
> on PC Linux.) This patch fixes that by using presumed locations instead of
> instantiation locations.
> There is a bit of a hack to handle the fact that actually entering and
> exiting source files looks the same as GNU linemarkers. (System header
> markers and normal "renames" are always from directives.)
> - Entering a file counts as a line directive if the include location is in
> the same file as the file itself.
> - Exiting a file counts as a line directive...if the exit doesn't happen
> at the beginning of a line. This is a kludge, and takes advantage of
> #include eating the newline before loading the next file, but I couldn't
> think of a better test that got everything correct (including the exit
> linemarkers in the predefines).
Thanks for the patch, I ended up with a slightly different approach in r101097. It turns out that GCC is wildly inconsistent with the exact number it uses for line markers and this is the closest I could reasonably get. I removed the .h part of your testcase because GCC was not accepting it (generating great errors in linemap.c :).
More information about the cfe-commits