[flang-commits] [flang] 8d24800 - [flang][nfc] Add an assert to guard against `nullptr` dereferencing

Andrzej Warzynski via flang-commits flang-commits at lists.llvm.org
Tue Feb 8 02:47:06 PST 2022


Author: Andrzej Warzynski
Date: 2022-02-08T10:46:57Z
New Revision: 8d248002a66bcb963a6de53c47d1d9933ca07ee4

URL: https://github.com/llvm/llvm-project/commit/8d248002a66bcb963a6de53c47d1d9933ca07ee4
DIFF: https://github.com/llvm/llvm-project/commit/8d248002a66bcb963a6de53c47d1d9933ca07ee4.diff

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

Differential Revision: https://reviews.llvm.org/D119133

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Lower/Bridge.h b/flang/include/flang/Lower/Bridge.h
index 5398dc44a0d26..7232a85c5413c 100644
--- a/flang/include/flang/Lower/Bridge.h
+++ b/flang/include/flang/Lower/Bridge.h
@@ -64,7 +64,10 @@ class LoweringBridge {
   //===--------------------------------------------------------------------===//
 
   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;
   }


        


More information about the flang-commits mailing list