std::string PresumedModuleMapFile;
/// The umbrella header or directory.
- llvm::PointerUnion<const FileEntry *, const DirectoryEntry *> Umbrella;
+ llvm::PointerUnion<const FileEntryRef::MapEntry *, const DirectoryEntry *>
+ Umbrella;
/// The module signature.
ASTFileSignature Signature;
struct Header {
std::string NameAsWritten;
std::string PathRelativeToRootModuleDirectory;
- const FileEntry *Entry;
+ OptionalFileEntryRefDegradesToFileEntryPtr Entry;
- explicit operator bool() { return Entry; }
+ explicit operator bool() { return Entry.has_value(); }
};
/// Information about a directory name as found in the module map
/// Retrieve the header that serves as the umbrella header for this
/// module.
Header getUmbrellaHeader() const {
- if (auto *FE = Umbrella.dyn_cast<const FileEntry *>())
+ if (auto *ME = Umbrella.dyn_cast<const FileEntryRef::MapEntry *>())
return Header{UmbrellaAsWritten, UmbrellaRelativeToRootModuleDirectory,
- FE};
+ FileEntryRef(*ME)};
return Header{};
}
/// Sets the umbrella header of the given module to the given
/// header.
- void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader,
+ void setUmbrellaHeader(Module *Mod, FileEntryRef UmbrellaHeader,
const Twine &NameAsWritten,
const Twine &PathRelativeToRootModuleDirectory);
#include "clang/AST/DeclGroup.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileEntry.h"
#include "clang/Basic/LangStandard.h"
#include "clang/Basic/Sarif.h"
#include "clang/Frontend/ASTUnit.h"
llvm::sys::path::native(UmbrellaDir.Entry->getName(), DirNative);
llvm::vfs::FileSystem &FS = FileMgr.getVirtualFileSystem();
- SmallVector<std::pair<std::string, const FileEntry *>, 8> Headers;
+ SmallVector<
+ std::pair<std::string, OptionalFileEntryRefDegradesToFileEntryPtr>, 8>
+ Headers;
for (llvm::vfs::recursive_directory_iterator Dir(FS, DirNative, EC), End;
Dir != End && !EC; Dir.increment(EC)) {
// Check whether this entry has an extension typically associated with
.Default(false))
continue;
- auto Header = FileMgr.getFile(Dir->path());
+ auto Header = FileMgr.getOptionalFileRef(Dir->path());
// FIXME: This shouldn't happen unless there is a file system race. Is
// that worth diagnosing?
if (!Header)
// supplied by Clang. Find that builtin header.
SmallString<128> Path;
llvm::sys::path::append(Path, BuiltinIncludeDir->getName(), Header.FileName);
- auto File = SourceMgr.getFileManager().getFile(Path);
+ auto File = SourceMgr.getFileManager().getOptionalFileRef(Path);
if (!File)
return false;
// Look for an umbrella header.
SmallString<128> UmbrellaName = StringRef(FrameworkDir->getName());
llvm::sys::path::append(UmbrellaName, "Headers", ModuleName + ".h");
- auto UmbrellaHeader = FileMgr.getFile(UmbrellaName);
+ auto UmbrellaHeader = FileMgr.getOptionalFileRef(UmbrellaName);
// FIXME: If there's no umbrella header, we could probably scan the
// framework to load *everything*. But, it's not clear that this is a good
}
void ModuleMap::setUmbrellaHeader(
- Module *Mod, const FileEntry *UmbrellaHeader, const Twine &NameAsWritten,
+ Module *Mod, FileEntryRef UmbrellaHeader, const Twine &NameAsWritten,
const Twine &PathRelativeToRootModuleDirectory) {
Headers[UmbrellaHeader].push_back(KnownHeader(Mod, NormalHeader));
- Mod->Umbrella = UmbrellaHeader;
+ Mod->Umbrella = &UmbrellaHeader.getMapEntry();
Mod->UmbrellaAsWritten = NameAsWritten.str();
Mod->UmbrellaRelativeToRootModuleDirectory =
PathRelativeToRootModuleDirectory.str();
- UmbrellaDirs[UmbrellaHeader->getDir()] = Mod;
+ UmbrellaDirs[UmbrellaHeader.getDir()] = Mod;
// Notify callbacks that we just added a new header.
for (const auto &Cb : Callbacks)
SourceMgr.getFileManager().getVirtualFileSystem();
for (llvm::vfs::recursive_directory_iterator I(FS, Dir->getName(), EC), E;
I != E && !EC; I.increment(EC)) {
- if (auto FE = SourceMgr.getFileManager().getFile(I->path())) {
- Module::Header Header = {"", std::string(I->path()), *FE};
+ if (auto FE = SourceMgr.getFileManager().getOptionalFileRef(I->path())) {
+ Module::Header Header = {"", std::string(I->path()), FE};
Headers.push_back(std::move(Header));
}
}
// TODO: Make the C++20 header lookup independent.
// When the input is pre-processed source, we need a file ref to the original
// file for the header map.
- auto F = SourceMgr.getFileManager().getFile(HUName);
+ auto F = SourceMgr.getFileManager().getOptionalFileRef(HUName);
// For the sake of error recovery (if someone has moved the original header
// after creating the pre-processed output) fall back to obtaining the file
// ref for the input file, which must be present.
if (!F)
- F = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());
+ F = SourceMgr.getFileEntryRefForID(SourceMgr.getMainFileID());
assert(F && "failed to find the header unit source?");
Module::Header H{HUName.str(), HUName.str(), *F};
auto &Map = PP.getHeaderSearchInfo().getModuleMap();
Reader.ResolveImportedPath(M, Filename);
// FIXME: NameAsWritten
Module::Header H = {std::string(key.Filename), "",
- *FileMgr.getFile(Filename)};
+ FileMgr.getOptionalFileRef(Filename)};
ModMap.addHeader(Mod, H, HeaderRole, /*Imported*/true);
HFI.isModuleHeader |= ModuleMap::isModular(HeaderRole);
}
// `Headers/`, so this path will never exist.
std::string Filename = std::string(Blob);
ResolveImportedPath(F, Filename);
- if (auto Umbrella = PP.getFileManager().getFile(Filename)) {
+ if (auto Umbrella = PP.getFileManager().getOptionalFileRef(Filename)) {
if (!CurrentModule->getUmbrellaHeader()) {
// FIXME: NameAsWritten
ModMap.setUmbrellaHeader(CurrentModule, *Umbrella, Blob, "");