[clang] [CIR] Implement 'weak-ref' lowering (PR #238538)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 4 06:55:30 PST 2026


================
@@ -1323,7 +1326,7 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
       return entry;
   }
 
-  mlir::Location loc = getLoc(d->getSourceRange());
+  mlir::Location loc = d ? getLoc(d->getSourceRange()) : theModule->getLoc();
----------------
erichkeane wrote:

Ah!  Turns out this was only ever called from one other place, so that ends up being pretty easy to do, AND there is a sensible place to get a location in the now-both-calls, so I think that makes sense.  Interestingly, we had handling (see 1335 below!) for `!d`, but are dereferencing it here, so this is the first time we've actually run into it being null before!

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


More information about the cfe-commits mailing list