aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-23 22:17:03 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-23 22:17:03 +0000
commit211f674e3fd27c663bed820f5569518de4b1d187 (patch)
tree93415a15d103e98fca8602a4045b62f41deb6f32 /include/llvm
parent803396fce26270fae6ff0dfba4813f4d4e5002fd (diff)
downloadexternal_llvm-211f674e3fd27c663bed820f5569518de4b1d187.zip
external_llvm-211f674e3fd27c663bed820f5569518de4b1d187.tar.gz
external_llvm-211f674e3fd27c663bed820f5569518de4b1d187.tar.bz2
Added "ReadEnum" and "WriteEnum" to serialization classes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Bitcode/Serialization.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/llvm/Bitcode/Serialization.h b/include/llvm/Bitcode/Serialization.h
index 2d63311..356a75c 100644
--- a/include/llvm/Bitcode/Serialization.h
+++ b/include/llvm/Bitcode/Serialization.h
@@ -35,7 +35,12 @@ public:
template <typename T>
inline void Emit(const T& X) { SerializeTrait<T>::Serialize(*this,X); }
- void EmitInt(unsigned X, unsigned bits);
+ void EmitInt(unsigned X, unsigned bits);
+
+ // FIXME: Substitute a better implementation which calculates the minimum
+ // number of bits needed to serialize the enum.
+ void EmitEnum(unsigned X, unsigned MinVal, unsigned MaxVal) { EmitInt(X,32); }
+
void EmitCString(const char* cstr);
void Flush() { if (inRecord()) EmitRecord(); }
@@ -55,7 +60,7 @@ public:
~Deserializer();
template <typename T>
- inline void Read(T& X) { SerializeTrait<T>::Deserialize(*this,X); }
+ inline T& Read(T& X) { SerializeTrait<T>::Deserialize(*this,X); return X; }
template <typename T>
inline T* Materialize() {
@@ -67,6 +72,13 @@ public:
uint64_t ReadInt(unsigned bits = 32);
bool ReadBool() { return ReadInt(1); }
+ // FIXME: Substitute a better implementation which calculates the minimum
+ // number of bits needed to serialize the enum.
+ template <typename EnumT>
+ EnumT ReadEnum(unsigned MinVal, unsigned MaxVal) {
+ return static_cast<EnumT>(ReadInt(32));
+ }
+
char* ReadCString(char* cstr = NULL, unsigned MaxLen=0, bool isNullTerm=true);
void ReadCString(std::vector<char>& buff, bool isNullTerm=false);
@@ -97,7 +109,6 @@ struct SerializeIntTrait {
X = (uintty) S.ReadInt(Bits);
}
};
-
template <> struct SerializeTrait<bool>
: public SerializeIntTrait<bool,1> {};
@@ -111,5 +122,7 @@ template <> struct SerializeTrait<short>
template <> struct SerializeTrait<unsigned>
: public SerializeIntTrait<unsigned,32> {};
+
+
} // end namespace llvm
#endif