[cfe-commits] [patch][preprocessor] Remember to exit <command line>

Rafael Espindola espindola at google.com
Tue Dec 1 09:43:30 PST 2009


> Perhaps its just my ignorance of how preprocessors work, but I don't
> see why this is needed. GCC doesn't introduce such a line:
>
> % gcc -E test.c
> # 1 "test.c"
> # 1 "<built-in>"
> # 1 "<command-line>"
> # 1 "test.c"
> int main(int argc, char *argv[]) {
>  return 0;
> }
>
> It's entirely likely I just don't understand the directives being
> produced here, as there are other differences.

The difference is how gcc changes from one "file" to another. Note
that it never prints a number after the file name. According to
libcpp/directives.c:do_linemarker that gets mapped to
"LC_RENAME_VERBATIM" which, if I understand correctly, doesn't affect
the stack of files being processed.

If a number is present, they have the following meaning: 1 in
LC_ENTER, 2 is LC_LEAVE and everything else is also
LC_RENAME_VERBATIM.

So, from the gcc output everything is a LC_RENAME_VERBATIM. OK.
>From the current clang output we have

# 1 "test.c"                     LC_RENAME_VERBATIM
# 1 "test.c" 1                   LC_ENTER
# 1 "<built-in>" 1               LC_ENTER
# 1 "<built-in>" 3               LC_RENAME_VERBATIM
# 113 "<built-in>" 3             LC_RENAME_VERBATIM
# 113 "<command line>" 1         LC_ENTER
# 1 "test.c" 2                   LC_LEAVE


Notice that we leave from "<command line>" into "test.c" without
passing by "<built-in>" that we passed on the way in.

> -Chandler
>

Cheers,
-- 
Rafael Ávila de Espíndola




More information about the cfe-commits mailing list