From 157e5cbc6e08e1dba8202e6d72b2c76420471bdc Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 4 Dec 2018 16:48:15 +0900 Subject: [PATCH] [coco] Remove cast helper (#2482) It is impossible to implement general cast helper under open Instr class hierarchy. Signed-off-by: Jonghyun Park --- contrib/coco/core/include/coco/IR/Instr.h | 8 -------- contrib/coco/core/src/IR/Instr.cpp | 14 -------------- contrib/coco/core/src/IR/Module.test.cpp | 1 - 3 files changed, 23 deletions(-) diff --git a/contrib/coco/core/include/coco/IR/Instr.h b/contrib/coco/core/include/coco/IR/Instr.h index 16a1fd9..0a404cd 100644 --- a/contrib/coco/core/include/coco/IR/Instr.h +++ b/contrib/coco/core/include/coco/IR/Instr.h @@ -142,14 +142,6 @@ template 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(ins)" does not hold. - */ -template T *cast(Instr *ins); - -/** - * @brief Cast as a derived instruction - * * @note "safe_cast(ins)" returns a null pointer if "ins" is not of T type * @note "safe_cast(ins)" returns a null pointer if "ins" is a null pointer */ diff --git a/contrib/coco/core/src/IR/Instr.cpp b/contrib/coco/core/src/IR/Instr.cpp index ee63005..bc223f7 100644 --- a/contrib/coco/core/src/IR/Instr.cpp +++ b/contrib/coco/core/src/IR/Instr.cpp @@ -66,20 +66,6 @@ template <> InstrList *DLinkedList::head(Block *b) { return b->ins #undef INSTR // -// cast -// -#define INSTR(Name) \ - template <> Name *cast(Instr * ins) \ - { \ - assert(ins != nullptr); \ - auto casted = ins->as##Name(); \ - assert(casted != nullptr); \ - return casted; \ - } -#include "coco/IR/Instr.lst" -#undef INSTR - -// // safe_cast // #define INSTR(Name) \ diff --git a/contrib/coco/core/src/IR/Module.test.cpp b/contrib/coco/core/src/IR/Module.test.cpp index a4ee668..b55ceac 100644 --- a/contrib/coco/core/src/IR/Module.test.cpp +++ b/contrib/coco/core/src/IR/Module.test.cpp @@ -186,7 +186,6 @@ TEST(IR_Module, create_entites) auto ins = entity->instr()->create(); \ ASSERT_EQ(ins->module(), m.get()); \ ASSERT_TRUE(coco::isa(ins)); \ - ASSERT_NE(coco::cast(ins), nullptr); \ ASSERT_NE(coco::safe_cast(ins), nullptr); \ } #include "coco/IR/Instr.lst" -- 2.7.4