[coco] Ensure Bag has no reference on destruction (#1449)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 11 Sep 2018 08:37:36 +0000 (17:37 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 11 Sep 2018 08:37:36 +0000 (17:37 +0900)
This commit introduces several asserts inside Bag's destructor to ensure
that each bag has no reference in IR on destruction.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/src/IR/Bag.cpp

index e3faf4c..1e2e4e4 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <nncc/foundation/Memory.h>
 
+#include <cassert>
+
 namespace coco
 {
 
@@ -17,7 +19,10 @@ Bag::Bag(std::unique_ptr<BagInfo> &&info) : _info{std::move(info)}
 
 Bag::~Bag()
 {
-  // DO NOTHING
+  // All the references over a bag SHOULD be dropped before its destruction
+  assert(_info->deps()->size() == 0);
+  assert(_info->reads()->size() == 0);
+  assert(_info->updates()->size() == 0);
 }
 
 uint32_t Bag::size(void) const { return _info->size(); }