diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2023-05-30 21:06:50 -0700 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2023-05-30 21:06:51 -0700 |
commit | e6830b6028ec5434ccf8dbebdd992918f67b1751 (patch) | |
tree | 94813ba74063a562fcfcdb8e279e3185857c8d1f /clang/lib/Basic/Module.cpp | |
parent | 0442d08fdb173d89b0779d32eb929957a344f5e6 (diff) | |
download | llvm-e6830b6028ec5434ccf8dbebdd992918f67b1751.zip llvm-e6830b6028ec5434ccf8dbebdd992918f67b1751.tar.gz llvm-e6830b6028ec5434ccf8dbebdd992918f67b1751.tar.bz2 |
[clang][modules] NFCI: Extract optionality out of `Module::{Header,DirectoryName}`
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.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D151586
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 3df376a..057fc77 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -483,15 +483,15 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const { OS << "\n"; } - if (Header H = getUmbrellaHeaderAsWritten()) { + if (std::optional<Header> H = getUmbrellaHeaderAsWritten()) { OS.indent(Indent + 2); OS << "umbrella header \""; - OS.write_escaped(H.NameAsWritten); + OS.write_escaped(H->NameAsWritten); OS << "\"\n"; - } else if (DirectoryName D = getUmbrellaDirAsWritten()) { + } else if (std::optional<DirectoryName> D = getUmbrellaDirAsWritten()) { OS.indent(Indent + 2); OS << "umbrella \""; - OS.write_escaped(D.NameAsWritten); + OS.write_escaped(D->NameAsWritten); OS << "\"\n"; } @@ -523,8 +523,8 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const { OS.indent(Indent + 2); OS << K.Prefix << "header \""; OS.write_escaped(H.NameAsWritten); - OS << "\" { size " << H.Entry->getSize() - << " mtime " << H.Entry->getModificationTime() << " }\n"; + OS << "\" { size " << H.Entry.getSize() + << " mtime " << H.Entry.getModificationTime() << " }\n"; } } for (auto *Unresolved : {&UnresolvedHeaders, &MissingHeaders}) { |