[cfe-commits] r43306 - in /cfe/trunk: Basic/IdentifierTable.cpp Basic/TokenKinds.cpp Driver/SerializationTest.cpp include/clang/Basic/IdentifierTable.h include/clang/Basic/TokenKinds.h
Ted Kremenek
kremenek at apple.com
Wed Oct 24 12:06:03 PDT 2007
Author: kremenek
Date: Wed Oct 24 14:06:02 2007
New Revision: 43306
URL: http://llvm.org/viewvc/llvm-project?rev=43306&view=rev
Log:
Modified current clients of Bitcode-Object serialization to use the
new split-header file configuration (Serialize.h and Deserialize.h)
now in place in the core LLVM repository.
Removed unneeded SerializeTrait specializations for enums in
TokenKinds.h
Modified:
cfe/trunk/Basic/IdentifierTable.cpp
cfe/trunk/Basic/TokenKinds.cpp
cfe/trunk/Driver/SerializationTest.cpp
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Basic/TokenKinds.h
Modified: cfe/trunk/Basic/IdentifierTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/IdentifierTable.cpp?rev=43306&r1=43305&r2=43306&view=diff
==============================================================================
--- cfe/trunk/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/Basic/IdentifierTable.cpp Wed Oct 24 14:06:02 2007
@@ -16,7 +16,8 @@
#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;
@@ -381,30 +382,25 @@
// 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());
-}
-
-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));
-
+ 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>::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());
@@ -413,27 +409,34 @@
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;
+}
Modified: cfe/trunk/Basic/TokenKinds.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/TokenKinds.cpp?rev=43306&r1=43305&r2=43306&view=diff
==============================================================================
--- cfe/trunk/Basic/TokenKinds.cpp (original)
+++ cfe/trunk/Basic/TokenKinds.cpp Wed Oct 24 14:06:02 2007
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/TokenKinds.h"
-#include "llvm/Bitcode/Serialization.h"
+
#include <cassert>
using namespace clang;
@@ -27,37 +27,3 @@
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
Modified: cfe/trunk/Driver/SerializationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/SerializationTest.cpp?rev=43306&r1=43305&r2=43306&view=diff
==============================================================================
--- cfe/trunk/Driver/SerializationTest.cpp (original)
+++ cfe/trunk/Driver/SerializationTest.cpp Wed Oct 24 14:06:02 2007
@@ -21,7 +21,8 @@
#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>
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=43306&r1=43305&r2=43306&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Wed Oct 24 14:06:02 2007
@@ -18,15 +18,12 @@
#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 {
@@ -311,21 +308,18 @@
/// 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;
};
Modified: cfe/trunk/include/clang/Basic/TokenKinds.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.h?rev=43306&r1=43305&r2=43306&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.h (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.h Wed Oct 24 14:06:02 2007
@@ -48,33 +48,4 @@
} // 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
More information about the cfe-commits
mailing list