[NFC] Clean up doc comment and implementation for Module::isSubModuleOf.

Patch by Varun Gandhi!

Differential Revision: https://reviews.llvm.org/D84087
This commit is contained in:
Adrian Prantl 2020-07-21 16:03:56 -07:00
parent bf6bc62d1f
commit b907ad539a
2 changed files with 9 additions and 9 deletions

View File

@ -457,8 +457,12 @@ public:
/// Determine whether this module is a submodule. /// Determine whether this module is a submodule.
bool isSubModule() const { return Parent != nullptr; } bool isSubModule() const { return Parent != nullptr; }
/// Determine whether this module is a submodule of the given other /// Check if this module is a (possibly transitive) submodule of \p Other.
/// module. ///
/// The 'A is a submodule of B' relation is a partial order based on the
/// the parent-child relationship between individual modules.
///
/// Returns \c false if \p Other is \c nullptr.
bool isSubModuleOf(const Module *Other) const; bool isSubModuleOf(const Module *Other) const;
/// Determine whether this module is a part of a framework, /// Determine whether this module is a part of a framework,

View File

@ -173,14 +173,10 @@ bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
} }
bool Module::isSubModuleOf(const Module *Other) const { bool Module::isSubModuleOf(const Module *Other) const {
const Module *This = this; for (auto *Parent = this; Parent; Parent = Parent->Parent) {
do { if (Parent == Other)
if (This == Other)
return true; return true;
}
This = This->Parent;
} while (This);
return false; return false;
} }