This is an archive of the discontinued LLVM Phabricator instance.

PCH + Module: make sure we write out macros associated with builtin identifiers
ClosedPublic

Authored by manmanren on May 18 2016, 2:00 PM.

Details

Summary

When we import a module that defines a builtin identifier from prefix header and precompile the prefix header, the macro information related to the identifier is lost.
If we don't precompile the prefix header, the source file can still see the macro information.
The reason is that we write out the identifier in the pch but not the macro information since the macro is not defined locally.

This seems to be related to r251565: If we read a builtin identifier from a module that wasn't "interesting" to that module, we will still write it out to a PCH that imports that module.

The fix proposed here is to write exported module macros for PCH as well. I am open to other suggestions.

Diff Detail

Repository
rL LLVM

Event Timeline

manmanren updated this revision to Diff 57673.May 18 2016, 2:00 PM
manmanren retitled this revision from to PCH + Module: make sure we write out macros associated with builtin identifiers.
manmanren updated this object.
manmanren added reviewers: benlangmuir, rsmith.
manmanren added a subscriber: cfe-commits.
bruno added a subscriber: bruno.May 18 2016, 5:35 PM

Hi Manman,

lib/Serialization/ASTWriter.cpp
2191 ↗(On Diff #57673)

Is this intended?

Thanks Bruno

lib/Serialization/ASTWriter.cpp
2191 ↗(On Diff #57673)

I was trying to make sure people get that it is the only thing this patch changes :) I will remove it if we are okay with this approach.

benlangmuir edited edge metadata.May 23 2016, 11:17 AM
benlangmuir added a subscriber: doug.gregor.

I'd like to see Doug and/or Richard review this. It seems reasonable to me to first blush, but I assume there was a good reason we weren't doing this already...

Doug and Richard,

Can you take a look at this when you have time?

Thanks,
Manman

doug.gregor edited edge metadata.May 30 2016, 8:16 AM

Yeah, this looks like the right approach. PCH follows the same rules as modules when it comes to newer information shadowing imported information.

Yeah, this looks like the right approach. PCH follows the same rules as modules when it comes to newer information shadowing imported information.

Hi Doug,

Thanks for reviewing the patch! Can I take that as a "LGTM"? I will clean up the source change.

Manman

doug.gregor accepted this revision.May 31 2016, 10:54 AM
doug.gregor edited edge metadata.

Yes, that's a LGTM, sorry for being unclear.

This revision is now accepted and ready to land.May 31 2016, 10:54 AM
rsmith accepted this revision.May 31 2016, 11:08 AM
rsmith edited edge metadata.

Looks good to me, too.

This revision was automatically updated to reflect the committed changes.