aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Module.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2023-10-20 18:23:19 +0200
committerGitHub <noreply@github.com>2023-10-20 09:23:19 -0700
commit1afb313b26851bdb050061f6d786c83ec1f569a3 (patch)
treef66955a25346da6cdef20b7fdef846c7e97a354e /clang/lib/Basic/Module.cpp
parentcb62f67088aaf79493350547f74870318b71acc5 (diff)
downloadllvm-1afb313b26851bdb050061f6d786c83ec1f569a3.zip
llvm-1afb313b26851bdb050061f6d786c83ec1f569a3.tar.gz
llvm-1afb313b26851bdb050061f6d786c83ec1f569a3.tar.bz2
[clang][modules] Use file name as requested (#68957)
This prevents redefinition errors due to having multiple paths for the same module map. (rdar://24116019) Originally implemented and tested downstream by @bcardosolopes, I just made use of `FileEntryRef::getNameAsRequested()`.
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r--clang/lib/Basic/Module.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 7879a11..cc2e5be 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -265,10 +265,10 @@ bool Module::fullModuleNameIs(ArrayRef<StringRef> nameParts) const {
}
OptionalDirectoryEntryRef Module::getEffectiveUmbrellaDir() const {
- if (Umbrella && Umbrella.is<FileEntryRef>())
- return Umbrella.get<FileEntryRef>().getDir();
- if (Umbrella && Umbrella.is<DirectoryEntryRef>())
- return Umbrella.get<DirectoryEntryRef>();
+ if (const auto *Hdr = std::get_if<FileEntryRef>(&Umbrella))
+ return Hdr->getDir();
+ if (const auto *Dir = std::get_if<DirectoryEntryRef>(&Umbrella))
+ return *Dir;
return std::nullopt;
}