diff options
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaModule.cpp | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 0b872c4..9937846 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2219,6 +2219,9 @@ private: /// 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 @@ public: 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); diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index 0606b3a4..a829693 100644 --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -514,6 +514,11 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc, 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; } |