aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CIR/CodeGen/CIRGenModule.cpp
diff options
context:
space:
mode:
authorMorris Hafner <mmha@users.noreply.github.com>2025-08-13 18:03:05 +0200
committerGitHub <noreply@github.com>2025-08-13 18:03:05 +0200
commit0045bfca9c51e3b61b1e1772adf3a2c391a039c2 (patch)
treef11ba640ee62bc58653abb860e1d2fa40b9c183b /clang/lib/CIR/CodeGen/CIRGenModule.cpp
parente9b4e68928979866d5912d104eac3a1fe67f5e98 (diff)
downloadllvm-0045bfca9c51e3b61b1e1772adf3a2c391a039c2.zip
llvm-0045bfca9c51e3b61b1e1772adf3a2c391a039c2.tar.gz
llvm-0045bfca9c51e3b61b1e1772adf3a2c391a039c2.tar.bz2
[CIR} Add support for static member variable instantiation (#153200)
This patch handles both implicit and explicit template instantiations of template class static member variables.
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp')
-rw-r--r--clang/lib/CIR/CodeGen/CIRGenModule.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 45dfcf5..d529688 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -438,6 +438,20 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd,
errorNYI(funcDecl->getSourceRange(), "deferredAnnotations");
}
+void CIRGenModule::handleCXXStaticMemberVarInstantiation(VarDecl *vd) {
+ VarDecl::DefinitionKind dk = vd->isThisDeclarationADefinition();
+ if (dk == VarDecl::Definition && vd->hasAttr<DLLImportAttr>())
+ return;
+
+ TemplateSpecializationKind tsk = vd->getTemplateSpecializationKind();
+ // If we have a definition, this might be a deferred decl. If the
+ // instantiation is explicit, make sure we emit it at the end.
+ if (vd->getDefinition() && tsk == TSK_ExplicitInstantiationDefinition)
+ getAddrOfGlobalVar(vd);
+
+ emitTopLevelDecl(vd);
+}
+
mlir::Operation *CIRGenModule::getGlobalValue(StringRef name) {
return mlir::SymbolTable::lookupSymbolIn(theModule, name);
}