[PATCH] D118589: [C++20][Modules][6/8] Record direct module imports.

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 27 02:07:39 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG853ca5472314: [C++20][Modules][6/8] Record direct module imports. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118589

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaModule.cpp


Index: clang/lib/Sema/SemaModule.cpp
===================================================================
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -514,6 +514,11 @@
     assert(ThisModule && "was expecting a module if building one");
   }
 
+  // In some cases we need to know if an entity was present in a directly-
+  // imported module (as opposed to a transitive import).  This avoids
+  // searching both Imports and Exports.
+  DirectModuleImports.insert(Mod);
+
   return Import;
 }
 
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -2219,6 +2219,9 @@
   /// The global module fragment of the current translation unit.
   clang::Module *GlobalModuleFragment = nullptr;
 
+  /// The modules we imported directly.
+  llvm::SmallPtrSet<clang::Module *, 8> DirectModuleImports;
+
   /// Namespace definitions that we will export when they finish.
   llvm::SmallPtrSet<const NamespaceDecl*, 8> DeferredExportedNamespaces;
 
@@ -2246,6 +2249,10 @@
     return Entity->getOwningModule();
   }
 
+  bool isModuleDirectlyImported(const Module *M) {
+    return DirectModuleImports.contains(M);
+  }
+
   /// Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118589.411664.patch
Type: text/x-patch
Size: 1427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220227/9b534e76/attachment.bin>


More information about the cfe-commits mailing list