diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-03-26 22:10:01 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-03-26 22:10:01 +0000 |
commit | 8f4d3ff1466a736d41e183c3275f634c129b9c09 (patch) | |
tree | 103a45d268aad62fc26b06275456db22694dfdb3 /clang/lib/Basic/Module.cpp | |
parent | 264899823fa15657971288b64393f4143d54197b (diff) | |
download | bcm5719-llvm-8f4d3ff1466a736d41e183c3275f634c129b9c09.tar.gz bcm5719-llvm-8f4d3ff1466a736d41e183c3275f634c129b9c09.zip |
[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
Diffstat (limited to 'clang/lib/Basic/Module.cpp')
-rw-r--r-- | clang/lib/Basic/Module.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
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<const FileEntry *> 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) { |