diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-04-14 21:41:27 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-06-22 18:20:56 +0000 |
| commit | bdd1243df58e60e85101c09001d9812a789b6bc4 (patch) | |
| tree | a1ce621c7301dd47ba2ddc3b8eaa63b441389481 /contrib/llvm-project/clang/lib/Basic/Module.cpp | |
| parent | 781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff) | |
| parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) | |
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic/Module.cpp')
| -rw-r--r-- | contrib/llvm-project/clang/lib/Basic/Module.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/Module.cpp b/contrib/llvm-project/clang/lib/Basic/Module.cpp index 17b83184abb6..9c4c83486c2d 100644 --- a/contrib/llvm-project/clang/lib/Basic/Module.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Module.cpp @@ -148,6 +148,26 @@ bool Module::isUnimportable(const LangOptions &LangOpts, llvm_unreachable("could not find a reason why module is unimportable"); } +// The -fmodule-name option tells the compiler to textually include headers in +// the specified module, meaning Clang won't build the specified module. This +// is useful in a number of situations, for instance, when building a library +// that vends a module map, one might want to avoid hitting intermediate build +// products containing the module map or avoid finding the system installed +// modulemap for that library. +bool Module::isForBuilding(const LangOptions &LangOpts) const { + StringRef TopLevelName = getTopLevelModuleName(); + StringRef CurrentModule = LangOpts.CurrentModule; + + // When building framework Foo, we want to make sure that Foo *and* + // Foo_Private are textually included and no modules are built for both. + if (getTopLevelModule()->IsFramework && + CurrentModule == LangOpts.ModuleName && + !CurrentModule.endswith("_Private") && TopLevelName.endswith("_Private")) + TopLevelName = TopLevelName.drop_back(8); + + return TopLevelName == CurrentModule; +} + bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target, Requirement &Req, UnresolvedHeaderDirective &MissingHeader, @@ -264,7 +284,7 @@ ArrayRef<const FileEntry *> Module::getTopHeaders(FileManager &FileMgr) { TopHeaderNames.clear(); } - return llvm::makeArrayRef(TopHeaders.begin(), TopHeaders.end()); + return llvm::ArrayRef(TopHeaders.begin(), TopHeaders.end()); } bool Module::directlyUses(const Module *Requested) { @@ -633,7 +653,9 @@ LLVM_DUMP_METHOD void Module::dump() const { void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc, VisibleCallback Vis, ConflictCallback Cb) { - assert(Loc.isValid() && "setVisible expects a valid import location"); + // We can't import a global module fragment so the location can be invalid. + assert((M->isGlobalModule() || Loc.isValid()) && + "setVisible expects a valid import location"); if (isVisible(M)) return; @@ -653,7 +675,7 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation Loc, return; ImportLocs[ID] = Loc; - Vis(M); + Vis(V.M); // Make any exported modules visible. SmallVector<Module *, 16> Exports; |
