summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp6
-rw-r--r--clang/lib/AST/Decl.cpp8
-rw-r--r--clang/lib/AST/DeclSerialization.cpp23
3 files changed, 35 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e4b48e21e44..7220ce4f9f0 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1175,7 +1175,7 @@ int ASTContext::getIntegerTypeOrder(QualType LHS, QualType RHS) {
QualType ASTContext::getCFConstantStringType() {
if (!CFConstantStringTypeDecl) {
CFConstantStringTypeDecl =
- RecordDecl::Create(*this, Decl::Struct, NULL, SourceLocation(),
+ RecordDecl::Create(*this, Decl::Struct, TUDecl, SourceLocation(),
&Idents.get("NSConstantString"), 0);
QualType FieldTypes[4];
@@ -1727,6 +1727,8 @@ void ASTContext::Emit(llvm::Serializer& S) const {
I!=E;++I)
(*I)->Emit(S);
+ S.EmitOwnedPtr(TUDecl);
+
// FIXME: S.EmitOwnedPtr(CFConstantStringTypeDecl);
}
@@ -1743,6 +1745,8 @@ ASTContext* ASTContext::Create(llvm::Deserializer& D) {
for (unsigned i = 0; i < size_reserve; ++i)
Type::Create(*A,i,D);
+ A->TUDecl = cast<TranslationUnitDecl>(D.ReadOwnedPtr<Decl>(*A));
+
// FIXME: A->CFConstantStringTypeDecl = D.ReadOwnedPtr<RecordDecl>();
return A;
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 900096f1ecc..6ebaac569ff 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -198,6 +198,7 @@ void Decl::addDeclKind(Kind k) {
case ObjCPropertyImpl: nObjCPropertyImplDecl++; break;
case LinkageSpec: nLinkageSpecDecl++; break;
case FileScopeAsm: nFileScopeAsmDecl++; break;
+ case TranslationUnit: break;
}
}
@@ -205,6 +206,11 @@ void Decl::addDeclKind(Kind k) {
// Decl Allocation/Deallocation Method Implementations
//===----------------------------------------------------------------------===//
+TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) {
+ void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>();
+ return new (Mem) TranslationUnitDecl();
+}
+
VarDecl *VarDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L,
IdentifierInfo *Id, QualType T,
@@ -213,7 +219,6 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *CD,
return new (Mem) VarDecl(Var, CD, L, Id, T, S, PrevDecl);
}
-
ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *CD,
SourceLocation L, IdentifierInfo *Id,
QualType T, StorageClass S,
@@ -329,6 +334,7 @@ const Attr *Decl::getAttrs() const {
void Decl::Destroy(ASTContext& C) const {
switch (getKind()) {
+ CASE(TranslationUnit);
CASE(Field);
CASE(ObjCIvar);
CASE(ObjCCategory);
diff --git a/clang/lib/AST/DeclSerialization.cpp b/clang/lib/AST/DeclSerialization.cpp
index 96df1b7fbf4..e7442ff51cc 100644
--- a/clang/lib/AST/DeclSerialization.cpp
+++ b/clang/lib/AST/DeclSerialization.cpp
@@ -41,6 +41,9 @@ Decl* Decl::Create(Deserializer& D, ASTContext& C) {
assert (false && "Not implemented.");
break;
+ case TranslationUnit:
+ return TranslationUnitDecl::CreateImpl(D, C);
+
case Var:
return VarDecl::CreateImpl(D, C);
@@ -192,6 +195,26 @@ void VarDecl::ReadImpl(Deserializer& D, ASTContext& C) {
}
//===----------------------------------------------------------------------===//
+// 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>();
+ TranslationUnitDecl* decl =
+ new (Mem) TranslationUnitDecl();
+
+ decl->Decl::ReadInRec(D, C);
+
+ return decl;
+}
+
+//===----------------------------------------------------------------------===//
// VarDecl Serialization.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud