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" |
| 16 | #include "clang/AST/Expr.h" |
| 17 | #include "llvm/Bitcode/Serialize.h" |
| 18 | #include "llvm/Bitcode/Deserialize.h" |
| 19 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 20 | using llvm::Serializer; |
| 21 | using llvm::Deserializer; |
| 22 | using llvm::SerializedPtrID; |
| 23 | |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 24 | using namespace clang; |
| 25 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 26 | //===----------------------------------------------------------------------===// |
| 27 | // Decl Serialization: Dispatch code to handle specialized decl types. |
| 28 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 8af8fe3 | 2007-11-05 21:38:00 +0000 | [diff] [blame] | 29 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 30 | void Decl::Emit(Serializer& S) const { |
| 31 | S.EmitInt(getKind()); |
| 32 | EmitImpl(S); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 33 | if (const DeclContext *DC = dyn_cast<const DeclContext>(this)) |
| 34 | DC->EmitOutRec(S); |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 37 | Decl* Decl::Create(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 38 | |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 39 | Decl *Dcl; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 40 | Kind k = static_cast<Kind>(D.ReadInt()); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 41 | |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 42 | switch (k) { |
| 43 | default: |
| 44 | assert (false && "Not implemented."); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 45 | |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 46 | case TranslationUnit: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 47 | Dcl = TranslationUnitDecl::CreateImpl(D, C); |
| 48 | break; |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 49 | |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 50 | case Namespace: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 51 | Dcl = NamespaceDecl::CreateImpl(D, C); |
| 52 | break; |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 53 | |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 54 | case Var: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 55 | Dcl = VarDecl::CreateImpl(D, C); |
| 56 | break; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 57 | |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 58 | case Enum: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 59 | Dcl = EnumDecl::CreateImpl(D, C); |
| 60 | break; |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 61 | |
| 62 | case EnumConstant: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 63 | Dcl = EnumConstantDecl::CreateImpl(D, C); |
| 64 | break; |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 65 | |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 66 | case Field: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 67 | Dcl = FieldDecl::CreateImpl(D, C); |
| 68 | break; |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 69 | |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 70 | case ParmVar: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 71 | Dcl = ParmVarDecl::CreateImpl(D, C); |
| 72 | break; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 73 | |
| 74 | case Function: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 75 | Dcl = FunctionDecl::CreateImpl(D, C); |
| 76 | break; |
| 77 | |
Argyrios Kyrtzidis | 35bc082 | 2008-10-15 00:42:39 +0000 | [diff] [blame^] | 78 | case Record: |
| 79 | Dcl = RecordDecl::CreateImpl(D, C); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 80 | break; |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 81 | |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 82 | case Typedef: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 83 | Dcl = TypedefDecl::CreateImpl(D, C); |
| 84 | break; |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 85 | |
| 86 | case FileScopeAsm: |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 87 | Dcl = FileScopeAsmDecl::CreateImpl(D, C); |
| 88 | break; |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 89 | } |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 90 | |
| 91 | if (DeclContext *DC = dyn_cast<DeclContext>(Dcl)) |
| 92 | DC->ReadOutRec(D, C); |
| 93 | |
| 94 | return Dcl; |
Ted Kremenek | 2f1f8cb | 2007-10-25 21:37:16 +0000 | [diff] [blame] | 95 | } |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 96 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 97 | //===----------------------------------------------------------------------===// |
| 98 | // Common serialization logic for subclasses of Decl. |
| 99 | //===----------------------------------------------------------------------===// |
| 100 | |
| 101 | void Decl::EmitInRec(Serializer& S) const { |
| 102 | S.Emit(getLocation()); // From Decl. |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 103 | } |
| 104 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 105 | void Decl::ReadInRec(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 106 | Loc = SourceLocation::ReadVal(D); // From Decl. |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 109 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 110 | // Common serialization logic for subclasses of DeclContext. |
| 111 | //===----------------------------------------------------------------------===// |
| 112 | |
| 113 | void DeclContext::EmitOutRec(Serializer& S) const { |
| 114 | S.EmitPtr(DeclChain); |
| 115 | } |
| 116 | |
| 117 | void DeclContext::ReadOutRec(Deserializer& D, ASTContext& C) { |
| 118 | D.ReadPtr(DeclChain); |
| 119 | } |
| 120 | |
| 121 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 122 | // Common serialization logic for subclasses of NamedDecl. |
| 123 | //===----------------------------------------------------------------------===// |
| 124 | |
| 125 | void NamedDecl::EmitInRec(Serializer& S) const { |
| 126 | Decl::EmitInRec(S); |
| 127 | S.EmitPtr(getIdentifier()); // From NamedDecl. |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 130 | void NamedDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
| 131 | Decl::ReadInRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 132 | D.ReadPtr(Identifier); // From NamedDecl. |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 135 | //===----------------------------------------------------------------------===// |
| 136 | // Common serialization logic for subclasses of ScopedDecl. |
| 137 | //===----------------------------------------------------------------------===// |
| 138 | |
| 139 | void ScopedDecl::EmitInRec(Serializer& S) const { |
| 140 | NamedDecl::EmitInRec(S); |
| 141 | S.EmitPtr(getNext()); // From ScopedDecl. |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 142 | S.EmitPtr(cast_or_null<Decl>(getDeclContext())); // From ScopedDecl. |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 145 | void ScopedDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
| 146 | NamedDecl::ReadInRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 147 | D.ReadPtr(Next); // From ScopedDecl. |
Ted Kremenek | 9f3e89a | 2008-05-12 17:29:34 +0000 | [diff] [blame] | 148 | |
Ted Kremenek | adbb619 | 2008-05-12 17:42:30 +0000 | [diff] [blame] | 149 | assert(DeclCtx == 0); // Allow back-patching. Observe that we register |
Ted Kremenek | 9f3e89a | 2008-05-12 17:29:34 +0000 | [diff] [blame] | 150 | D.ReadPtr(DeclCtx); // the variable of the *object* for back-patching. |
Ted Kremenek | 81edea8 | 2008-05-12 17:40:56 +0000 | [diff] [blame] | 151 | // Its actual value will get filled in later. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | //===------------------------------------------------------------===// |
| 155 | // NOTE: Not all subclasses of ScopedDecl will use the "OutRec" // |
| 156 | // methods. This is because owned pointers are usually "batched" // |
| 157 | // together for efficiency. // |
| 158 | //===------------------------------------------------------------===// |
| 159 | |
| 160 | void ScopedDecl::EmitOutRec(Serializer& S) const { |
| 161 | S.EmitOwnedPtr(getNextDeclarator()); // From ScopedDecl. |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 164 | void ScopedDecl::ReadOutRec(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 165 | NextDeclarator = |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 166 | cast_or_null<ScopedDecl>(D.ReadOwnedPtr<Decl>(C)); // From ScopedDecl. |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 169 | //===----------------------------------------------------------------------===// |
| 170 | // Common serialization logic for subclasses of ValueDecl. |
| 171 | //===----------------------------------------------------------------------===// |
| 172 | |
| 173 | void ValueDecl::EmitInRec(Serializer& S) const { |
| 174 | ScopedDecl::EmitInRec(S); |
| 175 | S.Emit(getType()); // From ValueDecl. |
| 176 | } |
| 177 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 178 | void ValueDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
| 179 | ScopedDecl::ReadInRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 180 | DeclType = QualType::ReadVal(D); // From ValueDecl. |
| 181 | } |
| 182 | |
| 183 | //===----------------------------------------------------------------------===// |
| 184 | // Common serialization logic for subclasses of VarDecl. |
| 185 | //===----------------------------------------------------------------------===// |
| 186 | |
| 187 | void VarDecl::EmitInRec(Serializer& S) const { |
| 188 | ValueDecl::EmitInRec(S); |
| 189 | S.EmitInt(getStorageClass()); // From VarDecl. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 192 | void VarDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
| 193 | ValueDecl::ReadInRec(D, C); |
Fariborz Jahanian | de7b4cd | 2007-12-13 00:54:18 +0000 | [diff] [blame] | 194 | SClass = static_cast<StorageClass>(D.ReadInt()); // From VarDecl. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | //===------------------------------------------------------------===// |
| 198 | // NOTE: VarDecl has its own "OutRec" methods that doesn't use // |
| 199 | // the one define in ScopedDecl. This is to batch emit the // |
| 200 | // owned pointers, which results in a smaller output. |
| 201 | //===------------------------------------------------------------===// |
| 202 | |
| 203 | void VarDecl::EmitOutRec(Serializer& S) const { |
| 204 | // Emit these last because they will create records of their own. |
| 205 | S.BatchEmitOwnedPtrs(getInit(), // From VarDecl. |
| 206 | getNextDeclarator()); // From ScopedDecl. |
| 207 | } |
| 208 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 209 | void VarDecl::ReadOutRec(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 210 | Decl* next_declarator; |
| 211 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 212 | D.BatchReadOwnedPtrs(Init, // From VarDecl. |
| 213 | next_declarator, // From ScopedDecl. |
| 214 | C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 215 | |
| 216 | setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator)); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 220 | void VarDecl::EmitImpl(Serializer& S) const { |
| 221 | VarDecl::EmitInRec(S); |
| 222 | VarDecl::EmitOutRec(S); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 223 | } |
| 224 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 225 | void VarDecl::ReadImpl(Deserializer& D, ASTContext& C) { |
| 226 | ReadInRec(D, C); |
| 227 | ReadOutRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 231 | // TranslationUnitDecl Serialization. |
| 232 | //===----------------------------------------------------------------------===// |
| 233 | |
| 234 | void TranslationUnitDecl::EmitImpl(llvm::Serializer& S) const |
| 235 | { |
| 236 | Decl::EmitInRec(S); |
| 237 | } |
| 238 | |
| 239 | TranslationUnitDecl* TranslationUnitDecl::CreateImpl(Deserializer& D, |
| 240 | ASTContext& C) { |
| 241 | void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>(); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 242 | TranslationUnitDecl* decl = new (Mem) TranslationUnitDecl(); |
Argyrios Kyrtzidis | ef17782 | 2008-04-17 14:40:12 +0000 | [diff] [blame] | 243 | |
| 244 | decl->Decl::ReadInRec(D, C); |
| 245 | |
| 246 | return decl; |
| 247 | } |
| 248 | |
| 249 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 250 | // NamespaceDecl Serialization. |
| 251 | //===----------------------------------------------------------------------===// |
| 252 | |
| 253 | void NamespaceDecl::EmitImpl(llvm::Serializer& S) const |
| 254 | { |
| 255 | ScopedDecl::EmitInRec(S); |
| 256 | S.Emit(getLBracLoc()); |
| 257 | S.Emit(getRBracLoc()); |
| 258 | ScopedDecl::EmitOutRec(S); |
| 259 | } |
| 260 | |
| 261 | NamespaceDecl* NamespaceDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
| 262 | void *Mem = C.getAllocator().Allocate<NamespaceDecl>(); |
| 263 | NamespaceDecl* decl = new (Mem) NamespaceDecl(0, SourceLocation(), 0); |
| 264 | |
| 265 | decl->ScopedDecl::ReadInRec(D, C); |
| 266 | decl->LBracLoc = SourceLocation::ReadVal(D); |
| 267 | decl->RBracLoc = SourceLocation::ReadVal(D); |
| 268 | decl->ScopedDecl::ReadOutRec(D, C); |
| 269 | |
| 270 | return decl; |
| 271 | } |
| 272 | |
| 273 | //===----------------------------------------------------------------------===// |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 274 | // VarDecl Serialization. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 275 | //===----------------------------------------------------------------------===// |
| 276 | |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 277 | VarDecl* VarDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
| 278 | void *Mem = C.getAllocator().Allocate<VarDecl>(); |
| 279 | VarDecl* decl = |
| 280 | new (Mem) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None, NULL); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 281 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 282 | decl->VarDecl::ReadImpl(D, C); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 283 | return decl; |
| 284 | } |
| 285 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 286 | //===----------------------------------------------------------------------===// |
Steve Naroff | 248a753 | 2008-04-15 22:42:06 +0000 | [diff] [blame] | 287 | // ParmVarDecl Serialization. |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 288 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 289 | |
Ted Kremenek | 137bd91 | 2007-12-13 06:28:13 +0000 | [diff] [blame] | 290 | void ParmVarDecl::EmitImpl(llvm::Serializer& S) const { |
| 291 | VarDecl::EmitImpl(S); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 292 | S.EmitInt(getObjCDeclQualifier()); // From ParmVarDecl. |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 293 | S.EmitOwnedPtr(getDefaultArg()); // From ParmVarDecl. |
Ted Kremenek | 137bd91 | 2007-12-13 06:28:13 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 296 | ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 297 | void *Mem = C.getAllocator().Allocate<ParmVarDecl>(); |
| 298 | ParmVarDecl* decl = new (Mem) |
| 299 | ParmVarDecl(0, SourceLocation(), NULL, QualType(), None, NULL, NULL); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 300 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 301 | decl->VarDecl::ReadImpl(D, C); |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 302 | decl->objcDeclQualifier = static_cast<ObjCDeclQualifier>(D.ReadInt()); |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 303 | decl->DefaultArg = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 304 | return decl; |
| 305 | } |
| 306 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 307 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 308 | // EnumDecl Serialization. |
| 309 | //===----------------------------------------------------------------------===// |
| 310 | |
| 311 | void EnumDecl::EmitImpl(Serializer& S) const { |
| 312 | ScopedDecl::EmitInRec(S); |
| 313 | S.EmitBool(isDefinition()); |
| 314 | S.Emit(IntegerType); |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 315 | S.BatchEmitOwnedPtrs(getEnumConstantList(),getNextDeclarator()); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 316 | } |
| 317 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 318 | EnumDecl* EnumDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 319 | void *Mem = C.getAllocator().Allocate<EnumDecl>(); |
| 320 | EnumDecl* decl = new (Mem) EnumDecl(0, SourceLocation(), NULL, NULL); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 321 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 322 | decl->ScopedDecl::ReadInRec(D, C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 323 | decl->setDefinition(D.ReadBool()); |
| 324 | decl->IntegerType = QualType::ReadVal(D); |
| 325 | |
| 326 | Decl* next_declarator; |
| 327 | Decl* Elist; |
| 328 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 329 | D.BatchReadOwnedPtrs(Elist, next_declarator, C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 330 | |
Argyrios Kyrtzidis | 7643536 | 2008-06-10 01:32:09 +0000 | [diff] [blame] | 331 | decl->setDeclChain(cast_or_null<EnumConstantDecl>(Elist)); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 332 | decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator)); |
| 333 | |
| 334 | return decl; |
| 335 | } |
| 336 | |
| 337 | //===----------------------------------------------------------------------===// |
| 338 | // EnumConstantDecl Serialization. |
| 339 | //===----------------------------------------------------------------------===// |
| 340 | |
| 341 | void EnumConstantDecl::EmitImpl(Serializer& S) const { |
| 342 | S.Emit(Val); |
| 343 | ValueDecl::EmitInRec(S); |
| 344 | S.BatchEmitOwnedPtrs(getNextDeclarator(),Init); |
| 345 | } |
| 346 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 347 | EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 049b168 | 2007-11-14 23:38:09 +0000 | [diff] [blame] | 348 | llvm::APSInt val(1); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 349 | D.Read(val); |
| 350 | |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 351 | void *Mem = C.getAllocator().Allocate<EnumConstantDecl>(); |
| 352 | EnumConstantDecl* decl = new (Mem) |
| 353 | EnumConstantDecl(0, SourceLocation(), NULL, QualType(), NULL, val, NULL); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 354 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 355 | decl->ValueDecl::ReadInRec(D, C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 356 | |
| 357 | Decl* next_declarator; |
| 358 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 359 | D.BatchReadOwnedPtrs(next_declarator, decl->Init, C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 360 | |
Ted Kremenek | 049b168 | 2007-11-14 23:38:09 +0000 | [diff] [blame] | 361 | decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator)); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 362 | |
| 363 | return decl; |
| 364 | } |
| 365 | |
| 366 | //===----------------------------------------------------------------------===// |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 367 | // FieldDecl Serialization. |
| 368 | //===----------------------------------------------------------------------===// |
| 369 | |
| 370 | void FieldDecl::EmitImpl(Serializer& S) const { |
| 371 | S.Emit(getType()); |
| 372 | NamedDecl::EmitInRec(S); |
| 373 | S.EmitOwnedPtr(BitWidth); |
| 374 | } |
| 375 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 376 | FieldDecl* FieldDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 377 | void *Mem = C.getAllocator().Allocate<FieldDecl>(); |
| 378 | FieldDecl* decl = new (Mem) FieldDecl(SourceLocation(), NULL, QualType(), 0); |
Ted Kremenek | 21d50e1 | 2007-11-14 22:51:02 +0000 | [diff] [blame] | 379 | decl->DeclType.ReadBackpatch(D); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 380 | decl->ReadInRec(D, C); |
| 381 | decl->BitWidth = D.ReadOwnedPtr<Expr>(C); |
Ted Kremenek | f9d56c8 | 2007-11-14 17:47:01 +0000 | [diff] [blame] | 382 | return decl; |
| 383 | } |
| 384 | |
| 385 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 386 | // FunctionDecl Serialization. |
| 387 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 388 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 389 | void FunctionDecl::EmitImpl(Serializer& S) const { |
| 390 | S.EmitInt(SClass); // From FunctionDecl. |
| 391 | S.EmitBool(IsInline); // From FunctionDecl. |
| 392 | ValueDecl::EmitInRec(S); |
Ted Kremenek | 3bbc198 | 2008-05-20 03:33:58 +0000 | [diff] [blame] | 393 | S.EmitPtr(PreviousDeclaration); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 394 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 395 | // NOTE: We do not need to serialize out the number of parameters, because |
| 396 | // that is encoded in the type (accessed via getNumParams()). |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 397 | |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 398 | if (ParamInfo != NULL) { |
| 399 | S.EmitBool(true); |
| 400 | S.BatchEmitOwnedPtrs(getNumParams(),&ParamInfo[0], Body, |
| 401 | getNextDeclarator()); |
| 402 | } |
| 403 | else { |
| 404 | S.EmitBool(false); |
| 405 | S.BatchEmitOwnedPtrs(Body,getNextDeclarator()); |
| 406 | } |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 409 | FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 410 | StorageClass SClass = static_cast<StorageClass>(D.ReadInt()); |
| 411 | bool IsInline = D.ReadBool(); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 412 | |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 413 | void *Mem = C.getAllocator().Allocate<FunctionDecl>(); |
| 414 | FunctionDecl* decl = new (Mem) |
Argyrios Kyrtzidis | d3bb44f | 2008-06-09 21:05:31 +0000 | [diff] [blame] | 415 | FunctionDecl(Function, 0, SourceLocation(), NULL, |
| 416 | QualType(), SClass, IsInline, 0); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 417 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 418 | decl->ValueDecl::ReadInRec(D, C); |
Ted Kremenek | 3bbc198 | 2008-05-20 03:33:58 +0000 | [diff] [blame] | 419 | D.ReadPtr(decl->PreviousDeclaration); |
Ted Kremenek | da25685 | 2007-11-16 18:11:10 +0000 | [diff] [blame] | 420 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 421 | Decl* next_declarator; |
| 422 | |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 423 | bool hasParamDecls = D.ReadBool(); |
Ted Kremenek | da25685 | 2007-11-16 18:11:10 +0000 | [diff] [blame] | 424 | |
| 425 | decl->ParamInfo = hasParamDecls |
| 426 | ? new ParmVarDecl*[decl->getNumParams()] |
| 427 | : NULL; |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 428 | |
| 429 | if (hasParamDecls) |
| 430 | D.BatchReadOwnedPtrs(decl->getNumParams(), |
| 431 | reinterpret_cast<Decl**>(&decl->ParamInfo[0]), |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 432 | decl->Body, next_declarator, C); |
Ted Kremenek | d437f23 | 2007-11-13 22:51:08 +0000 | [diff] [blame] | 433 | else |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 434 | D.BatchReadOwnedPtrs(decl->Body, next_declarator, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 435 | |
| 436 | decl->setNextDeclarator(cast_or_null<ScopedDecl>(next_declarator)); |
Ted Kremenek | 0497331 | 2007-11-02 18:05:11 +0000 | [diff] [blame] | 437 | |
| 438 | return decl; |
| 439 | } |
Ted Kremenek | f7bf411 | 2007-11-05 21:49:34 +0000 | [diff] [blame] | 440 | |
Steve Naroff | 56ee689 | 2008-10-08 17:01:13 +0000 | [diff] [blame] | 441 | void BlockDecl::EmitImpl(Serializer& S) const { |
| 442 | // FIXME: what about arguments? |
| 443 | S.Emit(getCaretLocation()); |
| 444 | S.EmitOwnedPtr(Body); |
| 445 | } |
| 446 | |
| 447 | BlockDecl* BlockDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
| 448 | QualType Q = QualType::ReadVal(D); |
| 449 | SourceLocation L = SourceLocation::ReadVal(D); |
| 450 | /*CompoundStmt* BodyStmt = cast<CompoundStmt>(*/D.ReadOwnedPtr<Stmt>(C)/*)*/; |
| 451 | assert(0 && "Cannot deserialize BlockBlockExpr yet"); |
| 452 | // FIXME: need to handle parameters. |
| 453 | //return new BlockBlockExpr(L, Q, BodyStmt); |
| 454 | return 0; |
| 455 | } |
| 456 | |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 457 | //===----------------------------------------------------------------------===// |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 458 | // RecordDecl Serialization. |
| 459 | //===----------------------------------------------------------------------===// |
| 460 | |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 461 | void RecordDecl::EmitImpl(Serializer& S) const { |
Argyrios Kyrtzidis | 35bc082 | 2008-10-15 00:42:39 +0000 | [diff] [blame^] | 462 | S.EmitInt(getTagKind()); |
| 463 | |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 464 | ScopedDecl::EmitInRec(S); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 465 | S.EmitBool(isDefinition()); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 466 | S.EmitBool(hasFlexibleArrayMember()); |
| 467 | S.EmitSInt(getNumMembers()); |
| 468 | if (getNumMembers() > 0) { |
| 469 | assert (Members); |
Ted Kremenek | 6812a73 | 2008-09-02 20:42:52 +0000 | [diff] [blame] | 470 | S.BatchEmitOwnedPtrs((unsigned) getNumMembers(), (Decl**) &Members[0]); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 471 | } |
| 472 | else |
| 473 | ScopedDecl::EmitOutRec(S); |
| 474 | } |
| 475 | |
Argyrios Kyrtzidis | 35bc082 | 2008-10-15 00:42:39 +0000 | [diff] [blame^] | 476 | RecordDecl* RecordDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
| 477 | TagKind TK = TagKind(D.ReadInt()); |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 478 | |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 479 | void *Mem = C.getAllocator().Allocate<RecordDecl>(); |
Argyrios Kyrtzidis | 35bc082 | 2008-10-15 00:42:39 +0000 | [diff] [blame^] | 480 | RecordDecl* decl = new (Mem) RecordDecl(Record, TK, 0, SourceLocation(), NULL); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 481 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 482 | decl->ScopedDecl::ReadInRec(D, C); |
Ted Kremenek | 583e008 | 2007-11-14 18:12:19 +0000 | [diff] [blame] | 483 | decl->setDefinition(D.ReadBool()); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 484 | decl->setHasFlexibleArrayMember(D.ReadBool()); |
| 485 | decl->NumMembers = D.ReadSInt(); |
| 486 | |
| 487 | if (decl->getNumMembers() > 0) { |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 488 | decl->Members = new FieldDecl*[(unsigned) decl->getNumMembers()]; |
| 489 | |
| 490 | D.BatchReadOwnedPtrs((unsigned) decl->getNumMembers(), |
Ted Kremenek | 6812a73 | 2008-09-02 20:42:52 +0000 | [diff] [blame] | 491 | (Decl**) &decl->Members[0], C); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 492 | } |
| 493 | else |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 494 | decl->ScopedDecl::ReadOutRec(D, C); |
Ted Kremenek | aad48b6 | 2007-11-14 08:06:37 +0000 | [diff] [blame] | 495 | |
| 496 | return decl; |
| 497 | } |
| 498 | |
| 499 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 500 | // TypedefDecl Serialization. |
| 501 | //===----------------------------------------------------------------------===// |
| 502 | |
| 503 | void TypedefDecl::EmitImpl(Serializer& S) const { |
Ted Kremenek | 2ebc89f | 2007-11-06 19:51:47 +0000 | [diff] [blame] | 504 | S.Emit(UnderlyingType); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 505 | ScopedDecl::EmitInRec(S); |
| 506 | ScopedDecl::EmitOutRec(S); |
Ted Kremenek | f7bf411 | 2007-11-05 21:49:34 +0000 | [diff] [blame] | 507 | } |
| 508 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 509 | TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 510 | QualType T = QualType::ReadVal(D); |
| 511 | |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 512 | void *Mem = C.getAllocator().Allocate<TypedefDecl>(); |
| 513 | TypedefDecl* decl = new (Mem) TypedefDecl(0, SourceLocation(), NULL, T, NULL); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 514 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 515 | decl->ScopedDecl::ReadInRec(D, C); |
| 516 | decl->ScopedDecl::ReadOutRec(D, C); |
Ted Kremenek | 928fd7f | 2007-11-13 00:15:39 +0000 | [diff] [blame] | 517 | |
Ted Kremenek | f7bf411 | 2007-11-05 21:49:34 +0000 | [diff] [blame] | 518 | return decl; |
| 519 | } |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 520 | |
| 521 | //===----------------------------------------------------------------------===// |
| 522 | // LinkageSpec Serialization. |
| 523 | //===----------------------------------------------------------------------===// |
| 524 | |
| 525 | void LinkageSpecDecl::EmitInRec(Serializer& S) const { |
| 526 | Decl::EmitInRec(S); |
| 527 | S.EmitInt(getLanguage()); |
| 528 | S.EmitPtr(D); |
| 529 | } |
| 530 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 531 | void LinkageSpecDecl::ReadInRec(Deserializer& D, ASTContext& C) { |
| 532 | Decl::ReadInRec(D, C); |
Chris Lattner | c6fdc34 | 2008-01-12 07:05:38 +0000 | [diff] [blame] | 533 | Language = static_cast<LanguageIDs>(D.ReadInt()); |
| 534 | D.ReadPtr(this->D); |
| 535 | } |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 536 | |
| 537 | //===----------------------------------------------------------------------===// |
| 538 | // FileScopeAsm Serialization. |
| 539 | //===----------------------------------------------------------------------===// |
| 540 | |
| 541 | void FileScopeAsmDecl::EmitImpl(llvm::Serializer& S) const |
| 542 | { |
| 543 | Decl::EmitInRec(S); |
| 544 | S.EmitOwnedPtr(AsmString); |
| 545 | } |
| 546 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 547 | FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D, ASTContext& C) { |
Sam Bishop | f3c63ae | 2008-04-11 14:49:10 +0000 | [diff] [blame] | 548 | void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>(); |
| 549 | FileScopeAsmDecl* decl = new (Mem) FileScopeAsmDecl(SourceLocation(), 0); |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 550 | |
Sam Bishop | e2563ca | 2008-04-07 21:55:54 +0000 | [diff] [blame] | 551 | decl->Decl::ReadInRec(D, C); |
| 552 | decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>(C)); |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 553 | // D.ReadOwnedPtr(D.ReadOwnedPtr<StringLiteral>())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString); |
| 554 | |
| 555 | return decl; |
| 556 | } |