This is an archive of the discontinued LLVM Phabricator instance.

Use the file name from linemarker for debug info if an input is preprocessed source.
ClosedPublic

Authored by twoh on Aug 8 2017, 10:35 AM.

Details

Summary

Even in the case of the input file is a preprocessed source, clang uses the file name of the preprocesses source for debug info (DW_AT_name attribute for DW_TAG_compile_unit). However, gcc uses the file name specified in the first linemarker instead. This makes more sense because the one specified in the linemarker represents the "actual" source file name.

Clang already uses the file name specified in the first linemarker for Module name (https://github.com/llvm-mirror/clang/blob/master/lib/Frontend/FrontendAction.cpp#L779) if the input is preprocessed. This patch makes clang to use the same value for debug info as well.

Event Timeline

twoh created this revision.Aug 8 2017, 10:35 AM
twoh updated this revision to Diff 110230.Aug 8 2017, 10:39 AM

Relocate.

dblaikie edited edge metadata.Aug 8 2017, 10:43 AM

Looks plausible (not sure how nice it is to use the llvm::Module itself to communicate the file name to this bit of logic - I'll leave that to Richard Smith to judge, I think)

test/CodeGen/debug-info-preprocessed-file.i
11

Should probably be a bit more specific in the check - verifying that the DICompileUnit's DIFile is the one you're checking here. (not that there's any other DI* that would have a DIFile here, but still)

twoh updated this revision to Diff 110237.Aug 8 2017, 11:10 AM

Addressing dblaikie's comments. Thanks!

twoh added a comment.Aug 16 2017, 10:38 AM

Ping. Thanks!

rnk accepted this revision.Aug 16 2017, 10:45 AM

lgtm

This revision is now accepted and ready to land.Aug 16 2017, 10:45 AM
This revision was automatically updated to reflect the committed changes.