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

Varun Gandhi via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 17 22:30:18 PDT 2020


varungandhi-apple updated this revision to Diff 278972.
varungandhi-apple added a comment.

Updated commit message with reviewer information and revision link.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84087/new/

https://reviews.llvm.org/D84087

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp


Index: clang/lib/Basic/Module.cpp
===================================================================
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -173,14 +173,10 @@
 }
 
 bool Module::isSubModuleOf(const Module *Other) const {
-  const Module *This = this;
-  do {
+  for (const Module *This = this; This != nullptr; This = This->Parent) {
     if (This == Other)
       return true;
-
-    This = This->Parent;
-  } while (This);
-
+  }
   return false;
 }
 
Index: clang/include/clang/Basic/Module.h
===================================================================
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -457,8 +457,12 @@
   /// Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }
 
-  /// Determine whether this module is a submodule of the given other
-  /// module.
+  /// Check if this module is a (possibly transitive) submodule of \p Other.
+  ///
+  /// 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;
 
   /// Determine whether this module is a part of a framework,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84087.278972.patch
Type: text/x-patch
Size: 1288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200718/e3a35d27/attachment.bin>


More information about the cfe-commits mailing list