Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 1 | //===--- DeclSerialization.cpp - Serialization of Decls ---------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Gabor Greif | 843e934 | 2008-03-06 10:40:09 +0000 | [diff] [blame] | 10 | // This file defines methods that implement bitcode serialization for Decls. |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 14 | #include "clang/AST/ASTContext.h" |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 15 | #include "clang/AST/Decl.h" |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclCXX.h" |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 17 | #include "clang/AST/Expr.h" |
| 18 | #include "llvm/Bitcode/Serialize.h" |
| 19 | #include "llvm/Bitcode/Deserialize.h" |
| 20 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 21 | using llvm::Serializer; |
| 22 | using llvm::Deserializer; |
| 23 | using llvm::SerializedPtrID; |
| 24 | |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 25 | using namespace clang; |
| 26 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 27 | //===----------------------------------------------------------------------===// |
| 28 | // Decl Serialization: Dispatch code to handle specialized decl types. |
| 29 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 8af8fe3 | 2007-11-05 21:38:00 +0000 | [diff] [blame] | 30 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 31 | void Decl::Emit(Serializer& S) const { |
| 32 | S.EmitInt(getKind()); |
| 33 | EmitImpl(S); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 34 | S.Emit(getLocation()); |
| 35 | S.EmitBool(InvalidDecl); |
| 36 | // FIXME: HasAttrs? |
| 37 | S.EmitBool(Implicit); |
| 38 | S.EmitInt(Access); |
| 39 | S.EmitPtr(cast_or_null<Decl>(getDeclContext())); // From Decl. |
| 40 | S.EmitPtr(cast_or_null<Decl>(getLexicalDeclContext())); // From Decl. |
| 41 | S.EmitPtr(NextDeclarator); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 42 | if (const DeclContext *DC = dyn_cast<const DeclContext>(this)) |
| 43 | DC->EmitOutRec(S); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 44 | |
| 45 | if (getDeclContext() && |
| 46 | !getDeclContext()->isFunctionOrMethod()) { |
| 47 | S.EmitBool(true); |
| 48 | S.EmitOwnedPtr(NextDeclInScope); |
| 49 | } else { |
| 50 | S.EmitBool(false); |
| 51 | S.EmitPtr(NextDeclInScope); |
| 52 | } |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 55 | Decl* Decl::Create(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 56 | |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 57 | Decl *Dcl; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 58 | Kind k = static_cast<Kind>(D.ReadInt()); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 59 | |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 60 | switch (k) { |
| 61 | default: |
| 62 | assert (false && "Not implemented."); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 63 | |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 64 | case TranslationUnit: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 65 | Dcl = TranslationUnitDecl::CreateImpl(D, C); |
| 66 | break; |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 67 | |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 68 | case Namespace: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 69 | Dcl = NamespaceDecl::CreateImpl(D, C); |
| 70 | break; |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 71 | |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 72 | case Var: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 73 | Dcl = VarDecl::CreateImpl(D, C); |
| 74 | break; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 75 | |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 76 | case Enum: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 77 | Dcl = EnumDecl::CreateImpl(D, C); |
| 78 | break; |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 79 | |
| 80 | case EnumConstant: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 81 | Dcl = EnumConstantDecl::CreateImpl(D, C); |
| 82 | break; |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 83 | |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 84 | case Field: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 85 | Dcl = FieldDecl::CreateImpl(D, C); |
| 86 | break; |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 87 | |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 88 | case ParmVar: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 89 | Dcl = ParmVarDecl::CreateImpl(D, C); |
| 90 | break; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 91 | |
Fariborz Jahanian | 73da9e4 | 2008-12-20 20:56:12 +0000 | [diff] [blame] | 92 | case OriginalParmVar: |
| 93 | Dcl = ParmVarWithOriginalTypeDecl::CreateImpl(D, C); |
| 94 | break; |
| 95 | |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 96 | case Function: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 97 | Dcl = FunctionDecl::CreateImpl(D, C); |
| 98 | break; |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 99 | |
| 100 | case OverloadedFunction: |
| 101 | Dcl = OverloadedFunctionDecl::CreateImpl(D, C); |
| 102 | break; |
| 103 | |
Argyrios Kyrtzidis | 35bc082 | 2008-10-15 00:42:39 +0000 | [diff] [blame] | 104 | case Record: |
| 105 | Dcl = RecordDecl::CreateImpl(D, C); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 106 | break; |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 107 | |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 108 | case Typedef: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 109 | Dcl = TypedefDecl::CreateImpl(D, C); |
| 110 | break; |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 111 | |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 112 | case TemplateTypeParm: |
| 113 | Dcl = TemplateTypeParmDecl::CreateImpl(D, C); |
| 114 | break; |
| 115 | |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 116 | case FileScopeAsm: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 117 | Dcl = FileScopeAsmDecl::CreateImpl(D, C); |
| 118 | break; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 119 | } |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 120 | |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 121 | Dcl->Loc = SourceLocation::ReadVal(D); // From Decl. |
| 122 | Dcl->InvalidDecl = D.ReadBool(); |
| 123 | // FIXME: HasAttrs? |
| 124 | Dcl->Implicit = D.ReadBool(); |
| 125 | Dcl->Access = D.ReadInt(); |
| 126 | |
| 127 | assert(Dcl->DeclCtx == 0); |
| 128 | |
| 129 | const SerializedPtrID &SemaDCPtrID = D.ReadPtrID(); |
| 130 | const SerializedPtrID &LexicalDCPtrID = D.ReadPtrID(); |
| 131 | |
| 132 | if (SemaDCPtrID == LexicalDCPtrID) { |
| 133 | // Allow back-patching. Observe that we register the variable of the |
| 134 | // *object* for back-patching. Its actual value will get filled in later. |
| 135 | D.ReadUIntPtr(Dcl->DeclCtx, SemaDCPtrID); |
| 136 | } |
| 137 | else { |
| 138 | MultipleDC *MDC = new MultipleDC(); |
| 139 | Dcl->DeclCtx = reinterpret_cast<uintptr_t>(MDC) | 0x1; |
| 140 | // Allow back-patching. Observe that we register the variable of the |
| 141 | // *object* for back-patching. Its actual value will get filled in later. |
| 142 | D.ReadPtr(MDC->SemanticDC, SemaDCPtrID); |
| 143 | D.ReadPtr(MDC->LexicalDC, LexicalDCPtrID); |
| 144 | } |
| 145 | D.ReadPtr(Dcl->NextDeclarator); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 146 | if (DeclContext *DC = dyn_cast<DeclContext>(Dcl)) |
| 147 | DC->ReadOutRec(D, C); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 148 | bool OwnsNext = D.ReadBool(); |
| 149 | if (OwnsNext) |
| 150 | Dcl->NextDeclInScope = D.ReadOwnedPtr<Decl>(C); |
| 151 | else |
| 152 | D.ReadPtr(Dcl->NextDeclInScope); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 153 | return Dcl; |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 154 | } |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 155 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 156 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 157 | // Common serialization logic for subclasses of DeclContext. |
| 158 | //===----------------------------------------------------------------------===// |
| 159 | |
| 160 | void DeclContext::EmitOutRec(Serializer& S) const { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 161 | bool Owned = !isFunctionOrMethod(); |
| 162 | S.EmitBool(Owned); |
| 163 | if (Owned) |
| 164 | S.EmitOwnedPtr(FirstDecl); |
| 165 | else |
| 166 | S.EmitPtr(FirstDecl); |
| 167 | S.EmitPtr(LastDecl); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | void DeclContext::ReadOutRec(Deserializer& D, ASTContext& C) { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 171 | bool Owned = D.ReadBool(); |
| 172 | if (Owned) |
| 173 | FirstDecl = cast_or_null<Decl>(D.ReadOwnedPtr<Decl>(C)); |
| 174 | else |
| 175 | D.ReadPtr(FirstDecl); |
| 176 | D.ReadPtr(LastDecl); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 180 | // Common serialization logic for subclasses of NamedDecl. |
| 181 | //===----------------------------------------------------------------------===// |
| 182 | |
| 183 | void NamedDecl::EmitInRec(Serializer& S) const { |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 184 | S.EmitInt(Name.getNameKind()); |
| 185 | |
| 186 | switch (Name.getNameKind()) { |
| 187 | case DeclarationName::Identifier: |
| 188 | S.EmitPtr(Name.getAsIdentifierInfo()); |
| 189 | break; |
| 190 | |
| 191 | case DeclarationName::ObjCZeroArgSelector: |
| 192 | case DeclarationName::ObjCOneArgSelector: |
| 193 | case DeclarationName::ObjCMultiArgSelector: |
| 194 | Name.getObjCSelector().Emit(S); |
| 195 | break; |
| 196 | |
| 197 | case DeclarationName::CXXConstructorName: |
| 198 | case DeclarationName::CXXDestructorName: |
| 199 | case DeclarationName::CXXConversionFunctionName: |
| 200 | Name.getCXXNameType().Emit(S); |
| 201 | break; |
Douglas Gregor | e94ca9e4 | 2008-11-18 14:39:36 +0000 | [diff] [blame] | 202 | |
| 203 | case DeclarationName::CXXOperatorName: |
| 204 | S.EmitInt(Name.getCXXOverloadedOperator()); |
| 205 | break; |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 206 | } |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 207 | } |
| 208 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 209 | void NamedDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 210 | DeclarationName::NameKind Kind |
| 211 | = static_cast<DeclarationName::NameKind>(D.ReadInt()); |
| 212 | switch (Kind) { |
| 213 | case DeclarationName::Identifier: { |
Ted Kremenek | ddf32da | 2009-01-21 00:42:24 +0000 | [diff] [blame] | 214 | // Don't allow back-patching. The IdentifierInfo table must already |
| 215 | // be loaded. |
| 216 | Name = D.ReadPtr<IdentifierInfo>(); |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 217 | break; |
| 218 | } |
| 219 | |
| 220 | case DeclarationName::ObjCZeroArgSelector: |
| 221 | case DeclarationName::ObjCOneArgSelector: |
| 222 | case DeclarationName::ObjCMultiArgSelector: |
| 223 | Name = Selector::ReadVal(D); |
| 224 | break; |
| 225 | |
| 226 | case DeclarationName::CXXConstructorName: |
| 227 | Name = C.DeclarationNames.getCXXConstructorName(QualType::ReadVal(D)); |
| 228 | break; |
| 229 | |
| 230 | case DeclarationName::CXXDestructorName: |
| 231 | Name = C.DeclarationNames.getCXXDestructorName(QualType::ReadVal(D)); |
| 232 | break; |
| 233 | |
| 234 | case DeclarationName::CXXConversionFunctionName: |
Douglas Gregor | e94ca9e4 | 2008-11-18 14:39:36 +0000 | [diff] [blame] | 235 | Name |
| 236 | = C.DeclarationNames.getCXXConversionFunctionName(QualType::ReadVal(D)); |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 237 | break; |
Douglas Gregor | e94ca9e4 | 2008-11-18 14:39:36 +0000 | [diff] [blame] | 238 | |
| 239 | case DeclarationName::CXXOperatorName: { |
| 240 | OverloadedOperatorKind Op |
| 241 | = static_cast<OverloadedOperatorKind>(D.ReadInt()); |
| 242 | Name = C.DeclarationNames.getCXXOperatorName(Op); |
| 243 | break; |
| 244 | } |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 245 | } |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 248 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 249 | // Common serialization logic for subclasses of ValueDecl. |
| 250 | //===----------------------------------------------------------------------===// |
| 251 | |
| 252 | void ValueDecl::EmitInRec(Serializer& S) const { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 253 | NamedDecl::EmitInRec(S); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 254 | S.Emit(getType()); // From ValueDecl. |
| 255 | } |
| 256 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 257 | void ValueDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 258 | NamedDecl::ReadInRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 259 | DeclType = QualType::ReadVal(D); // From ValueDecl. |
| 260 | } |
| 261 | |
| 262 | //===----------------------------------------------------------------------===// |
| 263 | // Common serialization logic for subclasses of VarDecl. |
| 264 | //===----------------------------------------------------------------------===// |
| 265 | |
| 266 | void VarDecl::EmitInRec(Serializer& S) const { |
| 267 | ValueDecl::EmitInRec(S); |
| 268 | S.EmitInt(getStorageClass()); // From VarDecl. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 269 | } |
| 270 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 271 | void VarDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
| 272 | ValueDecl::ReadInRec(D, C); |
Fariborz Jahanian | de7b4cd | 2007-12-13 00:54:18 +0000 | [diff] [blame] | 273 | SClass = static_cast<StorageClass>(D.ReadInt()); // From VarDecl. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 276 | void VarDecl::EmitOutRec(Serializer& S) const { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 277 | // Emit this last because it will create a record of its own. |
| 278 | S.EmitOwnedPtr(getInit()); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 279 | } |
| 280 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 281 | void VarDecl::ReadOutRec(Deserializer& D, ASTContext& C) { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 282 | Init = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 286 | void VarDecl::EmitImpl(Serializer& S) const { |
| 287 | VarDecl::EmitInRec(S); |
| 288 | VarDecl::EmitOutRec(S); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 289 | } |
| 290 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 291 | void VarDecl::ReadImpl(Deserializer& D, ASTContext& C) { |
| 292 | ReadInRec(D, C); |
| 293 | ReadOutRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 297 | // TranslationUnitDecl Serialization. |
| 298 | //===----------------------------------------------------------------------===// |
| 299 | |
| 300 | void TranslationUnitDecl::EmitImpl(llvm::Serializer& S) const |
| 301 | { |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | TranslationUnitDecl* TranslationUnitDecl::CreateImpl(Deserializer& D, |
| 305 | ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 306 | return new (C) TranslationUnitDecl(); |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 310 | // NamespaceDecl Serialization. |
| 311 | //===----------------------------------------------------------------------===// |
| 312 | |
| 313 | void NamespaceDecl::EmitImpl(llvm::Serializer& S) const |
| 314 | { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 315 | NamedDecl::EmitInRec(S); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 316 | S.Emit(getLBracLoc()); |
| 317 | S.Emit(getRBracLoc()); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | NamespaceDecl* NamespaceDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 321 | NamespaceDecl* decl = new (C) NamespaceDecl(0, SourceLocation(), 0); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 322 | |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 323 | decl->NamedDecl::ReadInRec(D, C); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 324 | decl->LBracLoc = SourceLocation::ReadVal(D); |
| 325 | decl->RBracLoc = SourceLocation::ReadVal(D); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 326 | |
| 327 | return decl; |
| 328 | } |
| 329 | |
| 330 | //===----------------------------------------------------------------------===// |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 331 | // VarDecl Serialization. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 332 | //===----------------------------------------------------------------------===// |
| 333 | |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 334 | VarDecl* VarDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 335 | VarDecl* decl = |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 336 | new (C) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 337 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 338 | decl->VarDecl::ReadImpl(D, C); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 339 | return decl; |
| 340 | } |
| 341 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 342 | //===----------------------------------------------------------------------===// |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 343 | // ParmVarDecl Serialization. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 344 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 345 | |
Ted Kremenek | 137bd91 | 2007-12-13 06:28:13 +0000 | [diff] [blame] | 346 | void ParmVarDecl::EmitImpl(llvm::Serializer& S) const { |
| 347 | VarDecl::EmitImpl(S); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 348 | S.EmitInt(getObjCDeclQualifier()); // From ParmVarDecl. |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 349 | S.EmitOwnedPtr(getDefaultArg()); // From ParmVarDecl. |
Ted Kremenek | 137bd91 | 2007-12-13 06:28:13 +0000 | [diff] [blame] | 350 | } |
| 351 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 352 | ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 353 | ParmVarDecl* decl = new (C) |
Fariborz Jahanian | 4306d3c | 2008-12-20 23:29:59 +0000 | [diff] [blame] | 354 | ParmVarDecl(ParmVar, |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 355 | 0, SourceLocation(), NULL, QualType(), None, NULL); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 356 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 357 | decl->VarDecl::ReadImpl(D, C); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 358 | decl->objcDeclQualifier = static_cast<ObjCDeclQualifier>(D.ReadInt()); |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 359 | decl->DefaultArg = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 360 | return decl; |
| 361 | } |
| 362 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 363 | //===----------------------------------------------------------------------===// |
Fariborz Jahanian | 73da9e4 | 2008-12-20 20:56:12 +0000 | [diff] [blame] | 364 | // ParmVarWithOriginalTypeDecl Serialization. |
| 365 | //===----------------------------------------------------------------------===// |
| 366 | |
| 367 | void ParmVarWithOriginalTypeDecl::EmitImpl(llvm::Serializer& S) const { |
| 368 | ParmVarDecl::EmitImpl(S); |
| 369 | S.Emit(OriginalType); |
| 370 | } |
| 371 | |
| 372 | ParmVarWithOriginalTypeDecl* ParmVarWithOriginalTypeDecl::CreateImpl( |
| 373 | Deserializer& D, ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 374 | ParmVarWithOriginalTypeDecl* decl = new (C) |
Fariborz Jahanian | 73da9e4 | 2008-12-20 20:56:12 +0000 | [diff] [blame] | 375 | ParmVarWithOriginalTypeDecl(0, SourceLocation(), NULL, QualType(), |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 376 | QualType(), None, NULL); |
Fariborz Jahanian | 73da9e4 | 2008-12-20 20:56:12 +0000 | [diff] [blame] | 377 | |
| 378 | decl->ParmVarDecl::ReadImpl(D, C); |
| 379 | decl->OriginalType = QualType::ReadVal(D); |
| 380 | return decl; |
| 381 | } |
| 382 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 383 | // EnumDecl Serialization. |
| 384 | //===----------------------------------------------------------------------===// |
| 385 | |
| 386 | void EnumDecl::EmitImpl(Serializer& S) const { |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 387 | NamedDecl::EmitInRec(S); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 388 | S.EmitBool(isDefinition()); |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 389 | S.Emit(IntegerType); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 392 | EnumDecl* EnumDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 393 | EnumDecl* decl = new (C) EnumDecl(0, SourceLocation(), NULL); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 394 | |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 395 | decl->NamedDecl::ReadInRec(D, C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 396 | decl->setDefinition(D.ReadBool()); |
| 397 | decl->IntegerType = QualType::ReadVal(D); |
| 398 | |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 399 | return decl; |
| 400 | } |
| 401 | |
| 402 | //===----------------------------------------------------------------------===// |
| 403 | // EnumConstantDecl Serialization. |
| 404 | //===----------------------------------------------------------------------===// |
| 405 | |
| 406 | void EnumConstantDecl::EmitImpl(Serializer& S) const { |
| 407 | S.Emit(Val); |
| 408 | ValueDecl::EmitInRec(S); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 409 | S.EmitOwnedPtr(Init); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 410 | } |
| 411 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 412 | EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 049b168 | 2007-11-14 23:38:09 +0000 | [diff] [blame] | 413 | llvm::APSInt val(1); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 414 | D.Read(val); |
| 415 | |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 416 | EnumConstantDecl* decl = new (C) |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 417 | EnumConstantDecl(0, SourceLocation(), NULL, QualType(), NULL, val); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 418 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 419 | decl->ValueDecl::ReadInRec(D, C); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 420 | decl->Init = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 421 | return decl; |
| 422 | } |
| 423 | |
| 424 | //===----------------------------------------------------------------------===// |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 425 | // FieldDecl Serialization. |
| 426 | //===----------------------------------------------------------------------===// |
| 427 | |
| 428 | void FieldDecl::EmitImpl(Serializer& S) const { |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 429 | S.EmitBool(Mutable); |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 430 | S.Emit(getType()); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 431 | NamedDecl::EmitInRec(S); |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 432 | S.EmitOwnedPtr(BitWidth); |
| 433 | } |
| 434 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 435 | FieldDecl* FieldDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 436 | FieldDecl* decl = new (C) FieldDecl(Field, 0, SourceLocation(), NULL, |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 437 | QualType(), 0, false); |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 438 | decl->Mutable = D.ReadBool(); |
Ted Kremenek | 21d50e1 | 2007-11-14 22:51:02 +0000 | [diff] [blame] | 439 | decl->DeclType.ReadBackpatch(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 440 | decl->ReadInRec(D, C); |
| 441 | decl->BitWidth = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 442 | return decl; |
| 443 | } |
| 444 | |
| 445 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 446 | // FunctionDecl Serialization. |
| 447 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 448 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 449 | void FunctionDecl::EmitImpl(Serializer& S) const { |
| 450 | S.EmitInt(SClass); // From FunctionDecl. |
| 451 | S.EmitBool(IsInline); // From FunctionDecl. |
| 452 | ValueDecl::EmitInRec(S); |
Ted Kremenek | 3bbc198 | 2008-05-20 03:33:58 +0000 | [diff] [blame] | 453 | S.EmitPtr(PreviousDeclaration); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 454 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 455 | // NOTE: We do not need to serialize out the number of parameters, because |
| 456 | // that is encoded in the type (accessed via getNumParams()). |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 457 | |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 458 | if (ParamInfo != NULL) { |
| 459 | S.EmitBool(true); |
Argyrios Kyrtzidis | dc5ddbf | 2008-11-07 14:22:23 +0000 | [diff] [blame] | 460 | S.EmitInt(getNumParams()); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 461 | S.BatchEmitOwnedPtrs(getNumParams(),&ParamInfo[0], Body); |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 462 | } |
| 463 | else { |
| 464 | S.EmitBool(false); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 465 | S.EmitOwnedPtr(Body); |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 466 | } |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 467 | } |
| 468 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 469 | FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 470 | StorageClass SClass = static_cast<StorageClass>(D.ReadInt()); |
| 471 | bool IsInline = D.ReadBool(); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 472 | |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 473 | FunctionDecl* decl = new (C) |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 474 | FunctionDecl(Function, 0, SourceLocation(), DeclarationName(), |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 475 | QualType(), SClass, IsInline); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 476 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 477 | decl->ValueDecl::ReadInRec(D, C); |
Ted Kremenek | 3bbc198 | 2008-05-20 03:33:58 +0000 | [diff] [blame] | 478 | D.ReadPtr(decl->PreviousDeclaration); |
Ted Kremenek | da25685 | 2007-11-16 18:11:10 +0000 | [diff] [blame] | 479 | |
Douglas Gregor | 6b54bd1 | 2009-01-05 17:18:30 +0000 | [diff] [blame] | 480 | int numParams = 0; |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 481 | bool hasParamDecls = D.ReadBool(); |
Argyrios Kyrtzidis | dc5ddbf | 2008-11-07 14:22:23 +0000 | [diff] [blame] | 482 | if (hasParamDecls) |
| 483 | numParams = D.ReadInt(); |
Ted Kremenek | da25685 | 2007-11-16 18:11:10 +0000 | [diff] [blame] | 484 | |
| 485 | decl->ParamInfo = hasParamDecls |
Argyrios Kyrtzidis | dc5ddbf | 2008-11-07 14:22:23 +0000 | [diff] [blame] | 486 | ? new ParmVarDecl*[numParams] |
Ted Kremenek | da25685 | 2007-11-16 18:11:10 +0000 | [diff] [blame] | 487 | : NULL; |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 488 | |
| 489 | if (hasParamDecls) |
Argyrios Kyrtzidis | dc5ddbf | 2008-11-07 14:22:23 +0000 | [diff] [blame] | 490 | D.BatchReadOwnedPtrs(numParams, |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 491 | reinterpret_cast<Decl**>(&decl->ParamInfo[0]), |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 492 | decl->Body, C); |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 493 | else |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 494 | decl->Body = D.ReadOwnedPtr<Stmt>(C); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 495 | |
| 496 | return decl; |
| 497 | } |
Ted Kremenek | f7bf411 | 2007-11-05 21:49:34 +0000 | [diff] [blame] | 498 | |
Steve Naroff | 56ee689 | 2008-10-08 17:01:13 +0000 | [diff] [blame] | 499 | void BlockDecl::EmitImpl(Serializer& S) const { |
| 500 | // FIXME: what about arguments? |
| 501 | S.Emit(getCaretLocation()); |
| 502 | S.EmitOwnedPtr(Body); |
| 503 | } |
| 504 | |
| 505 | BlockDecl* BlockDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
| 506 | QualType Q = QualType::ReadVal(D); |
| 507 | SourceLocation L = SourceLocation::ReadVal(D); |
| 508 | /*CompoundStmt* BodyStmt = cast<CompoundStmt>(*/D.ReadOwnedPtr<Stmt>(C)/*)*/; |
| 509 | assert(0 && "Cannot deserialize BlockBlockExpr yet"); |
| 510 | // FIXME: need to handle parameters. |
| 511 | //return new BlockBlockExpr(L, Q, BodyStmt); |
| 512 | return 0; |
| 513 | } |
| 514 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 515 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 516 | // OverloadedFunctionDecl Serialization. |
| 517 | //===----------------------------------------------------------------------===// |
| 518 | |
| 519 | void OverloadedFunctionDecl::EmitImpl(Serializer& S) const { |
| 520 | NamedDecl::EmitInRec(S); |
| 521 | |
| 522 | S.EmitInt(getNumFunctions()); |
| 523 | for (unsigned func = 0; func < getNumFunctions(); ++func) |
| 524 | S.EmitPtr(Functions[func]); |
| 525 | } |
| 526 | |
| 527 | OverloadedFunctionDecl * |
| 528 | OverloadedFunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 529 | OverloadedFunctionDecl* decl = new (C) |
Douglas Gregor | 2e1cd42 | 2008-11-17 14:58:09 +0000 | [diff] [blame] | 530 | OverloadedFunctionDecl(0, DeclarationName()); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 531 | |
| 532 | decl->NamedDecl::ReadInRec(D, C); |
| 533 | |
| 534 | unsigned numFunctions = D.ReadInt(); |
| 535 | decl->Functions.reserve(numFunctions); |
| 536 | for (unsigned func = 0; func < numFunctions; ++func) |
| 537 | D.ReadPtr(decl->Functions[func]); |
| 538 | |
| 539 | return decl; |
| 540 | } |
| 541 | |
| 542 | //===----------------------------------------------------------------------===// |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 543 | // RecordDecl Serialization. |
| 544 | //===----------------------------------------------------------------------===// |
| 545 | |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 546 | void RecordDecl::EmitImpl(Serializer& S) const { |
Argyrios Kyrtzidis | 35bc082 | 2008-10-15 00:42:39 +0000 | [diff] [blame] | 547 | S.EmitInt(getTagKind()); |
| 548 | |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 549 | NamedDecl::EmitInRec(S); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 550 | S.EmitBool(isDefinition()); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 551 | S.EmitBool(hasFlexibleArrayMember()); |
Douglas Gregor | bcbffc4 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 552 | S.EmitBool(isAnonymousStructOrUnion()); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 553 | } |
| 554 | |
Argyrios Kyrtzidis | 35bc082 | 2008-10-15 00:42:39 +0000 | [diff] [blame] | 555 | RecordDecl* RecordDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
| 556 | TagKind TK = TagKind(D.ReadInt()); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 557 | |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 558 | RecordDecl* decl = new (C) RecordDecl(Record, TK, 0, SourceLocation(), NULL); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 559 | |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 560 | decl->NamedDecl::ReadInRec(D, C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 561 | decl->setDefinition(D.ReadBool()); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 562 | decl->setHasFlexibleArrayMember(D.ReadBool()); |
Douglas Gregor | bcbffc4 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 563 | decl->setAnonymousStructOrUnion(D.ReadBool()); |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 564 | |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 565 | return decl; |
| 566 | } |
| 567 | |
| 568 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 569 | // TypedefDecl Serialization. |
| 570 | //===----------------------------------------------------------------------===// |
| 571 | |
| 572 | void TypedefDecl::EmitImpl(Serializer& S) const { |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 573 | S.Emit(UnderlyingType); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 574 | NamedDecl::EmitInRec(S); |
Ted Kremenek | f7bf411 | 2007-11-05 21:49:34 +0000 | [diff] [blame] | 575 | } |
| 576 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 577 | TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 578 | QualType T = QualType::ReadVal(D); |
| 579 | |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 580 | TypedefDecl* decl = new (C) TypedefDecl(0, SourceLocation(), NULL, T); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 581 | |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 582 | decl->NamedDecl::ReadInRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 583 | |
Ted Kremenek | f7bf411 | 2007-11-05 21:49:34 +0000 | [diff] [blame] | 584 | return decl; |
| 585 | } |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 586 | |
| 587 | //===----------------------------------------------------------------------===// |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 588 | // TemplateTypeParmDecl Serialization. |
| 589 | //===----------------------------------------------------------------------===// |
| 590 | |
| 591 | void TemplateTypeParmDecl::EmitImpl(Serializer& S) const { |
| 592 | S.EmitBool(Typename); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 593 | NamedDecl::EmitInRec(S); |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | TemplateTypeParmDecl * |
| 597 | TemplateTypeParmDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
| 598 | bool Typename = D.ReadBool(); |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 599 | TemplateTypeParmDecl *decl |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 600 | = new (C) TemplateTypeParmDecl(0, SourceLocation(), NULL, Typename); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 601 | decl->NamedDecl::ReadInRec(D, C); |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 602 | return decl; |
| 603 | } |
| 604 | |
| 605 | //===----------------------------------------------------------------------===// |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 606 | // LinkageSpec Serialization. |
| 607 | //===----------------------------------------------------------------------===// |
| 608 | |
| 609 | void LinkageSpecDecl::EmitInRec(Serializer& S) const { |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 610 | S.EmitInt(getLanguage()); |
Douglas Gregor | f44515a | 2008-12-16 22:23:02 +0000 | [diff] [blame] | 611 | S.EmitBool(HadBraces); |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 612 | } |
| 613 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 614 | void LinkageSpecDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 615 | Language = static_cast<LanguageIDs>(D.ReadInt()); |
Douglas Gregor | f44515a | 2008-12-16 22:23:02 +0000 | [diff] [blame] | 616 | HadBraces = D.ReadBool(); |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 617 | } |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 618 | |
| 619 | //===----------------------------------------------------------------------===// |
| 620 | // FileScopeAsm Serialization. |
| 621 | //===----------------------------------------------------------------------===// |
| 622 | |
| 623 | void FileScopeAsmDecl::EmitImpl(llvm::Serializer& S) const |
| 624 | { |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 625 | S.EmitOwnedPtr(AsmString); |
| 626 | } |
| 627 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 628 | FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Steve Naroff | 3e97049 | 2009-01-27 21:25:57 +0000 | [diff] [blame^] | 629 | FileScopeAsmDecl* decl = new (C) FileScopeAsmDecl(0, SourceLocation(), 0); |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 630 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 631 | decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>(C)); |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 632 | // D.ReadOwnedPtr(D.ReadOwnedPtr<StringLiteral>())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString); |
| 633 | |
| 634 | return decl; |
| 635 | } |