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