summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim King <taking@cs.nyu.edu>2018-08-13 09:25:26 -0700
committerGitHub <noreply@github.com>2018-08-13 09:25:26 -0700
commit957b02e415f60e725da569f1d7c0e2d1276cb3fa (patch)
treee588e05f4c1fb2320f7902618f49d188d043517d
parentb62055f1204a0846eef728b2b62e5fc77df4048c (diff)
Removing support for T* and const T* attributes. (#2297)
* Removing support for T* and const T* attributes. These are unused.
-rw-r--r--src/expr/attribute.cpp5
-rw-r--r--src/expr/attribute.h28
-rw-r--r--src/expr/attribute_internals.h122
-rw-r--r--src/expr/attribute_unique_id.h1
-rw-r--r--test/unit/expr/attribute_black.h82
5 files changed, 0 insertions, 238 deletions
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<TypeNode> d_types;
/** Underlying hash table for string-valued attributes */
AttrHash<std::string> d_strings;
- /** Underlying hash table for pointer-valued attributes */
- AttrHash<void*> d_ptrs;
/**
* Get a particular attribute on a particular node.
@@ -274,32 +272,6 @@ struct getTable<std::string, false> {
}
};
-/** Access the "d_ptrs" member of AttributeManager. */
-template <class T>
-struct getTable<T*, false> {
- static const AttrTableId id = AttrTablePointer;
- typedef AttrHash<void*> 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 <class T>
-struct getTable<const T*, false> {
- static const AttrTableId id = AttrTablePointer;
- typedef AttrHash<void*> 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 <class T>
-struct KindValueToTableValueMapping<T*> {
- /** 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<void*>(const_cast<T*>(t));
- }
- /** A simple reinterpret_cast<>() conversion from void* to T* */
- inline static T* convertBack(void* const& t) {
- return reinterpret_cast<T*>(t);
- }
-};
-
-/**
- * Specialization of KindValueToTableValueMapping<> for const
- * pointer-valued attributes.
- */
-template <class T>
-struct KindValueToTableValueMapping<const T*> {
- /** 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<void*>(const_cast<T*>(t));
- }
- /** A simple reinterpret_cast<>() conversion from const void* const to T* */
- inline static const T* convertBack(const void* const& t) {
- return reinterpret_cast<const T*>(t);
- }
-};
-
}/* CVC4::expr::attr namespace */
// ATTRIBUTE HASH TABLES =======================================================
@@ -376,23 +340,6 @@ namespace attr {
struct NullCleanupStrategy {
};/* struct NullCleanupStrategy */
-/** Default cleanup for ManagedAttribute<> */
-template <class T>
-struct ManagedAttributeCleanupStrategy {
-};/* struct ManagedAttributeCleanupStrategy<> */
-
-/** Specialization for T* */
-template <class T>
-struct ManagedAttributeCleanupStrategy<T*> {
- static inline void cleanup(T* p) { delete p; }
-};/* struct ManagedAttributeCleanupStrategy<T*> */
-
-/** Specialization for const T* */
-template <class T>
-struct ManagedAttributeCleanupStrategy<const T*> {
- static inline void cleanup(const T* p) { delete p; }
-};/* struct ManagedAttributeCleanupStrategy<const T*> */
-
/**
* Helper for Attribute<> class below to determine whether a cleanup
* is defined or not.
@@ -422,57 +369,6 @@ void (*const getCleanupStrategy<T, NullCleanupStrategy>::fn)
(typename getCleanupStrategy<T, NullCleanupStrategy>::
mapping::table_value_type) = NULL;
-/**
- * Specialization for ManagedAttributeCleanupStrategy<T>.
- */
-template <class T>
-struct getCleanupStrategy<T, ManagedAttributeCleanupStrategy<T> > {
- typedef T value_type;
- typedef KindValueToTableValueMapping<value_type> mapping;
- static void (*const fn)(typename mapping::table_value_type);
-};/* struct getCleanupStrategy<T, ManagedAttributeCleanupStrategy<T> > */
-
-// out-of-class initialization required (because it's a non-integral type)
-template <class T>
-void (*const getCleanupStrategy<T, ManagedAttributeCleanupStrategy<T> >::fn)
- (typename getCleanupStrategy<T, ManagedAttributeCleanupStrategy<T> >::
- mapping::table_value_type) = NULL;
-
-/**
- * Specialization for ManagedAttributeCleanupStrategy<T*>.
- */
-template <class T>
-struct getCleanupStrategy<T*, ManagedAttributeCleanupStrategy<T*> > {
- typedef T* value_type;
- typedef ManagedAttributeCleanupStrategy<value_type> C;
- typedef KindValueToTableValueMapping<value_type> mapping;
- static void fn(typename mapping::table_value_type t) {
- C::cleanup(mapping::convertBack(t));
- }
-};/* struct getCleanupStrategy<T*, ManagedAttributeCleanupStrategy<T*> > */
-
-/**
- * Specialization for ManagedAttributeCleanupStrategy<const T*>.
- */
-template <class T>
-struct getCleanupStrategy<const T*,
- ManagedAttributeCleanupStrategy<const T*> > {
- typedef const T* value_type;
- typedef ManagedAttributeCleanupStrategy<value_type> C;
- typedef KindValueToTableValueMapping<value_type> mapping;
- static void fn(typename mapping::table_value_type t) {
- C::cleanup(mapping::convertBack(t));
- }
-};/* struct getCleanupStrategy<const T*,
- ManagedAttributeCleanupStrategy<const T*> > */
-
-/**
- * Cause compile-time error for improperly-instantiated
- * getCleanupStrategy<>.
- */
-template <class T, class U>
-struct getCleanupStrategy<T, ManagedAttributeCleanupStrategy<U> >;
-
}/* 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 <class T,
- class value_type,
- class CleanupStrategy =
- attr::ManagedAttributeCleanupStrategy<value_type> >
-struct ManagedAttribute :
- public Attribute<T, value_type, CleanupStrategy, false> {};
-
// 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<MyDataAttributeId, MyData*, MyDataCleanupFunction> 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<PrimitiveIntAttributeId,uint64_t> 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<PtrAttributeId, Foo*> 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<ConstPtrAttributeId, const Foo*> 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<StringAttributeId, std::string> StringAttribute;
void testStrings(){
@@ -215,5 +135,3 @@ public:
}
};
-
-int AttributeBlack::MyData::count = 0;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback