This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules] NFCI: Extract optionality out of `Module::{Header,DirectoryName}`
ClosedPublic

Authored by jansvoboda11 on May 26 2023, 1:41 PM.

Details

Summary

Most users of Module::Header already assume its Entry is populated. Enforce this assumption in the type system and handle the only case where this is not the case by wrapping the whole struct in std::optional. Do the same for Module::DirectoryName.

Depends on D151584.

Diff Detail

Event Timeline

jansvoboda11 created this revision.May 26 2023, 1:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2023, 1:41 PM
Herald added a subscriber: ributzka. · View Herald Transcript
jansvoboda11 requested review of this revision.May 26 2023, 1:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2023, 1:41 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
benlangmuir accepted this revision.May 26 2023, 2:10 PM
benlangmuir added inline comments.
clang/lib/Basic/Module.cpp
486

These are on the edge, but I think I would lean towards spelling the typename here since it's not obvious from the name of the API what exactly it would be

This revision is now accepted and ready to land.May 26 2023, 2:10 PM

Change auto to std::optional<...> in all places

Herald added a project: Restricted Project. · View Herald TranscriptMay 30 2023, 5:00 PM
This revision was landed with ongoing or failed builds.May 30 2023, 9:24 PM
This revision was automatically updated to reflect the committed changes.