From 32c501dd88b62787d3a5ffda7aabcf4650dbe3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Duncan=20P=2E=20N=2E=20Exon=C2=A0Smith?= Date: Fri, 30 Oct 2020 16:10:10 -0400 Subject: Module: Use FileEntryRef and DirectoryEntryRef in Umbrella, Header, and DirectoryName, NFC Push `FileEntryRef` and `DirectoryEntryRef` further, using it them `Module::Umbrella`, `Module::Header::Entry`, and `Module::DirectoryName::Entry`. - Add `DirectoryEntryRef::operator const DirectoryEntry *` and `OptionalDirectoryEntryRefDegradesToDirectoryEntryPtr`, to get the same "degrades to `DirectoryEntry*` behaviour `FileEntryRef` enjoys (this avoids a bunch of churn in various clang tools). - Fix the `DirectoryEntryRef` constructor from `MapEntry` to take it by `const&`. Note that we cannot get rid of the `...AsWritten` names leveraging the new classes, since these need to be as written in the `ModuleMap` file and the module directory path is preprended for the lookup in the `FileManager`. Differential Revision: https://reviews.llvm.org/D90497 --- clang/lib/Basic/Module.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'clang/lib/Basic/Module.cpp') diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 8a8c400..9284c59 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -247,7 +247,10 @@ Module::DirectoryName Module::getUmbrellaDir() const { if (Header U = getUmbrellaHeader()) return {"", U.Entry->getDir()}; - return {UmbrellaAsWritten, Umbrella.dyn_cast()}; + if (auto *ME = Umbrella.dyn_cast()) + return {UmbrellaAsWritten, DirectoryEntryRef(*ME)}; + + return {"", None}; } void Module::addTopHeader(const FileEntry *File) { -- cgit v1.1