aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp9
-rw-r--r--clang/lib/CodeGen/CGDeclCXX.cpp6
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp2
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp2
-rw-r--r--clang/lib/Sema/SemaModule.cpp2
5 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7fdbf4d..3d44f1c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1153,6 +1153,13 @@ ArrayRef<Decl *> ASTContext::getModuleInitializers(Module *M) {
return Inits->Initializers;
}
+void ASTContext::setCurrentNamedModule(Module *M) {
+ assert(M->isModulePurview());
+ assert(!CurrentCXXNamedModule &&
+ "We should set named module for ASTContext for only once");
+ CurrentCXXNamedModule = M;
+}
+
ExternCContextDecl *ASTContext::getExternCContextDecl() const {
if (!ExternCContext)
ExternCContext = ExternCContextDecl::Create(*this, getTranslationUnitDecl());
@@ -11922,7 +11929,7 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
// Variables in other module units shouldn't be forced to be emitted.
auto *VM = VD->getOwningModule();
if (VM && VM->getTopLevelModule()->isModulePurview() &&
- VM->getTopLevelModule() != getNamedModuleForCodeGen())
+ VM->getTopLevelModule() != getCurrentNamedModule())
return false;
// Variables that can be needed in other TUs are required.
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 9d7284c..04e4215 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -883,12 +883,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
// with priority emitted above. Module implementation units behave the same
// way as a non-modular TU with imports.
llvm::Function *Fn;
- if (CXX20ModuleInits && getContext().getNamedModuleForCodeGen() &&
- !getContext().getNamedModuleForCodeGen()->isModuleImplementation()) {
+ if (CXX20ModuleInits && getContext().getCurrentNamedModule() &&
+ !getContext().getCurrentNamedModule()->isModuleImplementation()) {
SmallString<256> InitFnName;
llvm::raw_svector_ostream Out(InitFnName);
cast<ItaniumMangleContext>(getCXXABI().getMangleContext())
- .mangleModuleInitializer(getContext().getNamedModuleForCodeGen(), Out);
+ .mangleModuleInitializer(getContext().getCurrentNamedModule(), Out);
Fn = CreateGlobalInitOrCleanUpFunction(
FTy, llvm::Twine(InitFnName), FI, SourceLocation(), false,
llvm::GlobalVariable::ExternalLinkage);
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7534304..d3cde11 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -529,7 +529,7 @@ static void setVisibilityFromDLLStorageClass(const clang::LangOptions &LO,
}
void CodeGenModule::Release() {
- Module *Primary = getContext().getNamedModuleForCodeGen();
+ Module *Primary = getContext().getCurrentNamedModule();
if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
EmitModuleInitializers(Primary);
EmitDeferred();
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index bda49fb..b1e7db1 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -879,7 +879,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
Module *M = HeaderInfo.lookupModule(AST->getLangOpts().CurrentModule);
if (M && AST->getLangOpts().isCompilingModule() && M->isModulePurview())
- AST->Ctx->setNamedModuleForCodeGen(M);
+ AST->Ctx->setCurrentNamedModule(M);
// Create an AST consumer, even though it isn't used.
if (ToLoad >= LoadASTOnly)
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 53e453b..e1d7c29 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().setNamedModuleForCodeGen(Mod);
+ getASTContext().setCurrentNamedModule(Mod);
// We already potentially made an implicit import (in the case of a module
// implementation unit importing its interface). Make this module visible