Skip to content

Commit b907ad5

Browse files
committed
[NFC] Clean up doc comment and implementation for Module::isSubModuleOf.
Patch by Varun Gandhi! Differential Revision: https://reviews.llvm.org/D84087
1 parent bf6bc62 commit b907ad5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang/include/clang/Basic/Module.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,12 @@ class Module {
457457
/// Determine whether this module is a submodule.
458458
bool isSubModule() const { return Parent != nullptr; }
459459

460-
/// Determine whether this module is a submodule of the given other
461-
/// module.
460+
/// Check if this module is a (possibly transitive) submodule of \p Other.
461+
///
462+
/// The 'A is a submodule of B' relation is a partial order based on the
463+
/// the parent-child relationship between individual modules.
464+
///
465+
/// Returns \c false if \p Other is \c nullptr.
462466
bool isSubModuleOf(const Module *Other) const;
463467

464468
/// Determine whether this module is a part of a framework,

clang/lib/Basic/Module.cpp

+3-7
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,10 @@ bool Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,
173173
}
174174

175175
bool Module::isSubModuleOf(const Module *Other) const {
176-
const Module *This = this;
177-
do {
178-
if (This == Other)
176+
for (auto *Parent = this; Parent; Parent = Parent->Parent) {
177+
if (Parent == Other)
179178
return true;
180-
181-
This = This->Parent;
182-
} while (This);
183-
179+
}
184180
return false;
185181
}
186182

0 commit comments

Comments
 (0)