[coco] Remove cast<T> helper (#2482)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 4 Dec 2018 07:48:15 +0000 (16:48 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 4 Dec 2018 07:48:15 +0000 (16:48 +0900)
It is impossible to implement general cast<T> helper under open Instr
class hierarchy.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/Instr.h
contrib/coco/core/src/IR/Instr.cpp
contrib/coco/core/src/IR/Module.test.cpp

index 16a1fd9..0a404cd 100644 (file)
@@ -142,14 +142,6 @@ template <typename T> bool isa(const Instr *ins);
 /**
  * @brief Cast as a derived instruction
  *
- * @note "ins" cannot be a null pointer
- * @note The behavior is undefined when "isa<T>(ins)" does not hold.
- */
-template <typename T> T *cast(Instr *ins);
-
-/**
- * @brief Cast as a derived instruction
- *
  * @note "safe_cast<T>(ins)" returns a null pointer if "ins" is not of T type
  * @note "safe_cast<T>(ins)" returns a null pointer if "ins" is a null pointer
  */
index ee63005..bc223f7 100644 (file)
@@ -66,20 +66,6 @@ template <> InstrList *DLinkedList<Instr, Block>::head(Block *b) { return b->ins
 #undef INSTR
 
 //
-// cast<T>
-//
-#define INSTR(Name)                         \
-  template <> Name *cast<Name>(Instr * ins) \
-  {                                         \
-    assert(ins != nullptr);                 \
-    auto casted = ins->as##Name();          \
-    assert(casted != nullptr);              \
-    return casted;                          \
-  }
-#include "coco/IR/Instr.lst"
-#undef INSTR
-
-//
 // safe_cast<T>
 //
 #define INSTR(Name) \
index a4ee668..b55ceac 100644 (file)
@@ -186,7 +186,6 @@ TEST(IR_Module, create_entites)
     auto ins = entity->instr()->create<Name>();     \
     ASSERT_EQ(ins->module(), m.get());              \
     ASSERT_TRUE(coco::isa<Name>(ins));              \
-    ASSERT_NE(coco::cast<Name>(ins), nullptr);      \
     ASSERT_NE(coco::safe_cast<Name>(ins), nullptr); \
   }
 #include "coco/IR/Instr.lst"