[clang] [CIR] Integral types; simple global variables (PR #118743)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 06:28:19 PST 2024


================
@@ -82,6 +83,14 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd,
   theModule.push_back(funcOp);
 }
 
+void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
+                                           bool isTentative) {
+  mlir::Type type = getTypes().convertType(vd->getType());
+  auto varOp = builder.create<cir::GlobalOp>(
+      getLoc(vd->getSourceRange()), vd->getIdentifier()->getName(), type);
----------------
erichkeane wrote:

`getIdentifier` could potentially result in a nullptr if this is a 'special' name (or with some other magic? I know it is possible for local variables).  So an assert/fallback for `getIdentifier==nullptr` would be appreciated here.

https://github.com/llvm/llvm-project/pull/118743


More information about the cfe-commits mailing list