Skip to content

Commit e52fbb8

Browse files
committed
[AST] Intro a check for the export_as relationship between 2 modules
1 parent c0abde0 commit e52fbb8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/swift/AST/Module.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,10 @@ class ModuleDecl
877877
/// Returns the associated clang module if one exists.
878878
const clang::Module *findUnderlyingClangModule() const;
879879

880+
/// Does this module or the underlying clang module defines export_as with
881+
/// a value corresponding to the \p other module?
882+
bool isExportedAs(const ModuleDecl *other) const;
883+
880884
/// Returns a generator with the components of this module's full,
881885
/// hierarchical name.
882886
///

lib/AST/Module.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,14 @@ const clang::Module *ModuleDecl::findUnderlyingClangModule() const {
21752175
return nullptr;
21762176
}
21772177

2178+
bool ModuleDecl::isExportedAs(const ModuleDecl *other) const {
2179+
auto clangModule = findUnderlyingClangModule();
2180+
if (!clangModule)
2181+
return false;
2182+
2183+
return other->getRealName().str() == clangModule->ExportAsModule;
2184+
}
2185+
21782186
void ModuleDecl::collectBasicSourceFileInfo(
21792187
llvm::function_ref<void(const BasicSourceFileInfo &)> callback) const {
21802188
for (const FileUnit *fileUnit : getFiles()) {

0 commit comments

Comments
 (0)