From 8f4d3ff1466a736d41e183c3275f634c129b9c09 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 26 Mar 2015 22:10:01 +0000 Subject: [modules] Restrict the module use-declaration to only appear in top-level modules, and allow sub-modules of a module with a use-declaration to make use of the nominated modules. llvm-svn: 233323 --- clang/lib/Basic/Module.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'clang/lib/Basic/Module.cpp') diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index e7e37ced809..5fad1a9b229 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -158,6 +158,19 @@ ArrayRef Module::getTopHeaders(FileManager &FileMgr) { return llvm::makeArrayRef(TopHeaders.begin(), TopHeaders.end()); } +bool Module::directlyUses(const Module *Requested) const { + auto *Top = getTopLevelModule(); + + // A top-level module implicitly uses itself. + if (Requested->isSubModuleOf(Top)) + return true; + + for (auto *Use : Top->DirectUses) + if (Requested->isSubModuleOf(Use)) + return true; + return false; +} + void Module::addRequirement(StringRef Feature, bool RequiredState, const LangOptions &LangOpts, const TargetInfo &Target) { -- cgit v1.2.3