Removed ReadVal from SerializeTrait<T>, and also removed it from

Deserializer.

There were issues with Visual C++ barfing when instantiating
SerializeTrait<T> when "T" was an abstract class AND
SerializeTrait<T>::ReadVal was *never* called:

template <typename T>
struct SerializeTrait {
 <SNIP>
  static inline T ReadVal(Deserializer& D) { T::ReadVal(D); }
 <SNIP>
};

Visual C++ would complain about "T" being an abstract class, even
though ReadVal was never instantiated (although one of the other
member functions were).

Removing this from the trait is not a big deal.  It was used hardly
ever, and users who want "read-by-value" deserialization can simply
call the appropriate methods directly instead of relying on
trait-based-dispatch.  The trait dispatch for
serialization/deserialization is simply sugar in many cases (like this
one).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43624 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2007-11-01 22:23:34 +00:00
parent 514ab348fd
commit ff37ccc570
3 changed files with 2 additions and 11 deletions

View File

@ -103,11 +103,6 @@ public:
SerializeTrait<T>::Read(*this,X);
return X;
}
template <typename T>
inline T ReadVal() {
return SerializeTrait<T>::ReadVal(*this);
}
template <typename T>
inline T* Materialize() {

View File

@ -37,15 +37,13 @@ template <typename T>
struct SerializeTrait {
static inline void Emit(Serializer& S, const T& X) { X.Emit(S); }
static inline void Read(Deserializer& D, T& X) { X.Read(D); }
static inline T ReadVal(Deserializer& D) { T::ReadVal(D); }
static inline T* Materialize(Deserializer& D) { return T::Materialize(D); }
};
#define SERIALIZE_INT_TRAIT(TYPE)\
template <> struct SerializeTrait<TYPE> {\
static void Emit(Serializer& S, TYPE X);\
static void Read(Deserializer& S, TYPE& X);\
static TYPE ReadVal(Deserializer& S); };
static void Read(Deserializer& S, TYPE& X); };
SERIALIZE_INT_TRAIT(bool)
SERIALIZE_INT_TRAIT(unsigned char)

View File

@ -166,9 +166,7 @@ void Deserializer::BPEntry::SetPtr(BPNode*& FreeList, void* P) {
#define INT_READ(TYPE)\
void SerializeTrait<TYPE>::Read(Deserializer& D, TYPE& X) {\
X = (TYPE) D.ReadInt(); }\
TYPE SerializeTrait<TYPE>::ReadVal(Deserializer& D) {\
return (TYPE) D.ReadInt(); }
X = (TYPE) D.ReadInt(); }
INT_READ(bool)
INT_READ(unsigned char)