зеркало из https://github.com/microsoft/clang-1.git
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43306 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
a83cc33195
Коммит
a2bfb91c55
|
@ -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 @@ SelectorTable::~SelectorTable() {
|
|||
// 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());
|
||||
|
@ -413,27 +409,34 @@ void llvm::SerializeTrait<IdentifierInfo>::Deserialize(llvm::Deserializer& D,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Basic/TokenKinds.h"
|
||||
#include "llvm/Bitcode/Serialization.h"
|
||||
|
||||
#include <cassert>
|
||||
using namespace clang;
|
||||
|
||||
|
@ -27,37 +27,3 @@ const char *tok::getTokenName(enum TokenKind Kind) {
|
|||
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);
|
||||
}
|
|
@ -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>
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -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 @@ struct DenseMapInfo<clang::Selector> {
|
|||
/// 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;
|
||||
};
|
||||
|
||||
|
|
|
@ -48,33 +48,4 @@ const char *getTokenName(enum TokenKind Kind);
|
|||
} // 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
|
||||
|
|
Загрузка…
Ссылка в новой задаче