[cfe-commits] r43561 - in /cfe/trunk: AST/ASTContext.cpp AST/TypeSerialization.cpp include/clang/AST/Expr.h include/clang/AST/Stmt.h include/clang/AST/Type.h
Ted Kremenek
kremenek at apple.com
Wed Oct 31 10:50:23 PDT 2007
Author: kremenek
Date: Wed Oct 31 12:50:23 2007
New Revision: 43561
URL: http://llvm.org/viewvc/llvm-project?rev=43561&view=rev
Log:
Implemented serialization of Variable Array Types (VLAs).
Modified:
cfe/trunk/AST/ASTContext.cpp
cfe/trunk/AST/TypeSerialization.cpp
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/AST/Type.h
Modified: cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=43561&r1=43560&r2=43561&view=diff
==============================================================================
--- cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/trunk/AST/ASTContext.cpp Wed Oct 31 12:50:23 2007
@@ -1308,15 +1308,15 @@
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.
Modified: cfe/trunk/AST/TypeSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/TypeSerialization.cpp?rev=43561&r1=43560&r2=43561&view=diff
==============================================================================
--- cfe/trunk/AST/TypeSerialization.cpp (original)
+++ cfe/trunk/AST/TypeSerialization.cpp Wed Oct 31 12:50:23 2007
@@ -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 @@
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);
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=43561&r1=43560&r2=43561&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Oct 31 12:50:23 2007
@@ -110,6 +110,14 @@
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));
+ }
};
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=43561&r1=43560&r2=43561&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Wed Oct 31 12:50:23 2007
@@ -668,7 +668,7 @@
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);
};
Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=43561&r1=43560&r2=43561&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Oct 31 12:50:23 2007
@@ -484,7 +484,7 @@
/// 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 @@
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 @@
};
// 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 @@
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
More information about the cfe-commits
mailing list