aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2023-05-16 10:36:08 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2023-05-16 10:47:53 +0800
commit7f37066915ab330f153ede708ddc610cf2cb7bdf (patch)
treed818c1150593ea83a586c21b0fd0845d781d2549 /clang/lib/Sema/SemaModule.cpp
parent40c30543892aa6441eea075ba69864e79f5de82e (diff)
downloadllvm-7f37066915ab330f153ede708ddc610cf2cb7bdf.zip
llvm-7f37066915ab330f153ede708ddc610cf2cb7bdf.tar.gz
llvm-7f37066915ab330f153ede708ddc610cf2cb7bdf.tar.bz2
Revert "[NFC] [C++20] [Modules] Refactor Sema::isModuleUnitOfCurrentTU into"
This reverts commit f109b1016801e2b0dbee278f3c517057c0b1d441 as required in https://github.com/llvm/llvm-project/commit/f109b1016801e2b0dbee278f3c517057c0b1d441#commitcomment-113477829.
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 5815795..53e453b 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -389,7 +389,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
// statements, so imports are allowed.
ImportState = ModuleImportState::ImportAllowed;
- getASTContext().setCurrentNamedModule(Mod);
+ getASTContext().setNamedModuleForCodeGen(Mod);
// We already potentially made an implicit import (in the case of a module
// implementation unit importing its interface). Make this module visible
@@ -1021,3 +1021,16 @@ void Sema::PopImplicitGlobalModuleFragment() {
"left the wrong module scope, which is not global module fragment");
ModuleScopes.pop_back();
}
+
+bool Sema::isModuleUnitOfCurrentTU(const Module *M) const {
+ assert(M);
+
+ Module *CurrentModuleUnit = getCurrentModule();
+
+ // If we are not in a module currently, M must not be the module unit of
+ // current TU.
+ if (!CurrentModuleUnit)
+ return false;
+
+ return M->isSubModuleOf(CurrentModuleUnit->getTopLevelModule());
+}