This is an archive of the discontinued LLVM Phabricator instance.

Use filename in linemarker when compiling preprocessed source (Revised)
ClosedPublic

Authored by twoh on Mar 6 2017, 10:03 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

twoh created this revision.Mar 6 2017, 10:03 AM
inglorion added inline comments.Mar 6 2017, 10:51 AM
test/Frontend/preprocessed-input.c
3 ↗(On Diff #90722)

Actually, I think you don't even have to run the preprocessor - you can just put the file with the linemarker here and check that the name from the linemarker is propagated, right?

Also, it seems that there is a similar issue to the one you're trying to fix when going from .ll to .o (or .ll to .s, for that matter) - the name is taken from the file you're reading from, not from the source_filename directive in that file. Of course, that doesn't differ from gcc (given that gcc doesn't handle .ll files), but you may want to address that, too, for consistency.

twoh added inline comments.Mar 6 2017, 11:53 AM
test/Frontend/preprocessed-input.c
3 ↗(On Diff #90722)

@inglorion Thanks for the comments! Putting preprocessed file makes sense to me.

I recognize the second issue. If I do something like

clang -E -o test.i /abspath/test.c
clang -g -c -o test.o test.i

DW_AT_name is still test.i (for gcc, it is taken from the linemarker as well).

Moreover, if we use the absolute path of test.i for clang, i.e.

clang -g -c -o test.o /abspath/test.i

DW_AT_name becomes /abspath/test.i where DW_AT_comp_dir is /abspath. I think this could be a problem if the user of the object file assumes that DW_AT_name is a relative to DW_AT_comp_dir. I'm planning to address this with a separate patch.

twoh updated this revision to Diff 90735.Mar 6 2017, 12:24 PM

addressing comments from @inglorion

inglorion accepted this revision.Mar 7 2017, 11:25 AM

Fixing the other issues in a follow-up seems fine. This lgtm.

This revision is now accepted and ready to land.Mar 7 2017, 11:25 AM
This revision was automatically updated to reflect the committed changes.