[flang][nfc] Add an assert to guard against `nullptr` dereferencing
authorAndrzej Warzynski <andrzej.warzynski@arm.com>
Mon, 7 Feb 2022 14:03:49 +0000 (14:03 +0000)
committerAndrzej Warzynski <andrzej.warzynski@arm.com>
Tue, 8 Feb 2022 10:46:57 +0000 (10:46 +0000)
Differential Revision: https://reviews.llvm.org/D119133

flang/include/flang/Lower/Bridge.h

index 5398dc4..7232a85 100644 (file)
@@ -64,7 +64,10 @@ public:
   //===--------------------------------------------------------------------===//
 
   mlir::MLIRContext &getMLIRContext() { return context; }
-  mlir::ModuleOp &getModule() { return *module.get(); }
+  mlir::ModuleOp &getModule() {
+    assert(module && "This bridge is missing an MLIR module");
+    return *module.get();
+  }
   const Fortran::common::IntrinsicTypeDefaultKinds &getDefaultKinds() const {
     return defaultKinds;
   }