зеркало из https://github.com/microsoft/clang-1.git
Added QualType::ReadBackpatch to allow QualType initialization with
backpatching. This original was available, but then we removed it. It is back again to help with deserialization of FieldDecls. Because FieldDecls are currently owned by RecordDecls, which are owned by a TagType, the type of the FieldDecl may not be deserialized prior to deserializing the FieldDecl. Thus backpatching solves the problem of constructing a FieldDecl that references a type that has not yet been deserialized. Simplified serialization of TagType to not require passing in the SerializedPtrID. Registration of the materialized type object is done after the CreateImpl method returns (as with other types). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44143 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
9567392e16
Коммит
21d50e12c3
|
@ -295,8 +295,8 @@ void FieldDecl::EmitImpl(Serializer& S) const {
|
|||
}
|
||||
|
||||
FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
|
||||
QualType DeclType = QualType::ReadVal(D);
|
||||
FieldDecl* decl = new FieldDecl(SourceLocation(),NULL,DeclType);
|
||||
FieldDecl* decl = new FieldDecl(SourceLocation(),NULL,QualType());
|
||||
decl->DeclType.ReadBackpatch(D);
|
||||
decl->ReadInRec(D);
|
||||
decl->BitWidth = D.ReadOwnedPtr<Expr>();
|
||||
return decl;
|
||||
|
|
|
@ -35,6 +35,11 @@ QualType QualType::ReadVal(Deserializer& D) {
|
|||
return Q;
|
||||
}
|
||||
|
||||
void QualType::ReadBackpatch(Deserializer& D) {
|
||||
D.ReadUIntPtr(ThePtr,true);
|
||||
ThePtr |= D.ReadInt();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Type Serialization: Dispatch code to handle specific types.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -87,7 +92,7 @@ void Type::Create(ASTContext& Context, unsigned i, Deserializer& D) {
|
|||
break;
|
||||
|
||||
case Type::Tagged:
|
||||
TagType::CreateImpl(Context,PtrID,D);
|
||||
D.RegisterPtr(PtrID,TagType::CreateImpl(Context,D));
|
||||
break;
|
||||
|
||||
case Type::TypeName:
|
||||
|
@ -193,18 +198,13 @@ void TagType::EmitImpl(Serializer& S) const {
|
|||
S.EmitOwnedPtr(getDecl());
|
||||
}
|
||||
|
||||
Type* TagType::CreateImpl(ASTContext& Context, SerializedPtrID& PtrID,
|
||||
Deserializer& D) {
|
||||
|
||||
Type* TagType::CreateImpl(ASTContext& Context, Deserializer& D) {
|
||||
std::vector<Type*>& Types =
|
||||
const_cast<std::vector<Type*>&>(Context.getTypes());
|
||||
|
||||
TagType* T = new TagType(NULL,QualType());
|
||||
Types.push_back(T);
|
||||
|
||||
// Forward register the type pointer before deserializing the decl.
|
||||
D.RegisterPtr(PtrID,T);
|
||||
|
||||
// Deserialize the decl.
|
||||
T->decl = cast<TagDecl>(D.ReadOwnedPtr<Decl>());
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace clang {
|
|||
class TagDecl;
|
||||
class RecordDecl;
|
||||
class EnumDecl;
|
||||
class FieldDecl;
|
||||
class ObjcInterfaceDecl;
|
||||
class ObjcProtocolDecl;
|
||||
class ObjcMethodDecl;
|
||||
|
@ -161,6 +162,10 @@ public:
|
|||
|
||||
/// Read - Deserialize a QualType from Bitcode.
|
||||
static QualType ReadVal(llvm::Deserializer& D);
|
||||
|
||||
private:
|
||||
void ReadBackpatch(llvm::Deserializer& D);
|
||||
friend class FieldDecl;
|
||||
};
|
||||
|
||||
} // end clang.
|
||||
|
@ -888,8 +893,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void EmitImpl(llvm::Serializer& S) const;
|
||||
static Type* CreateImpl(ASTContext& Context, llvm::SerializedPtrID& PtrID,
|
||||
llvm::Deserializer& D);
|
||||
static Type* CreateImpl(ASTContext& Context, llvm::Deserializer& D);
|
||||
friend class Type;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче