2007-10-26 05:37:16 +08:00
|
|
|
//===--- DeclSerialization.cpp - Serialization of Decls ---------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-10-26 05:37:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2008-03-06 18:40:09 +08:00
|
|
|
// This file defines methods that implement bitcode serialization for Decls.
|
2007-10-26 05:37:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-04-11 22:49:10 +08:00
|
|
|
#include "clang/AST/ASTContext.h"
|
2007-10-26 05:37:16 +08:00
|
|
|
#include "clang/AST/Decl.h"
|
2008-10-22 00:13:35 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
2007-10-26 05:37:16 +08:00
|
|
|
#include "clang/AST/Expr.h"
|
|
|
|
#include "llvm/Bitcode/Serialize.h"
|
|
|
|
#include "llvm/Bitcode/Deserialize.h"
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
using llvm::Serializer;
|
|
|
|
using llvm::Deserializer;
|
|
|
|
using llvm::SerializedPtrID;
|
|
|
|
|
2007-10-26 05:37:16 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Decl Serialization: Dispatch code to handle specialized decl types.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2007-11-06 05:38:00 +08:00
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
void Decl::Emit(Serializer& S) const {
|
|
|
|
S.EmitInt(getKind());
|
|
|
|
EmitImpl(S);
|
2008-06-10 09:32:09 +08:00
|
|
|
if (const DeclContext *DC = dyn_cast<const DeclContext>(this))
|
|
|
|
DC->EmitOutRec(S);
|
2007-10-26 05:37:16 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
Decl* Decl::Create(Deserializer& D, ASTContext& C) {
|
2007-11-13 08:15:39 +08:00
|
|
|
|
2008-06-10 09:32:09 +08:00
|
|
|
Decl *Dcl;
|
2007-11-07 03:51:47 +08:00
|
|
|
Kind k = static_cast<Kind>(D.ReadInt());
|
2008-04-08 05:55:54 +08:00
|
|
|
|
2007-11-07 03:51:47 +08:00
|
|
|
switch (k) {
|
|
|
|
default:
|
|
|
|
assert (false && "Not implemented.");
|
2008-04-04 14:12:32 +08:00
|
|
|
|
2008-04-17 22:40:12 +08:00
|
|
|
case TranslationUnit:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = TranslationUnitDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2008-04-17 22:40:12 +08:00
|
|
|
|
2008-04-27 21:50:30 +08:00
|
|
|
case Namespace:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = NamespaceDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2008-04-27 21:50:30 +08:00
|
|
|
|
2008-04-16 06:42:06 +08:00
|
|
|
case Var:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = VarDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2007-11-07 03:51:47 +08:00
|
|
|
|
2007-11-15 02:12:19 +08:00
|
|
|
case Enum:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = EnumDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2007-11-15 02:12:19 +08:00
|
|
|
|
|
|
|
case EnumConstant:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = EnumConstantDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2007-11-15 02:12:19 +08:00
|
|
|
|
2007-11-15 01:47:01 +08:00
|
|
|
case Field:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = FieldDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2007-11-15 01:47:01 +08:00
|
|
|
|
2007-11-07 03:51:47 +08:00
|
|
|
case ParmVar:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = ParmVarDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2007-11-07 03:51:47 +08:00
|
|
|
|
2008-12-21 04:56:12 +08:00
|
|
|
case OriginalParmVar:
|
|
|
|
Dcl = ParmVarWithOriginalTypeDecl::CreateImpl(D, C);
|
|
|
|
break;
|
|
|
|
|
2007-11-07 03:51:47 +08:00
|
|
|
case Function:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = FunctionDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2008-10-22 00:13:35 +08:00
|
|
|
|
|
|
|
case OverloadedFunction:
|
|
|
|
Dcl = OverloadedFunctionDecl::CreateImpl(D, C);
|
|
|
|
break;
|
|
|
|
|
2008-10-15 08:42:39 +08:00
|
|
|
case Record:
|
|
|
|
Dcl = RecordDecl::CreateImpl(D, C);
|
2008-06-10 09:32:09 +08:00
|
|
|
break;
|
2007-11-14 16:06:37 +08:00
|
|
|
|
2007-11-07 03:51:47 +08:00
|
|
|
case Typedef:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = TypedefDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2008-02-08 08:33:21 +08:00
|
|
|
|
2008-12-06 02:15:24 +08:00
|
|
|
case TemplateTypeParm:
|
|
|
|
Dcl = TemplateTypeParmDecl::CreateImpl(D, C);
|
|
|
|
break;
|
|
|
|
|
2008-02-08 08:33:21 +08:00
|
|
|
case FileScopeAsm:
|
2008-06-10 09:32:09 +08:00
|
|
|
Dcl = FileScopeAsmDecl::CreateImpl(D, C);
|
|
|
|
break;
|
2007-11-07 03:51:47 +08:00
|
|
|
}
|
2008-06-10 09:32:09 +08:00
|
|
|
|
|
|
|
if (DeclContext *DC = dyn_cast<DeclContext>(Dcl))
|
|
|
|
DC->ReadOutRec(D, C);
|
|
|
|
|
|
|
|
return Dcl;
|
2007-10-26 05:37:16 +08:00
|
|
|
}
|
2007-11-03 02:05:11 +08:00
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Common serialization logic for subclasses of Decl.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void Decl::EmitInRec(Serializer& S) const {
|
|
|
|
S.Emit(getLocation()); // From Decl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void Decl::ReadInRec(Deserializer& D, ASTContext& C) {
|
2007-11-13 08:15:39 +08:00
|
|
|
Loc = SourceLocation::ReadVal(D); // From Decl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-06-10 09:32:09 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Common serialization logic for subclasses of DeclContext.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void DeclContext::EmitOutRec(Serializer& S) const {
|
2009-01-10 03:42:16 +08:00
|
|
|
#if 0
|
|
|
|
// FIXME: it would be far easier to just serialize FirstDecl and let
|
|
|
|
// ScopedDecl do the work of serializing NextDeclInScope.
|
2008-12-12 00:49:14 +08:00
|
|
|
S.EmitInt(Decls.size());
|
|
|
|
for (decl_iterator D = decls_begin(); D != decls_end(); ++D) {
|
|
|
|
bool Owned = ((*D)->getLexicalDeclContext() == this &&
|
|
|
|
DeclKind != Decl::TranslationUnit &&
|
|
|
|
!isFunctionOrMethod());
|
|
|
|
S.EmitBool(Owned);
|
|
|
|
if (Owned)
|
|
|
|
S.EmitOwnedPtr(*D);
|
|
|
|
else
|
|
|
|
S.EmitPtr(*D);
|
|
|
|
}
|
2009-01-10 03:42:16 +08:00
|
|
|
#endif
|
2008-06-10 09:32:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeclContext::ReadOutRec(Deserializer& D, ASTContext& C) {
|
2009-01-10 03:42:16 +08:00
|
|
|
#if 0
|
|
|
|
// FIXME: See comment in DeclContext::EmitOutRec
|
2008-12-12 00:49:14 +08:00
|
|
|
unsigned NumDecls = D.ReadInt();
|
|
|
|
Decls.resize(NumDecls);
|
|
|
|
for (unsigned Idx = 0; Idx < NumDecls; ++Idx) {
|
|
|
|
bool Owned = D.ReadBool();
|
|
|
|
if (Owned)
|
|
|
|
Decls[Idx] = cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>(C));
|
|
|
|
else
|
|
|
|
D.ReadPtr<ScopedDecl>(Decls[Idx]);
|
|
|
|
}
|
2009-01-10 03:42:16 +08:00
|
|
|
#endif
|
2008-06-10 09:32:09 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Common serialization logic for subclasses of NamedDecl.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void NamedDecl::EmitInRec(Serializer& S) const {
|
|
|
|
Decl::EmitInRec(S);
|
2008-11-17 22:58:09 +08:00
|
|
|
S.EmitInt(Name.getNameKind());
|
|
|
|
|
|
|
|
switch (Name.getNameKind()) {
|
|
|
|
case DeclarationName::Identifier:
|
|
|
|
S.EmitPtr(Name.getAsIdentifierInfo());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DeclarationName::ObjCZeroArgSelector:
|
|
|
|
case DeclarationName::ObjCOneArgSelector:
|
|
|
|
case DeclarationName::ObjCMultiArgSelector:
|
|
|
|
Name.getObjCSelector().Emit(S);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DeclarationName::CXXConstructorName:
|
|
|
|
case DeclarationName::CXXDestructorName:
|
|
|
|
case DeclarationName::CXXConversionFunctionName:
|
|
|
|
Name.getCXXNameType().Emit(S);
|
|
|
|
break;
|
Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.
Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.
Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.
Extended Declarator to store overloaded operator names.
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator.
Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.
llvm-svn: 59526
2008-11-18 22:39:36 +08:00
|
|
|
|
|
|
|
case DeclarationName::CXXOperatorName:
|
|
|
|
S.EmitInt(Name.getCXXOverloadedOperator());
|
|
|
|
break;
|
2008-11-17 22:58:09 +08:00
|
|
|
}
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void NamedDecl::ReadInRec(Deserializer& D, ASTContext& C) {
|
|
|
|
Decl::ReadInRec(D, C);
|
2008-11-17 22:58:09 +08:00
|
|
|
|
|
|
|
DeclarationName::NameKind Kind
|
|
|
|
= static_cast<DeclarationName::NameKind>(D.ReadInt());
|
|
|
|
switch (Kind) {
|
|
|
|
case DeclarationName::Identifier: {
|
|
|
|
IdentifierInfo *Identifier;
|
|
|
|
D.ReadPtr(Identifier);
|
|
|
|
Name = Identifier;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DeclarationName::ObjCZeroArgSelector:
|
|
|
|
case DeclarationName::ObjCOneArgSelector:
|
|
|
|
case DeclarationName::ObjCMultiArgSelector:
|
|
|
|
Name = Selector::ReadVal(D);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DeclarationName::CXXConstructorName:
|
|
|
|
Name = C.DeclarationNames.getCXXConstructorName(QualType::ReadVal(D));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DeclarationName::CXXDestructorName:
|
|
|
|
Name = C.DeclarationNames.getCXXDestructorName(QualType::ReadVal(D));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DeclarationName::CXXConversionFunctionName:
|
Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.
Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.
Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.
Extended Declarator to store overloaded operator names.
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator.
Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.
llvm-svn: 59526
2008-11-18 22:39:36 +08:00
|
|
|
Name
|
|
|
|
= C.DeclarationNames.getCXXConversionFunctionName(QualType::ReadVal(D));
|
2008-11-17 22:58:09 +08:00
|
|
|
break;
|
Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.
Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.
Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.
Extended Declarator to store overloaded operator names.
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator.
Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.
llvm-svn: 59526
2008-11-18 22:39:36 +08:00
|
|
|
|
|
|
|
case DeclarationName::CXXOperatorName: {
|
|
|
|
OverloadedOperatorKind Op
|
|
|
|
= static_cast<OverloadedOperatorKind>(D.ReadInt());
|
|
|
|
Name = C.DeclarationNames.getCXXOperatorName(Op);
|
|
|
|
break;
|
|
|
|
}
|
2008-11-17 22:58:09 +08:00
|
|
|
}
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Common serialization logic for subclasses of ScopedDecl.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void ScopedDecl::EmitInRec(Serializer& S) const {
|
|
|
|
NamedDecl::EmitInRec(S);
|
2008-04-06 12:47:34 +08:00
|
|
|
S.EmitPtr(cast_or_null<Decl>(getDeclContext())); // From ScopedDecl.
|
2008-11-10 07:41:00 +08:00
|
|
|
S.EmitPtr(cast_or_null<Decl>(getLexicalDeclContext())); // From ScopedDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void ScopedDecl::ReadInRec(Deserializer& D, ASTContext& C) {
|
|
|
|
NamedDecl::ReadInRec(D, C);
|
2008-11-10 07:41:00 +08:00
|
|
|
|
|
|
|
assert(DeclCtx == 0);
|
|
|
|
|
|
|
|
const SerializedPtrID &SemaDCPtrID = D.ReadPtrID();
|
|
|
|
const SerializedPtrID &LexicalDCPtrID = D.ReadPtrID();
|
|
|
|
|
|
|
|
if (SemaDCPtrID == LexicalDCPtrID) {
|
|
|
|
// Allow back-patching. Observe that we register the variable of the
|
|
|
|
// *object* for back-patching. Its actual value will get filled in later.
|
|
|
|
D.ReadUIntPtr(DeclCtx, SemaDCPtrID);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
MultipleDC *MDC = new MultipleDC();
|
|
|
|
DeclCtx = reinterpret_cast<uintptr_t>(MDC) | 0x1;
|
|
|
|
// Allow back-patching. Observe that we register the variable of the
|
|
|
|
// *object* for back-patching. Its actual value will get filled in later.
|
2008-11-15 07:32:45 +08:00
|
|
|
D.ReadPtr(MDC->SemanticDC, SemaDCPtrID);
|
|
|
|
D.ReadPtr(MDC->LexicalDC, LexicalDCPtrID);
|
2008-11-10 07:41:00 +08:00
|
|
|
}
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
2007-11-13 08:15:39 +08:00
|
|
|
|
|
|
|
//===------------------------------------------------------------===//
|
|
|
|
// NOTE: Not all subclasses of ScopedDecl will use the "OutRec" //
|
|
|
|
// methods. This is because owned pointers are usually "batched" //
|
|
|
|
// together for efficiency. //
|
|
|
|
//===------------------------------------------------------------===//
|
2007-11-03 02:05:11 +08:00
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
void ScopedDecl::EmitOutRec(Serializer& S) const {
|
|
|
|
S.EmitOwnedPtr(getNextDeclarator()); // From ScopedDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void ScopedDecl::ReadOutRec(Deserializer& D, ASTContext& C) {
|
2007-11-13 08:15:39 +08:00
|
|
|
NextDeclarator =
|
2008-04-08 05:55:54 +08:00
|
|
|
cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>(C)); // From ScopedDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Common serialization logic for subclasses of ValueDecl.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2007-11-03 02:05:11 +08:00
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
void ValueDecl::EmitInRec(Serializer& S) const {
|
|
|
|
ScopedDecl::EmitInRec(S);
|
|
|
|
S.Emit(getType()); // From ValueDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void ValueDecl::ReadInRec(Deserializer& D, ASTContext& C) {
|
|
|
|
ScopedDecl::ReadInRec(D, C);
|
2007-11-13 08:15:39 +08:00
|
|
|
DeclType = QualType::ReadVal(D); // From ValueDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Common serialization logic for subclasses of VarDecl.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void VarDecl::EmitInRec(Serializer& S) const {
|
|
|
|
ValueDecl::EmitInRec(S);
|
|
|
|
S.EmitInt(getStorageClass()); // From VarDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void VarDecl::ReadInRec(Deserializer& D, ASTContext& C) {
|
|
|
|
ValueDecl::ReadInRec(D, C);
|
2007-12-13 08:54:18 +08:00
|
|
|
SClass = static_cast<StorageClass>(D.ReadInt()); // From VarDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===------------------------------------------------------------===//
|
|
|
|
// NOTE: VarDecl has its own "OutRec" methods that doesn't use //
|
|
|
|
// the one define in ScopedDecl. This is to batch emit the //
|
|
|
|
// owned pointers, which results in a smaller output.
|
|
|
|
//===------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void VarDecl::EmitOutRec(Serializer& S) const {
|
|
|
|
// Emit these last because they will create records of their own.
|
|
|
|
S.BatchEmitOwnedPtrs(getInit(), // From VarDecl.
|
|
|
|
getNextDeclarator()); // From ScopedDecl.
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void VarDecl::ReadOutRec(Deserializer& D, ASTContext& C) {
|
2007-11-13 08:15:39 +08:00
|
|
|
Decl* next_declarator;
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(Init, // From VarDecl.
|
|
|
|
next_declarator, // From ScopedDecl.
|
|
|
|
C);
|
2007-11-13 08:15:39 +08:00
|
|
|
|
|
|
|
setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void VarDecl::EmitImpl(Serializer& S) const {
|
|
|
|
VarDecl::EmitInRec(S);
|
|
|
|
VarDecl::EmitOutRec(S);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void VarDecl::ReadImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
ReadInRec(D, C);
|
|
|
|
ReadOutRec(D, C);
|
2007-11-13 08:15:39 +08:00
|
|
|
}
|
|
|
|
|
2008-04-17 22:40:12 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// TranslationUnitDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void TranslationUnitDecl::EmitImpl(llvm::Serializer& S) const
|
|
|
|
{
|
|
|
|
Decl::EmitInRec(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
TranslationUnitDecl* TranslationUnitDecl::CreateImpl(Deserializer& D,
|
|
|
|
ASTContext& C) {
|
|
|
|
void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>();
|
2008-04-27 21:50:30 +08:00
|
|
|
TranslationUnitDecl* decl = new (Mem) TranslationUnitDecl();
|
2008-04-17 22:40:12 +08:00
|
|
|
|
|
|
|
decl->Decl::ReadInRec(D, C);
|
|
|
|
|
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
2008-04-27 21:50:30 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// NamespaceDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void NamespaceDecl::EmitImpl(llvm::Serializer& S) const
|
|
|
|
{
|
|
|
|
ScopedDecl::EmitInRec(S);
|
|
|
|
S.Emit(getLBracLoc());
|
|
|
|
S.Emit(getRBracLoc());
|
|
|
|
ScopedDecl::EmitOutRec(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
NamespaceDecl* NamespaceDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
void *Mem = C.getAllocator().Allocate<NamespaceDecl>();
|
|
|
|
NamespaceDecl* decl = new (Mem) NamespaceDecl(0, SourceLocation(), 0);
|
|
|
|
|
|
|
|
decl->ScopedDecl::ReadInRec(D, C);
|
|
|
|
decl->LBracLoc = SourceLocation::ReadVal(D);
|
|
|
|
decl->RBracLoc = SourceLocation::ReadVal(D);
|
|
|
|
decl->ScopedDecl::ReadOutRec(D, C);
|
|
|
|
|
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2008-04-16 06:42:06 +08:00
|
|
|
// VarDecl Serialization.
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-04-16 06:42:06 +08:00
|
|
|
VarDecl* VarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
void *Mem = C.getAllocator().Allocate<VarDecl>();
|
|
|
|
VarDecl* decl =
|
|
|
|
new (Mem) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None, NULL);
|
2007-11-13 08:15:39 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->VarDecl::ReadImpl(D, C);
|
2007-11-13 08:15:39 +08:00
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2008-04-16 06:42:06 +08:00
|
|
|
// ParmVarDecl Serialization.
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-12-13 14:28:13 +08:00
|
|
|
void ParmVarDecl::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
VarDecl::EmitImpl(S);
|
2008-01-08 03:49:32 +08:00
|
|
|
S.EmitInt(getObjCDeclQualifier()); // From ParmVarDecl.
|
2008-04-08 12:40:51 +08:00
|
|
|
S.EmitOwnedPtr(getDefaultArg()); // From ParmVarDecl.
|
2007-12-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<ParmVarDecl>();
|
|
|
|
ParmVarDecl* decl = new (Mem)
|
2008-12-21 07:29:59 +08:00
|
|
|
ParmVarDecl(ParmVar,
|
|
|
|
0, SourceLocation(), NULL, QualType(), None, NULL, NULL);
|
2007-11-13 08:15:39 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->VarDecl::ReadImpl(D, C);
|
2008-01-08 03:49:32 +08:00
|
|
|
decl->objcDeclQualifier = static_cast<ObjCDeclQualifier>(D.ReadInt());
|
2008-04-08 12:40:51 +08:00
|
|
|
decl->DefaultArg = D.ReadOwnedPtr<Expr>(C);
|
2007-11-13 08:15:39 +08:00
|
|
|
return decl;
|
|
|
|
}
|
2007-11-03 02:05:11 +08:00
|
|
|
|
2008-12-21 04:56:12 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// ParmVarWithOriginalTypeDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void ParmVarWithOriginalTypeDecl::EmitImpl(llvm::Serializer& S) const {
|
|
|
|
ParmVarDecl::EmitImpl(S);
|
|
|
|
S.Emit(OriginalType);
|
|
|
|
}
|
|
|
|
|
|
|
|
ParmVarWithOriginalTypeDecl* ParmVarWithOriginalTypeDecl::CreateImpl(
|
|
|
|
Deserializer& D, ASTContext& C) {
|
|
|
|
void *Mem = C.getAllocator().Allocate<ParmVarWithOriginalTypeDecl>();
|
|
|
|
ParmVarWithOriginalTypeDecl* decl = new (Mem)
|
|
|
|
ParmVarWithOriginalTypeDecl(0, SourceLocation(), NULL, QualType(),
|
|
|
|
QualType(), None, NULL, NULL);
|
|
|
|
|
|
|
|
decl->ParmVarDecl::ReadImpl(D, C);
|
|
|
|
decl->OriginalType = QualType::ReadVal(D);
|
|
|
|
return decl;
|
|
|
|
}
|
2007-11-15 02:12:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// EnumDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void EnumDecl::EmitImpl(Serializer& S) const {
|
|
|
|
ScopedDecl::EmitInRec(S);
|
|
|
|
S.EmitBool(isDefinition());
|
2008-12-12 00:49:14 +08:00
|
|
|
S.Emit(IntegerType);
|
|
|
|
S.EmitOwnedPtr(getNextDeclarator());
|
2007-11-15 02:12:19 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
EnumDecl* EnumDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<EnumDecl>();
|
|
|
|
EnumDecl* decl = new (Mem) EnumDecl(0, SourceLocation(), NULL, NULL);
|
2007-11-15 02:12:19 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->ScopedDecl::ReadInRec(D, C);
|
2007-11-15 02:12:19 +08:00
|
|
|
decl->setDefinition(D.ReadBool());
|
|
|
|
decl->IntegerType = QualType::ReadVal(D);
|
|
|
|
|
2008-12-12 00:49:14 +08:00
|
|
|
Decl* next_declarator = D.ReadOwnedPtr<Decl>(C);
|
2007-11-15 02:12:19 +08:00
|
|
|
decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
|
|
|
|
|
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// EnumConstantDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void EnumConstantDecl::EmitImpl(Serializer& S) const {
|
|
|
|
S.Emit(Val);
|
|
|
|
ValueDecl::EmitInRec(S);
|
|
|
|
S.BatchEmitOwnedPtrs(getNextDeclarator(),Init);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-15 07:38:09 +08:00
|
|
|
llvm::APSInt val(1);
|
2007-11-15 02:12:19 +08:00
|
|
|
D.Read(val);
|
|
|
|
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<EnumConstantDecl>();
|
|
|
|
EnumConstantDecl* decl = new (Mem)
|
|
|
|
EnumConstantDecl(0, SourceLocation(), NULL, QualType(), NULL, val, NULL);
|
2007-11-15 02:12:19 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->ValueDecl::ReadInRec(D, C);
|
2007-11-15 02:12:19 +08:00
|
|
|
|
|
|
|
Decl* next_declarator;
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(next_declarator, decl->Init, C);
|
2007-11-15 02:12:19 +08:00
|
|
|
|
2007-11-15 07:38:09 +08:00
|
|
|
decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
|
2007-11-15 02:12:19 +08:00
|
|
|
|
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
2007-11-15 01:47:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// FieldDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void FieldDecl::EmitImpl(Serializer& S) const {
|
2008-12-12 00:49:14 +08:00
|
|
|
S.EmitBool(Mutable);
|
2007-11-15 01:47:01 +08:00
|
|
|
S.Emit(getType());
|
2008-12-12 00:49:14 +08:00
|
|
|
ScopedDecl::EmitInRec(S);
|
2007-11-15 01:47:01 +08:00
|
|
|
S.EmitOwnedPtr(BitWidth);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
FieldDecl* FieldDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<FieldDecl>();
|
2008-12-12 00:49:14 +08:00
|
|
|
FieldDecl* decl = new (Mem) FieldDecl(Field, 0, SourceLocation(), NULL,
|
|
|
|
QualType(), 0, false, 0);
|
|
|
|
decl->Mutable = D.ReadBool();
|
2007-11-15 06:51:02 +08:00
|
|
|
decl->DeclType.ReadBackpatch(D);
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->ReadInRec(D, C);
|
|
|
|
decl->BitWidth = D.ReadOwnedPtr<Expr>(C);
|
2007-11-15 01:47:01 +08:00
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// FunctionDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void FunctionDecl::EmitImpl(Serializer& S) const {
|
|
|
|
S.EmitInt(SClass); // From FunctionDecl.
|
|
|
|
S.EmitBool(IsInline); // From FunctionDecl.
|
|
|
|
ValueDecl::EmitInRec(S);
|
2008-05-20 11:33:58 +08:00
|
|
|
S.EmitPtr(PreviousDeclaration);
|
2007-11-03 02:05:11 +08:00
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
// NOTE: We do not need to serialize out the number of parameters, because
|
|
|
|
// that is encoded in the type (accessed via getNumParams()).
|
2007-11-03 02:05:11 +08:00
|
|
|
|
2007-11-14 06:51:08 +08:00
|
|
|
if (ParamInfo != NULL) {
|
|
|
|
S.EmitBool(true);
|
2008-11-07 22:22:23 +08:00
|
|
|
S.EmitInt(getNumParams());
|
2007-11-14 06:51:08 +08:00
|
|
|
S.BatchEmitOwnedPtrs(getNumParams(),&ParamInfo[0], Body,
|
|
|
|
getNextDeclarator());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
S.EmitBool(false);
|
|
|
|
S.BatchEmitOwnedPtrs(Body,getNextDeclarator());
|
|
|
|
}
|
2007-11-03 02:05:11 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-03 02:05:11 +08:00
|
|
|
StorageClass SClass = static_cast<StorageClass>(D.ReadInt());
|
|
|
|
bool IsInline = D.ReadBool();
|
|
|
|
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<FunctionDecl>();
|
|
|
|
FunctionDecl* decl = new (Mem)
|
2008-11-17 22:58:09 +08:00
|
|
|
FunctionDecl(Function, 0, SourceLocation(), DeclarationName(),
|
2008-06-10 05:05:31 +08:00
|
|
|
QualType(), SClass, IsInline, 0);
|
2007-11-03 02:05:11 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->ValueDecl::ReadInRec(D, C);
|
2008-05-20 11:33:58 +08:00
|
|
|
D.ReadPtr(decl->PreviousDeclaration);
|
2007-11-17 02:11:10 +08:00
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
Decl* next_declarator;
|
|
|
|
|
2009-01-06 01:18:30 +08:00
|
|
|
int numParams = 0;
|
2007-11-14 06:51:08 +08:00
|
|
|
bool hasParamDecls = D.ReadBool();
|
2008-11-07 22:22:23 +08:00
|
|
|
if (hasParamDecls)
|
|
|
|
numParams = D.ReadInt();
|
2007-11-17 02:11:10 +08:00
|
|
|
|
|
|
|
decl->ParamInfo = hasParamDecls
|
2008-11-07 22:22:23 +08:00
|
|
|
? new ParmVarDecl*[numParams]
|
2007-11-17 02:11:10 +08:00
|
|
|
: NULL;
|
2007-11-14 06:51:08 +08:00
|
|
|
|
|
|
|
if (hasParamDecls)
|
2008-11-07 22:22:23 +08:00
|
|
|
D.BatchReadOwnedPtrs(numParams,
|
2007-11-14 06:51:08 +08:00
|
|
|
reinterpret_cast<Decl**>(&decl->ParamInfo[0]),
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->Body, next_declarator, C);
|
2007-11-14 06:51:08 +08:00
|
|
|
else
|
2008-04-08 05:55:54 +08:00
|
|
|
D.BatchReadOwnedPtrs(decl->Body, next_declarator, C);
|
2007-11-13 08:15:39 +08:00
|
|
|
|
|
|
|
decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator));
|
2007-11-03 02:05:11 +08:00
|
|
|
|
|
|
|
return decl;
|
|
|
|
}
|
2007-11-06 05:49:34 +08:00
|
|
|
|
2008-10-09 01:01:13 +08:00
|
|
|
void BlockDecl::EmitImpl(Serializer& S) const {
|
|
|
|
// FIXME: what about arguments?
|
|
|
|
S.Emit(getCaretLocation());
|
|
|
|
S.EmitOwnedPtr(Body);
|
|
|
|
}
|
|
|
|
|
|
|
|
BlockDecl* BlockDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
QualType Q = QualType::ReadVal(D);
|
|
|
|
SourceLocation L = SourceLocation::ReadVal(D);
|
|
|
|
/*CompoundStmt* BodyStmt = cast<CompoundStmt>(*/D.ReadOwnedPtr<Stmt>(C)/*)*/;
|
|
|
|
assert(0 && "Cannot deserialize BlockBlockExpr yet");
|
|
|
|
// FIXME: need to handle parameters.
|
|
|
|
//return new BlockBlockExpr(L, Q, BodyStmt);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-22 00:13:35 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// OverloadedFunctionDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void OverloadedFunctionDecl::EmitImpl(Serializer& S) const {
|
|
|
|
NamedDecl::EmitInRec(S);
|
|
|
|
|
|
|
|
S.EmitInt(getNumFunctions());
|
|
|
|
for (unsigned func = 0; func < getNumFunctions(); ++func)
|
|
|
|
S.EmitPtr(Functions[func]);
|
|
|
|
}
|
|
|
|
|
|
|
|
OverloadedFunctionDecl *
|
|
|
|
OverloadedFunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
void *Mem = C.getAllocator().Allocate<OverloadedFunctionDecl>();
|
|
|
|
OverloadedFunctionDecl* decl = new (Mem)
|
2008-11-17 22:58:09 +08:00
|
|
|
OverloadedFunctionDecl(0, DeclarationName());
|
2008-10-22 00:13:35 +08:00
|
|
|
|
|
|
|
decl->NamedDecl::ReadInRec(D, C);
|
|
|
|
|
|
|
|
unsigned numFunctions = D.ReadInt();
|
|
|
|
decl->Functions.reserve(numFunctions);
|
|
|
|
for (unsigned func = 0; func < numFunctions; ++func)
|
|
|
|
D.ReadPtr(decl->Functions[func]);
|
|
|
|
|
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
2007-11-14 16:06:37 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// RecordDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-11-15 02:12:19 +08:00
|
|
|
void RecordDecl::EmitImpl(Serializer& S) const {
|
2008-10-15 08:42:39 +08:00
|
|
|
S.EmitInt(getTagKind());
|
|
|
|
|
2007-11-14 16:06:37 +08:00
|
|
|
ScopedDecl::EmitInRec(S);
|
2007-11-15 02:12:19 +08:00
|
|
|
S.EmitBool(isDefinition());
|
2007-11-14 16:06:37 +08:00
|
|
|
S.EmitBool(hasFlexibleArrayMember());
|
2009-01-07 08:43:41 +08:00
|
|
|
S.EmitBool(isAnonymousStructOrUnion());
|
2008-12-12 00:49:14 +08:00
|
|
|
ScopedDecl::EmitOutRec(S);
|
2007-11-14 16:06:37 +08:00
|
|
|
}
|
|
|
|
|
2008-10-15 08:42:39 +08:00
|
|
|
RecordDecl* RecordDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
TagKind TK = TagKind(D.ReadInt());
|
2008-04-08 05:55:54 +08:00
|
|
|
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<RecordDecl>();
|
2008-10-15 08:42:39 +08:00
|
|
|
RecordDecl* decl = new (Mem) RecordDecl(Record, TK, 0, SourceLocation(), NULL);
|
2007-11-15 02:12:19 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->ScopedDecl::ReadInRec(D, C);
|
2007-11-15 02:12:19 +08:00
|
|
|
decl->setDefinition(D.ReadBool());
|
2007-11-14 16:06:37 +08:00
|
|
|
decl->setHasFlexibleArrayMember(D.ReadBool());
|
2009-01-07 08:43:41 +08:00
|
|
|
decl->setAnonymousStructOrUnion(D.ReadBool());
|
2008-12-12 00:49:14 +08:00
|
|
|
decl->ScopedDecl::ReadOutRec(D, C);
|
|
|
|
|
2007-11-14 16:06:37 +08:00
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:15:39 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// TypedefDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void TypedefDecl::EmitImpl(Serializer& S) const {
|
2007-11-07 03:51:47 +08:00
|
|
|
S.Emit(UnderlyingType);
|
2007-11-13 08:15:39 +08:00
|
|
|
ScopedDecl::EmitInRec(S);
|
|
|
|
ScopedDecl::EmitOutRec(S);
|
2007-11-06 05:49:34 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
2007-11-13 08:15:39 +08:00
|
|
|
QualType T = QualType::ReadVal(D);
|
|
|
|
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<TypedefDecl>();
|
|
|
|
TypedefDecl* decl = new (Mem) TypedefDecl(0, SourceLocation(), NULL, T, NULL);
|
2007-11-13 08:15:39 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->ScopedDecl::ReadInRec(D, C);
|
|
|
|
decl->ScopedDecl::ReadOutRec(D, C);
|
2007-11-13 08:15:39 +08:00
|
|
|
|
2007-11-06 05:49:34 +08:00
|
|
|
return decl;
|
|
|
|
}
|
2008-01-12 15:05:38 +08:00
|
|
|
|
2008-12-06 02:15:24 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// TemplateTypeParmDecl Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void TemplateTypeParmDecl::EmitImpl(Serializer& S) const {
|
|
|
|
S.EmitBool(Typename);
|
|
|
|
ScopedDecl::EmitInRec(S);
|
|
|
|
ScopedDecl::EmitOutRec(S);
|
|
|
|
}
|
|
|
|
|
|
|
|
TemplateTypeParmDecl *
|
|
|
|
TemplateTypeParmDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
|
|
|
bool Typename = D.ReadBool();
|
|
|
|
void *Mem = C.getAllocator().Allocate<TemplateTypeParmDecl>();
|
|
|
|
TemplateTypeParmDecl *decl
|
|
|
|
= new (Mem) TemplateTypeParmDecl(0, SourceLocation(), NULL, Typename);
|
|
|
|
decl->ScopedDecl::ReadInRec(D, C);
|
|
|
|
decl->ScopedDecl::ReadOutRec(D, C);
|
|
|
|
return decl;
|
|
|
|
}
|
|
|
|
|
2008-01-12 15:05:38 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// LinkageSpec Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void LinkageSpecDecl::EmitInRec(Serializer& S) const {
|
|
|
|
Decl::EmitInRec(S);
|
|
|
|
S.EmitInt(getLanguage());
|
2008-12-17 06:23:02 +08:00
|
|
|
S.EmitBool(HadBraces);
|
2008-01-12 15:05:38 +08:00
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
void LinkageSpecDecl::ReadInRec(Deserializer& D, ASTContext& C) {
|
|
|
|
Decl::ReadInRec(D, C);
|
2008-01-12 15:05:38 +08:00
|
|
|
Language = static_cast<LanguageIDs>(D.ReadInt());
|
2008-12-17 06:23:02 +08:00
|
|
|
HadBraces = D.ReadBool();
|
2008-01-12 15:05:38 +08:00
|
|
|
}
|
2008-02-08 08:33:21 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// FileScopeAsm Serialization.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void FileScopeAsmDecl::EmitImpl(llvm::Serializer& S) const
|
|
|
|
{
|
|
|
|
Decl::EmitInRec(S);
|
|
|
|
S.EmitOwnedPtr(AsmString);
|
|
|
|
}
|
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
2008-04-11 22:49:10 +08:00
|
|
|
void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>();
|
|
|
|
FileScopeAsmDecl* decl = new (Mem) FileScopeAsmDecl(SourceLocation(), 0);
|
2008-02-08 08:33:21 +08:00
|
|
|
|
2008-04-08 05:55:54 +08:00
|
|
|
decl->Decl::ReadInRec(D, C);
|
|
|
|
decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>(C));
|
2008-02-08 08:33:21 +08:00
|
|
|
// D.ReadOwnedPtr(D.ReadOwnedPtr<StringLiteral>())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString);
|
|
|
|
|
|
|
|
return decl;
|
|
|
|
}
|