From: Tim King Date: Mon, 13 Aug 2018 16:25:26 +0000 (-0700) Subject: Removing support for T* and const T* attributes. (#2297) X-Git-Tag: cvc5-1.0.0~4788 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=957b02e415f60e725da569f1d7c0e2d1276cb3fa;p=cvc5.git Removing support for T* and const T* attributes. (#2297) * Removing support for T* and const T* attributes. These are unused. --- diff --git a/src/expr/attribute.cpp b/src/expr/attribute.cpp index eeb6d00a0..9481cde99 100644 --- a/src/expr/attribute.cpp +++ b/src/expr/attribute.cpp @@ -50,7 +50,6 @@ void AttributeManager::deleteAllAttributes(NodeValue* nv) { deleteFromTable(d_nodes, nv); deleteFromTable(d_types, nv); deleteFromTable(d_strings, nv); - deleteFromTable(d_ptrs, nv); } void AttributeManager::deleteAllAttributes() { @@ -60,7 +59,6 @@ void AttributeManager::deleteAllAttributes() { deleteAllFromTable(d_nodes); deleteAllFromTable(d_types); deleteAllFromTable(d_strings); - deleteAllFromTable(d_ptrs); } void AttributeManager::deleteAttributes(const AttrIdVec& atids) { @@ -98,9 +96,6 @@ void AttributeManager::deleteAttributes(const AttrIdVec& atids) { case AttrTableString: deleteAttributesFromTable(d_strings, ids); break; - case AttrTablePointer: - deleteAttributesFromTable(d_ptrs, ids); - break; case AttrTableCDBool: case AttrTableCDUInt64: diff --git a/src/expr/attribute.h b/src/expr/attribute.h index f564b36f8..aafe168ea 100644 --- a/src/expr/attribute.h +++ b/src/expr/attribute.h @@ -88,8 +88,6 @@ public: AttrHash d_types; /** Underlying hash table for string-valued attributes */ AttrHash d_strings; - /** Underlying hash table for pointer-valued attributes */ - AttrHash d_ptrs; /** * Get a particular attribute on a particular node. @@ -274,32 +272,6 @@ struct getTable { } }; -/** Access the "d_ptrs" member of AttributeManager. */ -template -struct getTable { - static const AttrTableId id = AttrTablePointer; - typedef AttrHash table_type; - static inline table_type& get(AttributeManager& am) { - return am.d_ptrs; - } - static inline const table_type& get(const AttributeManager& am) { - return am.d_ptrs; - } -}; - -/** Access the "d_ptrs" member of AttributeManager. */ -template -struct getTable { - static const AttrTableId id = AttrTablePointer; - typedef AttrHash table_type; - static inline table_type& get(AttributeManager& am) { - return am.d_ptrs; - } - static inline const table_type& get(const AttributeManager& am) { - return am.d_ptrs; - } -}; - }/* CVC4::expr::attr namespace */ // ATTRIBUTE MANAGER IMPLEMENTATIONS =========================================== diff --git a/src/expr/attribute_internals.h b/src/expr/attribute_internals.h index c21b15140..ed1769740 100644 --- a/src/expr/attribute_internals.h +++ b/src/expr/attribute_internals.h @@ -101,42 +101,6 @@ struct KindValueToTableValueMapping { inline static T convertBack(const T& t) { return t; } }; -/** - * Specialization of KindValueToTableValueMapping<> for pointer-valued - * attributes. - */ -template -struct KindValueToTableValueMapping { - /** Table's value type is void* */ - typedef void* table_value_type; - /** A simple reinterpret_cast<>() conversion from T* to void* */ - inline static void* convert(const T* const& t) { - return reinterpret_cast(const_cast(t)); - } - /** A simple reinterpret_cast<>() conversion from void* to T* */ - inline static T* convertBack(void* const& t) { - return reinterpret_cast(t); - } -}; - -/** - * Specialization of KindValueToTableValueMapping<> for const - * pointer-valued attributes. - */ -template -struct KindValueToTableValueMapping { - /** Table's value type is void* */ - typedef void* table_value_type; - /** A simple reinterpret_cast<>() conversion from const T* const to void* */ - inline static void* convert(const T* const& t) { - return reinterpret_cast(const_cast(t)); - } - /** A simple reinterpret_cast<>() conversion from const void* const to T* */ - inline static const T* convertBack(const void* const& t) { - return reinterpret_cast(t); - } -}; - }/* CVC4::expr::attr namespace */ // ATTRIBUTE HASH TABLES ======================================================= @@ -376,23 +340,6 @@ namespace attr { struct NullCleanupStrategy { };/* struct NullCleanupStrategy */ -/** Default cleanup for ManagedAttribute<> */ -template -struct ManagedAttributeCleanupStrategy { -};/* struct ManagedAttributeCleanupStrategy<> */ - -/** Specialization for T* */ -template -struct ManagedAttributeCleanupStrategy { - static inline void cleanup(T* p) { delete p; } -};/* struct ManagedAttributeCleanupStrategy */ - -/** Specialization for const T* */ -template -struct ManagedAttributeCleanupStrategy { - static inline void cleanup(const T* p) { delete p; } -};/* struct ManagedAttributeCleanupStrategy */ - /** * Helper for Attribute<> class below to determine whether a cleanup * is defined or not. @@ -422,57 +369,6 @@ void (*const getCleanupStrategy::fn) (typename getCleanupStrategy:: mapping::table_value_type) = NULL; -/** - * Specialization for ManagedAttributeCleanupStrategy. - */ -template -struct getCleanupStrategy > { - typedef T value_type; - typedef KindValueToTableValueMapping mapping; - static void (*const fn)(typename mapping::table_value_type); -};/* struct getCleanupStrategy > */ - -// out-of-class initialization required (because it's a non-integral type) -template -void (*const getCleanupStrategy >::fn) - (typename getCleanupStrategy >:: - mapping::table_value_type) = NULL; - -/** - * Specialization for ManagedAttributeCleanupStrategy. - */ -template -struct getCleanupStrategy > { - typedef T* value_type; - typedef ManagedAttributeCleanupStrategy C; - typedef KindValueToTableValueMapping mapping; - static void fn(typename mapping::table_value_type t) { - C::cleanup(mapping::convertBack(t)); - } -};/* struct getCleanupStrategy > */ - -/** - * Specialization for ManagedAttributeCleanupStrategy. - */ -template -struct getCleanupStrategy > { - typedef const T* value_type; - typedef ManagedAttributeCleanupStrategy C; - typedef KindValueToTableValueMapping mapping; - static void fn(typename mapping::table_value_type t) { - C::cleanup(mapping::convertBack(t)); - } -};/* struct getCleanupStrategy > */ - -/** - * Cause compile-time error for improperly-instantiated - * getCleanupStrategy<>. - */ -template -struct getCleanupStrategy >; - }/* CVC4::expr::attr namespace */ // ATTRIBUTE IDENTIFIER ASSIGNMENT TEMPLATE ==================================== @@ -650,24 +546,6 @@ public: } };/* class Attribute<..., bool, ...> */ -/** - * This is a managed attribute kind (the only difference between - * ManagedAttribute<> and Attribute<> is the default cleanup function - * and the fact that ManagedAttributes cannot be context-dependent). - * In the default ManagedAttribute cleanup function, the value is - * destroyed with the delete operator. If the value is allocated with - * the array version of new[], an alternate cleanup function should be - * provided that uses array delete[]. It is an error to create a - * ManagedAttribute<> kind with a non-pointer value_type if you don't - * also supply a custom cleanup function. - */ -template > -struct ManagedAttribute : - public Attribute {}; - // ATTRIBUTE IDENTIFIER ASSIGNMENT ============================================= /** Assign unique IDs to attributes at load time. */ diff --git a/src/expr/attribute_unique_id.h b/src/expr/attribute_unique_id.h index 3ba53bede..1a6220db2 100644 --- a/src/expr/attribute_unique_id.h +++ b/src/expr/attribute_unique_id.h @@ -35,7 +35,6 @@ enum AttrTableId { AttrTableNode, AttrTableTypeNode, AttrTableString, - AttrTablePointer, AttrTableCDBool, AttrTableCDUInt64, AttrTableCDTNode, diff --git a/test/unit/expr/attribute_black.h b/test/unit/expr/attribute_black.h index 971c28684..afc99ef32 100644 --- a/test/unit/expr/attribute_black.h +++ b/test/unit/expr/attribute_black.h @@ -57,36 +57,6 @@ public: delete d_exprManager; } - class MyData { - public: - static int count; - MyData() { count ++; } - ~MyData() { count --; } - }; - - struct MyDataAttributeId {}; - - struct MyDataCleanupFunction { - static void cleanup(MyData* myData){ - delete myData; - } - }; - - typedef expr::Attribute MyDataAttribute; - - void testDeallocation() { - TypeNode booleanType = d_nodeManager->booleanType(); - Node* node = new Node(d_nodeManager->mkSkolem("b", booleanType)); - MyData* data; - MyData* data1; - MyDataAttribute attr; - TS_ASSERT(!node->getAttribute(attr, data)); - node->setAttribute(attr, new MyData()); - TS_ASSERT(node->getAttribute(attr, data1)); - TS_ASSERT(MyData::count == 1); - delete node; - } - struct PrimitiveIntAttributeId {}; typedef expr::Attribute PrimitiveIntAttribute; void testInts(){ @@ -125,56 +95,6 @@ public: delete node; } - class Foo { - int d_bar; - public: - Foo(int b) : d_bar(b) {} - int getBar() const { return d_bar; } - }; - - struct PtrAttributeId {}; - - typedef expr::Attribute PtrAttribute; - void testPtrs(){ - TypeNode booleanType = d_nodeManager->booleanType(); - Node* node = new Node(d_nodeManager->mkSkolem("b", booleanType)); - - Foo* val = new Foo(63489); - Foo* data0 = NULL; - Foo* data1 = NULL; - - PtrAttribute attr; - TS_ASSERT(!node->getAttribute(attr, data0)); - node->setAttribute(attr, val); - TS_ASSERT(node->getAttribute(attr, data1)); - TS_ASSERT_EQUALS(data1, val); - - delete node; - delete val; - } - - - struct ConstPtrAttributeId {}; - - typedef expr::Attribute ConstPtrAttribute; - void testConstPtrs(){ - TypeNode booleanType = d_nodeManager->booleanType(); - Node* node = new Node(d_nodeManager->mkSkolem("b", booleanType)); - - const Foo* val = new Foo(63489); - const Foo* data0 = NULL; - const Foo* data1 = NULL; - - ConstPtrAttribute attr; - TS_ASSERT(!node->getAttribute(attr, data0)); - node->setAttribute(attr, val); - TS_ASSERT(node->getAttribute(attr, data1)); - TS_ASSERT_EQUALS(data1, val); - - delete node; - delete val; - } - struct StringAttributeId {}; typedef expr::Attribute StringAttribute; void testStrings(){ @@ -215,5 +135,3 @@ public: } }; - -int AttributeBlack::MyData::count = 0;