This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules] Avoid serializing all diag mappings in non-deterministic order
ClosedPublic

Authored by benlangmuir on Jun 28 2023, 4:27 PM.

Details

Summary

When writing a pcm, we serialize diagnostic mappings in order to
accurately reproduce the diagnostic environment inside any headers from
that module. However, the diagnostic state mapping table contains
entries for every diagnostic ID ever accessed, while we only want to
serialize the ones that are actually modified from their default value.
Futher, we need to serialize them in a deterministic order.

rdar://111477511

Diff Detail

Event Timeline

benlangmuir created this revision.Jun 28 2023, 4:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 4:27 PM
Herald added a subscriber: mgrang. · View Herald Transcript
benlangmuir requested review of this revision.Jun 28 2023, 4:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2023, 4:27 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
steven_wu added inline comments.Jun 29 2023, 9:49 AM
clang/lib/Serialization/ASTWriter.cpp
3016–3034

Is pragma in this context refer to #pragma diagnostics push/pop? Do we have test to cover those to be deterministic?

Extended test to include diagnostic pragmas

benlangmuir marked an inline comment as done.Jun 29 2023, 10:33 AM
benlangmuir added inline comments.
clang/lib/Serialization/ASTWriter.cpp
3016–3034

Is pragma in this context refer to #pragma diagnostics push/pop?

Yeah, this is diagnostic pragmas.

Do we have test to cover those to be deterministic?

I extended the current test to include some pragmas as well. It's harder to check them exhaustively because the encoded format gets more complex, but I checked the specific mappings are in order and the diff part of the test should help catch any other non-determinism there could be.

This revision is now accepted and ready to land.Jun 29 2023, 10:55 AM
This revision was landed with ongoing or failed builds.Jun 29 2023, 1:17 PM
This revision was automatically updated to reflect the committed changes.
benlangmuir marked an inline comment as done.