[Mlir-commits] [mlir] c71101d - [mlir] Initialize the Region::container field to nullptr by default

Alex Zinenko llvmlistbot at llvm.org
Sun May 10 05:23:44 PDT 2020


Author: Alex Zinenko
Date: 2020-05-10T14:23:35+02:00
New Revision: c71101d9efced2291d46992d32dc88577aef2cf6

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

LOG: [mlir] Initialize the Region::container field to nullptr by default

Region has a default constructor that is called when a region is constructed
while an operation is being created, and therefore before the region can be
attached to this operation. The `container` field is uninitialized, which makes
it impossible to check programmatically if a Region is attached to an operation
or not, leading to sly memory errors when this field is read. Initialize it to
nullptr by default and thus make sure one can check if a region is attached to
an operation or not.

Added: 
    

Modified: 
    mlir/include/mlir/IR/Region.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h
index 0efa58ca4c0a..35e773d74385 100644
--- a/mlir/include/mlir/IR/Region.h
+++ b/mlir/include/mlir/IR/Region.h
@@ -231,7 +231,7 @@ class Region {
   BlockListType blocks;
 
   /// This is the object we are part of.
-  Operation *container;
+  Operation *container = nullptr;
 };
 
 /// This class provides an abstraction over the 
diff erent types of ranges over


        


More information about the Mlir-commits mailing list