From e6830b6028ec5434ccf8dbebdd992918f67b1751 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Tue, 30 May 2023 21:06:50 -0700 Subject: [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 --- clang/lib/Lex/ModuleMap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'clang/lib/Lex/ModuleMap.cpp') diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 6808fdf..bfd4890 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -1289,7 +1289,7 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header, // Notify callbacks that we just added a new header. for (const auto &Cb : Callbacks) - Cb->moduleMapAddHeader(Header.Entry->getName()); + Cb->moduleMapAddHeader(Header.Entry.getName()); } OptionalFileEntryRef @@ -2541,7 +2541,7 @@ void ModuleMapParser::parseUmbrellaDirDecl(SourceLocation UmbrellaLoc) { for (llvm::vfs::recursive_directory_iterator I(FS, Dir->getName(), EC), E; I != E && !EC; I.increment(EC)) { if (auto FE = SourceMgr.getFileManager().getOptionalFileRef(I->path())) { - Module::Header Header = {"", std::string(I->path()), FE}; + Module::Header Header = {"", std::string(I->path()), *FE}; Headers.push_back(std::move(Header)); } } -- cgit v1.1