[PATCH] D119133: [flang][nfc] Add an assert to guard against `nullptr` dereferencing

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 7 06:11:03 PST 2022


awarzynski created this revision.
awarzynski added reviewers: rovka, kiranchandramohan, clementval, schweitz.
Herald added a project: Flang.
awarzynski requested review of this revision.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119133

Files:
  flang/include/flang/Lower/Bridge.h


Index: flang/include/flang/Lower/Bridge.h
===================================================================
--- flang/include/flang/Lower/Bridge.h
+++ flang/include/flang/Lower/Bridge.h
@@ -64,7 +64,10 @@
   //===--------------------------------------------------------------------===//
 
   mlir::MLIRContext &getMLIRContext() { return context; }
-  mlir::ModuleOp &getModule() { return *module.get(); }
+  mlir::ModuleOp &getModule() {
+    assert(module && "This bridge is missing MLIR module");
+    return *module.get();
+  }
   const Fortran::common::IntrinsicTypeDefaultKinds &getDefaultKinds() const {
     return defaultKinds;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119133.406423.patch
Type: text/x-patch
Size: 643 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220207/be6dd2cf/attachment.bin>


More information about the llvm-commits mailing list