зеркало из https://github.com/microsoft/clang-1.git
Implemented serialization of Variable Array Types (VLAs).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43561 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
fdc08a0682
Коммит
2e7d352dbe
|
@ -1308,15 +1308,15 @@ void ASTContext::Emit(llvm::Serializer& S) const {
|
|||
EmitSet(PointerTypes,S);
|
||||
EmitSet(ReferenceTypes,S);
|
||||
EmitSet(ConstantArrayTypes,S);
|
||||
// FIXME EmitSet(IncompleteVariableArrayTypes,S);
|
||||
/* FIXME: Emit for VLAs
|
||||
EmitSet(IncompleteVariableArrayTypes,S);
|
||||
|
||||
S.EmitInt(CompleteVariableArrayTypes.size());
|
||||
for (unsigned i = 0; i < CompleteVariableArrayTypes.size(); ++i)
|
||||
S.Emit(*CompleteVariableArrayTypes[i]); */
|
||||
S.Emit(*CompleteVariableArrayTypes[i]);
|
||||
|
||||
EmitSet(VectorTypes,S);
|
||||
// FIXME: EmitSet(FunctionTypeNoProtos);
|
||||
// FIXME: EmitSet(FunctionTypeProtos);
|
||||
EmitSet(FunctionTypeNoProtos,S);
|
||||
EmitSet(FunctionTypeProtos,S);
|
||||
// FIXME: EmitSet(ObjcQualifiedInterfaceTypes,S);
|
||||
// FIXME: RecourdLayoutInfo
|
||||
// FIXME: Builtins.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "llvm/Bitcode/Serialize.h"
|
||||
#include "llvm/Bitcode/Deserialize.h"
|
||||
|
||||
|
@ -140,6 +141,23 @@ ConstantArrayType* ConstantArrayType::Materialize(llvm::Deserializer& D) {
|
|||
return T;
|
||||
}
|
||||
|
||||
void VariableArrayType::Emit(llvm::Serializer& S) const {
|
||||
EmitArrayTypeInternal(S);
|
||||
S.EmitOwnedPtr(SizeExpr);
|
||||
}
|
||||
|
||||
VariableArrayType* VariableArrayType::Materialize(llvm::Deserializer& D) {
|
||||
// "Default" construct the array type.
|
||||
VariableArrayType* T =
|
||||
new VariableArrayType(QualType(), QualType(), NULL, ArrayType::Normal, 0);
|
||||
|
||||
// Deserialize the internal values.
|
||||
T->ReadArrayTypeInternal(D);
|
||||
T->SizeExpr = D.ReadOwnedPtr<Expr>();
|
||||
|
||||
return T;
|
||||
}
|
||||
|
||||
void VectorType::Emit(llvm::Serializer& S) const {
|
||||
EmitTypeInternal(S);
|
||||
S.Emit(ElementType);
|
||||
|
|
|
@ -110,6 +110,14 @@ public:
|
|||
T->getStmtClass() <= lastExprConstant;
|
||||
}
|
||||
static bool classof(const Expr *) { return true; }
|
||||
|
||||
void Emit(llvm::Serializer& S) const {
|
||||
llvm::SerializeTrait<Stmt>::Emit(S,*this);
|
||||
}
|
||||
|
||||
static inline Expr* Materialize(llvm::Deserializer& D) {
|
||||
return cast<Expr>(llvm::SerializeTrait<Stmt>::Materialize(D));
|
||||
}
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -668,7 +668,7 @@ public:
|
|||
namespace llvm {
|
||||
|
||||
template<> struct SerializeTrait<clang::Stmt> {
|
||||
static void Emit(Serializer& S, clang::Stmt& stmt);
|
||||
static void Emit(Serializer& S, const clang::Stmt& stmt);
|
||||
static clang::Stmt* Materialize(Deserializer& D);
|
||||
};
|
||||
|
||||
|
|
|
@ -484,7 +484,7 @@ public:
|
|||
|
||||
/// ArrayType - C99 6.7.5.2 - Array Declarators.
|
||||
///
|
||||
class ArrayType : public Type {
|
||||
class ArrayType : public Type, public llvm::FoldingSetNode {
|
||||
public:
|
||||
/// ArraySizeModifier - Capture whether this is a normal array (e.g. int X[4])
|
||||
/// an array with a static size (e.g. int X[static 4]), or with a star size
|
||||
|
@ -532,7 +532,7 @@ protected:
|
|||
void ReadArrayTypeInternal(llvm::Deserializer& S);
|
||||
};
|
||||
|
||||
class ConstantArrayType : public ArrayType, public llvm::FoldingSetNode {
|
||||
class ConstantArrayType : public ArrayType {
|
||||
llvm::APInt Size; // Allows us to unique the type.
|
||||
|
||||
ConstantArrayType(QualType et, QualType can, llvm::APInt sz,
|
||||
|
@ -573,7 +573,7 @@ public:
|
|||
};
|
||||
|
||||
// FIXME: VariableArrayType's aren't uniqued (since expressions aren't).
|
||||
class VariableArrayType : public ArrayType, public llvm::FoldingSetNode {
|
||||
class VariableArrayType : public ArrayType {
|
||||
/// SizeExpr - An assignment expression. VLA's are only permitted within
|
||||
/// a function block.
|
||||
Expr *SizeExpr;
|
||||
|
@ -605,8 +605,8 @@ public:
|
|||
ID.AddPointer(ET.getAsOpaquePtr());
|
||||
}
|
||||
|
||||
// FIXME: Who owns VariableArrayType's? What are the semantics
|
||||
// for serialization.
|
||||
void Emit(llvm::Serializer& S) const;
|
||||
static VariableArrayType* Materialize(llvm::Deserializer& D);
|
||||
};
|
||||
|
||||
/// VectorType - GCC generic vector type. This type is created using
|
||||
|
|
Загрузка…
Ссылка в новой задаче