#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/Bitcode/Serialization.h"
+#include "llvm/Bitcode/Serialize.h"
+#include "llvm/Bitcode/Deserialize.h"
using namespace clang;
// Serialization for IdentifierInfo and IdentifierTable.
//===----------------------------------------------------------------------===//
-void llvm::SerializeTrait<IdentifierInfo>::Serialize(llvm::Serializer& S,
+void llvm::SerializeTrait<IdentifierInfo>::Emit(llvm::Serializer& S,
const IdentifierInfo& I) {
- S.Emit<tok::TokenKind>(I.getTokenID());
- S.EmitInt(I.getBuiltinID(),9);
- S.Emit<tok::ObjCKeywordKind>(I.getObjCKeywordID());
- S.Emit(I.hasMacroDefinition());
- S.Emit(I.isExtensionToken());
- S.Emit(I.isPoisoned());
- S.Emit(I.isOtherTargetMacro());
- S.Emit(I.isCPlusPlusOperatorKeyword());
- S.Emit(I.isNonPortableBuiltin());
+ S.EmitInt(I.getTokenID());
+ S.EmitInt(I.getBuiltinID());
+ S.EmitInt(I.getObjCKeywordID());
+ S.EmitBool(I.hasMacroDefinition());
+ S.EmitBool(I.isExtensionToken());
+ S.EmitBool(I.isPoisoned());
+ S.EmitBool(I.isOtherTargetMacro());
+ S.EmitBool(I.isCPlusPlusOperatorKeyword());
+ S.EmitBool(I.isNonPortableBuiltin());
}
-void llvm::SerializeTrait<IdentifierInfo>::Deserialize(llvm::Deserializer& D,
- IdentifierInfo& I) {
- tok::TokenKind X;
- I.setTokenID(D.Read<tok::TokenKind>(X));
-
- I.setBuiltinID(D.ReadInt(9));
-
- tok::ObjCKeywordKind Y;
- I.setObjCKeywordID(D.Read<tok::ObjCKeywordKind>(Y));
-
+void llvm::SerializeTrait<IdentifierInfo>::Read(llvm::Deserializer& D,
+ IdentifierInfo& I) {
+ I.setTokenID((tok::TokenKind) D.ReadInt());
+ I.setBuiltinID(D.ReadInt());
+ I.setObjCKeywordID((tok::ObjCKeywordKind) D.ReadInt());
I.setHasMacroDefinition(D.ReadBool());
I.setIsExtensionToken(D.ReadBool());
I.setIsPoisoned(D.ReadBool());
I.setNonPortableBuiltin(D.ReadBool());
}
-void llvm::SerializeTrait<IdentifierTable>::Serialize(llvm::Serializer& S,
- const IdentifierTable& T){
+void llvm::SerializeTrait<IdentifierTable>::Emit(llvm::Serializer& S,
+ const IdentifierTable& T){
S.Emit<unsigned>(T.size());
for (clang::IdentifierTable::iterator I=T.begin(), E=T.end(); I != E; ++I) {
- S.EmitCString(I->getKeyData());
+ S.EmitCStr(I->getKeyData());
S.Emit(I->getValue());
}
}
-void llvm::SerializeTrait<IdentifierTable>::Deserialize(llvm::Deserializer& D,
- IdentifierTable& T) {
+void llvm::SerializeTrait<IdentifierTable>::Read(llvm::Deserializer& D,
+ IdentifierTable& T) {
unsigned len = D.ReadInt();
std::vector<char> buff;
buff.reserve(200);
for (unsigned i = 0; i < len; ++i) {
- D.ReadCString(buff);
+ D.ReadCStr(buff);
IdentifierInfo& Info = T.get(&buff[0],&buff[0]+buff.size());
D.Read(Info);
}
}
-
+
+IdentifierTable*
+llvm::SerializeTrait<IdentifierTable>::Materialize(llvm::Deserializer& D)
+{
+ IdentifierTable* t = new IdentifierTable();
+ D.Read(*t);
+ return t;
+}
//===----------------------------------------------------------------------===//
#include "clang/Basic/TokenKinds.h"
-#include "llvm/Bitcode/Serialization.h"
+
#include <cassert>
using namespace clang;
assert(Kind < tok::NUM_TOKENS);
return TokNames[Kind];
}
-
-// Serialization traits for TokenKind, PPKeywordKind, and ObjCKeywordKind
-
-void llvm::SerializeTrait<tok::TokenKind>::Serialize(llvm::Serializer& S,
- tok::TokenKind X) {
- S.EmitEnum(X,0,tok::NUM_TOKENS-1);
-}
-
-void llvm::SerializeTrait<tok::TokenKind>::Deserialize(llvm::Deserializer& D,
- tok::TokenKind& X) {
- X = D.ReadEnum<tok::TokenKind>(0,tok::NUM_TOKENS-1);
-}
-
-void llvm::SerializeTrait<tok::PPKeywordKind>::Serialize(llvm::Serializer& S,
- tok::PPKeywordKind X) {
- S.EmitEnum(X,0,tok::NUM_PP_KEYWORDS-1);
-}
-
-void llvm::SerializeTrait<tok::PPKeywordKind>::Deserialize(llvm::Deserializer& D,
- tok::PPKeywordKind& X) {
- X = D.ReadEnum<tok::PPKeywordKind>(0,tok::NUM_PP_KEYWORDS-1);
-}
-
-void
-llvm::SerializeTrait<tok::ObjCKeywordKind>::Serialize(llvm::Serializer& S,
- tok::ObjCKeywordKind X) {
- S.EmitEnum(X,0,tok::NUM_OBJC_KEYWORDS-1);
-}
-
-void
-llvm::SerializeTrait<tok::ObjCKeywordKind>::Deserialize(llvm::Deserializer& D,
- tok::ObjCKeywordKind& X) {
- X = D.ReadEnum<tok::ObjCKeywordKind>(0,tok::NUM_OBJC_KEYWORDS-1);
-}
\ No newline at end of file
#include "llvm/System/Path.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Bitcode/Serialization.h"
+#include "llvm/Bitcode/Serialize.h"
+#include "llvm/Bitcode/Deserialize.h"
#include <stdio.h>
//===----------------------------------------------------------------------===//
#include "clang/Basic/TokenKinds.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Bitcode/Serialization.h"
#include <string>
#include <cassert>
-
namespace llvm {
template <typename T> struct DenseMapInfo;
- template <typename T> struct SerializeTrait;
- class Serializer;
- class Deserializer;
}
namespace clang {
/// Define SerializeTrait to enable serialization for IdentifierInfos.
template <>
struct SerializeTrait<clang::IdentifierInfo> {
- static void Serialize(llvm::Serializer& S, const clang::IdentifierInfo& I);
- static void Deserialize(llvm::Deserializer& S, clang::IdentifierInfo& I);
+ static void Emit(Serializer& S, const clang::IdentifierInfo& I);
+ static void Read(Deserializer& S, clang::IdentifierInfo& I);
};
/// Define SerializeTrait to enable serialization for IdentifierTables.
template <>
struct SerializeTrait<clang::IdentifierTable> {
- static void Serialize(llvm::Serializer& S, const clang::IdentifierTable& X);
- static void Deserialize(llvm::Deserializer& S, clang::IdentifierTable& X);
+ static void Emit(Serializer& S, const clang::IdentifierTable& X);
+ static void Read(Deserializer& S, clang::IdentifierTable& X);
private:
- static inline clang::IdentifierTable* Instantiate() {
- return new clang::IdentifierTable();
- }
-
+ static clang::IdentifierTable* Materialize(Deserializer& D);
friend class Deserializer;
};
} // end namespace tok
} // end namespace clang
-//===----------------------------------------------------------------------===//
-// Serialization traits.
-//===----------------------------------------------------------------------===//
-
-namespace llvm {
- template <typename T> struct SerializeTrait;
- class Serializer;
- class Deserializer;
-
-template<>
-struct SerializeTrait<clang::tok::TokenKind> {
- static void Serialize(llvm::Serializer& S, clang::tok::TokenKind X);
- static void Deserialize(llvm::Deserializer& D, clang::tok::TokenKind& X);
-};
-
-template<>
-struct SerializeTrait<clang::tok::PPKeywordKind> {
- static void Serialize(llvm::Serializer& S, clang::tok::PPKeywordKind X);
- static void Deserialize(llvm::Deserializer& D, clang::tok::PPKeywordKind& X);
-};
-
-template<>
-struct SerializeTrait<clang::tok::ObjCKeywordKind> {
- static void Serialize(llvm::Serializer& S, clang::tok::ObjCKeywordKind X);
- static void Deserialize(llvm::Deserializer& D, clang::tok::ObjCKeywordKind& X);
-};
-
-} // end namespace llvm
-
#endif