aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2021-12-23 20:47:28 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2021-12-23 20:51:05 +0800
commit368318bcce66d9fef420fc34cca361b79d80cee5 (patch)
tree76d80fd4897a33631eca1d4832043c94d9e4d7db /clang/lib/Sema/SemaModule.cpp
parent23f1cd9e635757edd7a7877a80a36f5f9e53ae28 (diff)
downloadllvm-368318bcce66d9fef420fc34cca361b79d80cee5.zip
llvm-368318bcce66d9fef420fc34cca361b79d80cee5.tar.gz
llvm-368318bcce66d9fef420fc34cca361b79d80cee5.tar.bz2
[C++20] [Coroutines] Mark imported module as imported if not exported
In C++20 Modules, imported module which doesn't get exported wouldn't be recorded. This patch would record such modules to avoid possible incorrect visibility problems. Reviewed By: urnathan Differential Revision: https://reviews.llvm.org/D116098
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index f497199..a4b9f3c 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -383,11 +383,18 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
if (!ModuleScopes.empty())
Context.addModuleInitializer(ModuleScopes.back().Module, Import);
- // Re-export the module if needed.
if (!ModuleScopes.empty() && ModuleScopes.back().ModuleInterface) {
+ // Re-export the module if the imported module is exported.
+ // Note that we don't need to add re-exported module to Imports field
+ // since `Exports` implies the module is imported already.
if (ExportLoc.isValid() || getEnclosingExportDecl(Import))
getCurrentModule()->Exports.emplace_back(Mod, false);
+ else
+ getCurrentModule()->Imports.insert(Mod);
} else if (ExportLoc.isValid()) {
+ // [module.interface]p1:
+ // An export-declaration shall inhabit a namespace scope and appear in the
+ // purview of a module interface unit.
Diag(ExportLoc, diag::err_export_not_in_module_interface);
}