Sebastian Redl | 4ee2ad0 | 2010-08-18 23:56:31 +0000 | [diff] [blame] | 1 | //===--- ASTWriterDecl.cpp - Declaration Serialization --------------------===// |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements serialization for Declarations. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Sebastian Redl | 7faa2ec | 2010-08-18 23:56:37 +0000 | [diff] [blame] | 14 | #include "clang/Serialization/ASTWriter.h" |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 15 | #include "ASTCommon.h" |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclVisitor.h" |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 17 | #include "clang/AST/DeclCXX.h" |
| 18 | #include "clang/AST/DeclTemplate.h" |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 19 | #include "clang/AST/Expr.h" |
Argyrios Kyrtzidis | 0ad6dc3 | 2010-10-20 16:22:56 +0000 | [diff] [blame] | 20 | #include "clang/AST/DeclContextInternals.h" |
Daniel Dunbar | 3367198 | 2009-12-03 09:13:36 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/Twine.h" |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 22 | #include "llvm/Bitcode/BitstreamWriter.h" |
Daniel Dunbar | 3367198 | 2009-12-03 09:13:36 +0000 | [diff] [blame] | 23 | #include "llvm/Support/ErrorHandling.h" |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 24 | using namespace clang; |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 25 | using namespace serialization; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 26 | |
| 27 | //===----------------------------------------------------------------------===// |
| 28 | // Declaration serialization |
| 29 | //===----------------------------------------------------------------------===// |
| 30 | |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 31 | namespace clang { |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 32 | class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 33 | |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 34 | ASTWriter &Writer; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 35 | ASTContext &Context; |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 36 | typedef ASTWriter::RecordData RecordData; |
| 37 | RecordData &Record; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 38 | |
| 39 | public: |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 40 | serialization::DeclCode Code; |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 41 | unsigned AbbrevToUse; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 42 | |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 43 | ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, RecordData &Record) |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 44 | : Writer(Writer), Context(Context), Record(Record) { |
| 45 | } |
Argyrios Kyrtzidis | c01dc6f | 2010-10-24 17:26:27 +0000 | [diff] [blame] | 46 | |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 47 | void Visit(Decl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 48 | |
| 49 | void VisitDecl(Decl *D); |
| 50 | void VisitTranslationUnitDecl(TranslationUnitDecl *D); |
| 51 | void VisitNamedDecl(NamedDecl *D); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 52 | void VisitLabelDecl(LabelDecl *LD); |
Douglas Gregor | 0cef483 | 2010-02-21 18:22:14 +0000 | [diff] [blame] | 53 | void VisitNamespaceDecl(NamespaceDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 54 | void VisitUsingDirectiveDecl(UsingDirectiveDecl *D); |
| 55 | void VisitNamespaceAliasDecl(NamespaceAliasDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 56 | void VisitTypeDecl(TypeDecl *D); |
| 57 | void VisitTypedefDecl(TypedefDecl *D); |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 58 | void VisitTypeAliasDecl(TypeAliasDecl *D); |
Argyrios Kyrtzidis | 8f4eae9 | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 59 | void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 60 | void VisitTagDecl(TagDecl *D); |
| 61 | void VisitEnumDecl(EnumDecl *D); |
| 62 | void VisitRecordDecl(RecordDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 63 | void VisitCXXRecordDecl(CXXRecordDecl *D); |
| 64 | void VisitClassTemplateSpecializationDecl( |
| 65 | ClassTemplateSpecializationDecl *D); |
| 66 | void VisitClassTemplatePartialSpecializationDecl( |
| 67 | ClassTemplatePartialSpecializationDecl *D); |
| 68 | void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 69 | void VisitValueDecl(ValueDecl *D); |
| 70 | void VisitEnumConstantDecl(EnumConstantDecl *D); |
Argyrios Kyrtzidis | 8f4eae9 | 2010-06-30 08:49:30 +0000 | [diff] [blame] | 71 | void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 72 | void VisitDeclaratorDecl(DeclaratorDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 73 | void VisitFunctionDecl(FunctionDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 74 | void VisitCXXMethodDecl(CXXMethodDecl *D); |
| 75 | void VisitCXXConstructorDecl(CXXConstructorDecl *D); |
| 76 | void VisitCXXDestructorDecl(CXXDestructorDecl *D); |
| 77 | void VisitCXXConversionDecl(CXXConversionDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 78 | void VisitFieldDecl(FieldDecl *D); |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 79 | void VisitIndirectFieldDecl(IndirectFieldDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 80 | void VisitVarDecl(VarDecl *D); |
| 81 | void VisitImplicitParamDecl(ImplicitParamDecl *D); |
| 82 | void VisitParmVarDecl(ParmVarDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 83 | void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); |
| 84 | void VisitTemplateDecl(TemplateDecl *D); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 85 | void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 86 | void VisitClassTemplateDecl(ClassTemplateDecl *D); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 87 | void VisitFunctionTemplateDecl(FunctionTemplateDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 88 | void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 89 | void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D); |
Argyrios Kyrtzidis | b01a552 | 2010-06-20 14:40:59 +0000 | [diff] [blame] | 90 | void VisitUsingDecl(UsingDecl *D); |
| 91 | void VisitUsingShadowDecl(UsingShadowDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 92 | void VisitLinkageSpecDecl(LinkageSpecDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 93 | void VisitFileScopeAsmDecl(FileScopeAsmDecl *D); |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 94 | void VisitAccessSpecDecl(AccessSpecDecl *D); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 95 | void VisitFriendDecl(FriendDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 96 | void VisitFriendTemplateDecl(FriendTemplateDecl *D); |
| 97 | void VisitStaticAssertDecl(StaticAssertDecl *D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 98 | void VisitBlockDecl(BlockDecl *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 99 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 100 | void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset, |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 101 | uint64_t VisibleOffset); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 102 | template <typename T> void VisitRedeclarable(Redeclarable<T> *D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 103 | |
| 104 | |
Sean Hunt | 9a55591 | 2010-05-30 07:21:58 +0000 | [diff] [blame] | 105 | // FIXME: Put in the same order is DeclNodes.td? |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 106 | void VisitObjCMethodDecl(ObjCMethodDecl *D); |
| 107 | void VisitObjCContainerDecl(ObjCContainerDecl *D); |
| 108 | void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D); |
| 109 | void VisitObjCIvarDecl(ObjCIvarDecl *D); |
| 110 | void VisitObjCProtocolDecl(ObjCProtocolDecl *D); |
| 111 | void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D); |
| 112 | void VisitObjCClassDecl(ObjCClassDecl *D); |
| 113 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D); |
| 114 | void VisitObjCCategoryDecl(ObjCCategoryDecl *D); |
| 115 | void VisitObjCImplDecl(ObjCImplDecl *D); |
| 116 | void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D); |
| 117 | void VisitObjCImplementationDecl(ObjCImplementationDecl *D); |
| 118 | void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D); |
| 119 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
| 120 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
| 121 | }; |
| 122 | } |
| 123 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 124 | void ASTDeclWriter::Visit(Decl *D) { |
| 125 | DeclVisitor<ASTDeclWriter>::Visit(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 126 | |
| 127 | // Handle FunctionDecl's body here and write it after all other Stmts/Exprs |
| 128 | // have been written. We want it last because we will not read it back when |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 129 | // retrieving it from the AST, we'll just lazily set the offset. |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 130 | if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { |
Sean Hunt | 10620eb | 2011-05-06 20:44:56 +0000 | [diff] [blame] | 131 | Record.push_back(FD->doesThisDeclarationHaveABody()); |
| 132 | if (FD->doesThisDeclarationHaveABody()) |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 133 | Writer.AddStmt(FD->getBody()); |
| 134 | } |
| 135 | } |
| 136 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 137 | void ASTDeclWriter::VisitDecl(Decl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 138 | Writer.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()), Record); |
| 139 | Writer.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()), Record); |
| 140 | Writer.AddSourceLocation(D->getLocation(), Record); |
| 141 | Record.push_back(D->isInvalidDecl()); |
| 142 | Record.push_back(D->hasAttrs()); |
Argyrios Kyrtzidis | 4eb9fc0 | 2010-10-18 19:20:11 +0000 | [diff] [blame] | 143 | if (D->hasAttrs()) |
| 144 | Writer.WriteAttributes(D->getAttrs(), Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 145 | Record.push_back(D->isImplicit()); |
Douglas Gregor | c070cc6 | 2010-06-17 23:14:26 +0000 | [diff] [blame] | 146 | Record.push_back(D->isUsed(false)); |
Argyrios Kyrtzidis | 6b6b42a | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 147 | Record.push_back(D->isReferenced()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 148 | Record.push_back(D->getAccess()); |
Douglas Gregor | 7d1d49d | 2009-10-16 20:01:17 +0000 | [diff] [blame] | 149 | Record.push_back(D->getPCHLevel()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 152 | void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 153 | VisitDecl(D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 154 | Writer.AddDeclRef(D->getAnonymousNamespace(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 155 | Code = serialization::DECL_TRANSLATION_UNIT; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 156 | } |
| 157 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 158 | void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 159 | VisitDecl(D); |
| 160 | Writer.AddDeclarationName(D->getDeclName(), Record); |
| 161 | } |
| 162 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 163 | void ASTDeclWriter::VisitTypeDecl(TypeDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 164 | VisitNamedDecl(D); |
Abramo Bagnara | 344577e | 2011-03-06 15:48:19 +0000 | [diff] [blame] | 165 | Writer.AddSourceLocation(D->getLocStart(), Record); |
Argyrios Kyrtzidis | d8a0c6f | 2010-07-02 11:55:01 +0000 | [diff] [blame] | 166 | Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 169 | void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 170 | VisitTypeDecl(D); |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 171 | Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 172 | Code = serialization::DECL_TYPEDEF; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 175 | void ASTDeclWriter::VisitTypeAliasDecl(TypeAliasDecl *D) { |
| 176 | VisitTypeDecl(D); |
| 177 | Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record); |
| 178 | Code = serialization::DECL_TYPEALIAS; |
| 179 | } |
| 180 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 181 | void ASTDeclWriter::VisitTagDecl(TagDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 182 | VisitTypeDecl(D); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 183 | VisitRedeclarable(D); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 184 | Record.push_back(D->getIdentifierNamespace()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 185 | Record.push_back((unsigned)D->getTagKind()); // FIXME: stable encoding |
| 186 | Record.push_back(D->isDefinition()); |
Douglas Gregor | b37b648 | 2010-02-12 17:40:34 +0000 | [diff] [blame] | 187 | Record.push_back(D->isEmbeddedInDeclarator()); |
Argyrios Kyrtzidis | ad93a74 | 2009-07-14 03:18:02 +0000 | [diff] [blame] | 188 | Writer.AddSourceLocation(D->getRBraceLoc(), Record); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 189 | Record.push_back(D->hasExtInfo()); |
| 190 | if (D->hasExtInfo()) |
| 191 | Writer.AddQualifierInfo(*D->getExtInfo(), Record); |
| 192 | else |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 193 | Writer.AddDeclRef(D->getTypedefNameForAnonDecl(), Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 196 | void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 197 | VisitTagDecl(D); |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 198 | Writer.AddTypeSourceInfo(D->getIntegerTypeSourceInfo(), Record); |
| 199 | if (!D->getIntegerTypeSourceInfo()) |
| 200 | Writer.AddTypeRef(D->getIntegerType(), Record); |
John McCall | 842aef8 | 2009-12-09 09:09:27 +0000 | [diff] [blame] | 201 | Writer.AddTypeRef(D->getPromotionType(), Record); |
John McCall | 1b5a618 | 2010-05-06 08:49:23 +0000 | [diff] [blame] | 202 | Record.push_back(D->getNumPositiveBits()); |
| 203 | Record.push_back(D->getNumNegativeBits()); |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 204 | Record.push_back(D->isScoped()); |
Abramo Bagnara | a88cefd | 2010-12-03 18:54:17 +0000 | [diff] [blame] | 205 | Record.push_back(D->isScopedUsingClassTag()); |
Douglas Gregor | 1274ccd | 2010-10-08 23:50:27 +0000 | [diff] [blame] | 206 | Record.push_back(D->isFixed()); |
Argyrios Kyrtzidis | 7422827 | 2010-07-06 15:36:48 +0000 | [diff] [blame] | 207 | Writer.AddDeclRef(D->getInstantiatedFromMemberEnum(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 208 | Code = serialization::DECL_ENUM; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 211 | void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 212 | VisitTagDecl(D); |
| 213 | Record.push_back(D->hasFlexibleArrayMember()); |
| 214 | Record.push_back(D->isAnonymousStructOrUnion()); |
Fariborz Jahanian | 643b7df | 2009-07-08 16:37:44 +0000 | [diff] [blame] | 215 | Record.push_back(D->hasObjectMember()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 216 | Code = serialization::DECL_RECORD; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 219 | void ASTDeclWriter::VisitValueDecl(ValueDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 220 | VisitNamedDecl(D); |
| 221 | Writer.AddTypeRef(D->getType(), Record); |
| 222 | } |
| 223 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 224 | void ASTDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 225 | VisitValueDecl(D); |
| 226 | Record.push_back(D->getInitExpr()? 1 : 0); |
| 227 | if (D->getInitExpr()) |
| 228 | Writer.AddStmt(D->getInitExpr()); |
| 229 | Writer.AddAPSInt(D->getInitVal(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 230 | Code = serialization::DECL_ENUM_CONSTANT; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 231 | } |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 232 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 233 | void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 234 | VisitValueDecl(D); |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 235 | Writer.AddSourceLocation(D->getInnerLocStart(), Record); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 236 | Record.push_back(D->hasExtInfo()); |
| 237 | if (D->hasExtInfo()) |
| 238 | Writer.AddQualifierInfo(*D->getExtInfo(), Record); |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 239 | Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record); |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 240 | } |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 241 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 242 | void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 243 | VisitDeclaratorDecl(D); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 244 | VisitRedeclarable(D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 245 | |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 246 | Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record); |
Argyrios Kyrtzidis | c8f9af2 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 247 | Record.push_back(D->getIdentifierNamespace()); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 248 | Record.push_back(D->getTemplatedKind()); |
| 249 | switch (D->getTemplatedKind()) { |
Argyrios Kyrtzidis | dc767e3 | 2010-06-28 09:31:34 +0000 | [diff] [blame] | 250 | default: assert(false && "Unhandled TemplatedKind!"); |
| 251 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 252 | case FunctionDecl::TK_NonTemplate: |
| 253 | break; |
| 254 | case FunctionDecl::TK_FunctionTemplate: |
| 255 | Writer.AddDeclRef(D->getDescribedFunctionTemplate(), Record); |
| 256 | break; |
| 257 | case FunctionDecl::TK_MemberSpecialization: { |
| 258 | MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo(); |
| 259 | Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record); |
| 260 | Record.push_back(MemberInfo->getTemplateSpecializationKind()); |
| 261 | Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record); |
| 262 | break; |
| 263 | } |
| 264 | case FunctionDecl::TK_FunctionTemplateSpecialization: { |
| 265 | FunctionTemplateSpecializationInfo * |
| 266 | FTSInfo = D->getTemplateSpecializationInfo(); |
Argyrios Kyrtzidis | a626a3d | 2010-09-09 11:28:23 +0000 | [diff] [blame] | 267 | Writer.AddDeclRef(FTSInfo->getTemplate(), Record); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 268 | Record.push_back(FTSInfo->getTemplateSpecializationKind()); |
| 269 | |
| 270 | // Template arguments. |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 271 | Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 272 | |
| 273 | // Template args as written. |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 274 | Record.push_back(FTSInfo->TemplateArgumentsAsWritten != 0); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 275 | if (FTSInfo->TemplateArgumentsAsWritten) { |
| 276 | Record.push_back(FTSInfo->TemplateArgumentsAsWritten->size()); |
| 277 | for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->size(); i!=e; ++i) |
| 278 | Writer.AddTemplateArgumentLoc((*FTSInfo->TemplateArgumentsAsWritten)[i], |
| 279 | Record); |
| 280 | Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->getLAngleLoc(), |
| 281 | Record); |
| 282 | Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->getRAngleLoc(), |
| 283 | Record); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 284 | } |
Argyrios Kyrtzidis | 7b081c8 | 2010-07-05 10:37:55 +0000 | [diff] [blame] | 285 | |
| 286 | Writer.AddSourceLocation(FTSInfo->getPointOfInstantiation(), Record); |
Argyrios Kyrtzidis | 99a8ca0 | 2010-09-13 11:45:48 +0000 | [diff] [blame] | 287 | |
| 288 | if (D->isCanonicalDecl()) { |
| 289 | // Write the template that contains the specializations set. We will |
| 290 | // add a FunctionTemplateSpecializationInfo to it when reading. |
| 291 | Writer.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl(), Record); |
| 292 | } |
Argyrios Kyrtzidis | a56b049 | 2010-06-25 16:24:51 +0000 | [diff] [blame] | 293 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 294 | } |
| 295 | case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { |
| 296 | DependentFunctionTemplateSpecializationInfo * |
| 297 | DFTSInfo = D->getDependentSpecializationInfo(); |
| 298 | |
| 299 | // Templates. |
| 300 | Record.push_back(DFTSInfo->getNumTemplates()); |
| 301 | for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i) |
| 302 | Writer.AddDeclRef(DFTSInfo->getTemplate(i), Record); |
| 303 | |
| 304 | // Templates args. |
| 305 | Record.push_back(DFTSInfo->getNumTemplateArgs()); |
| 306 | for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i) |
| 307 | Writer.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i), Record); |
Argyrios Kyrtzidis | 7b081c8 | 2010-07-05 10:37:55 +0000 | [diff] [blame] | 308 | Writer.AddSourceLocation(DFTSInfo->getLAngleLoc(), Record); |
| 309 | Writer.AddSourceLocation(DFTSInfo->getRAngleLoc(), Record); |
Argyrios Kyrtzidis | a56b049 | 2010-06-25 16:24:51 +0000 | [diff] [blame] | 310 | break; |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 311 | } |
| 312 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 313 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 314 | // FunctionDecl's body is handled last at ASTWriterDecl::Visit, |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 315 | // after everything else is written. |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 316 | |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 317 | Record.push_back(D->getStorageClass()); // FIXME: stable encoding |
| 318 | Record.push_back(D->getStorageClassAsWritten()); |
Douglas Gregor | 8f15094 | 2010-12-09 16:59:22 +0000 | [diff] [blame] | 319 | Record.push_back(D->IsInline); |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 320 | Record.push_back(D->isInlineSpecified()); |
| 321 | Record.push_back(D->isVirtualAsWritten()); |
| 322 | Record.push_back(D->isPure()); |
| 323 | Record.push_back(D->hasInheritedPrototype()); |
| 324 | Record.push_back(D->hasWrittenPrototype()); |
Sean Hunt | 10620eb | 2011-05-06 20:44:56 +0000 | [diff] [blame] | 325 | Record.push_back(D->isDeletedAsWritten()); |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 326 | Record.push_back(D->isTrivial()); |
Sean Hunt | 2be7e90 | 2011-05-12 22:46:29 +0000 | [diff] [blame^] | 327 | Record.push_back(D->isDefaulted()); |
| 328 | Record.push_back(D->isExplicitlyDefaulted()); |
Argyrios Kyrtzidis | 5efb06f | 2010-07-02 11:55:40 +0000 | [diff] [blame] | 329 | Record.push_back(D->hasImplicitReturnZero()); |
| 330 | Writer.AddSourceLocation(D->getLocEnd(), Record); |
| 331 | |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 332 | Record.push_back(D->param_size()); |
| 333 | for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end(); |
| 334 | P != PEnd; ++P) |
| 335 | Writer.AddDeclRef(*P, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 336 | Code = serialization::DECL_FUNCTION; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 337 | } |
| 338 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 339 | void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 340 | VisitNamedDecl(D); |
| 341 | // FIXME: convert to LazyStmtPtr? |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 342 | // Unlike C/C++, method bodies will never be in header files. |
Argyrios Kyrtzidis | 2f92230 | 2010-08-09 10:54:37 +0000 | [diff] [blame] | 343 | bool HasBodyStuff = D->getBody() != 0 || |
| 344 | D->getSelfDecl() != 0 || D->getCmdDecl() != 0; |
| 345 | Record.push_back(HasBodyStuff); |
| 346 | if (HasBodyStuff) { |
Argyrios Kyrtzidis | 6fb0aee | 2009-06-30 02:35:26 +0000 | [diff] [blame] | 347 | Writer.AddStmt(D->getBody()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 348 | Writer.AddDeclRef(D->getSelfDecl(), Record); |
| 349 | Writer.AddDeclRef(D->getCmdDecl(), Record); |
| 350 | } |
| 351 | Record.push_back(D->isInstanceMethod()); |
| 352 | Record.push_back(D->isVariadic()); |
| 353 | Record.push_back(D->isSynthesized()); |
Fariborz Jahanian | 3fe1041 | 2010-07-22 18:24:20 +0000 | [diff] [blame] | 354 | Record.push_back(D->isDefined()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 355 | // FIXME: stable encoding for @required/@optional |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 356 | Record.push_back(D->getImplementationControl()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 357 | // FIXME: stable encoding for in/out/inout/bycopy/byref/oneway |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 358 | Record.push_back(D->getObjCDeclQualifier()); |
Fariborz Jahanian | 7732cc9 | 2010-04-08 21:29:11 +0000 | [diff] [blame] | 359 | Record.push_back(D->getNumSelectorArgs()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 360 | Writer.AddTypeRef(D->getResultType(), Record); |
Douglas Gregor | 4bc1cb6 | 2010-03-08 14:59:44 +0000 | [diff] [blame] | 361 | Writer.AddTypeSourceInfo(D->getResultTypeSourceInfo(), Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 362 | Writer.AddSourceLocation(D->getLocEnd(), Record); |
| 363 | Record.push_back(D->param_size()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 364 | for (ObjCMethodDecl::param_iterator P = D->param_begin(), |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 365 | PEnd = D->param_end(); P != PEnd; ++P) |
| 366 | Writer.AddDeclRef(*P, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 367 | Code = serialization::DECL_OBJC_METHOD; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 370 | void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 371 | VisitNamedDecl(D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 372 | Writer.AddSourceRange(D->getAtEndRange(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 373 | // Abstract class (no need to define a stable serialization::DECL code). |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 374 | } |
| 375 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 376 | void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 377 | VisitObjCContainerDecl(D); |
| 378 | Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record); |
| 379 | Writer.AddDeclRef(D->getSuperClass(), Record); |
Ted Kremenek | 53b9441 | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 380 | |
| 381 | // Write out the protocols that are directly referenced by the @interface. |
| 382 | Record.push_back(D->ReferencedProtocols.size()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 383 | for (ObjCInterfaceDecl::protocol_iterator P = D->protocol_begin(), |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 384 | PEnd = D->protocol_end(); |
| 385 | P != PEnd; ++P) |
| 386 | Writer.AddDeclRef(*P, Record); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 387 | for (ObjCInterfaceDecl::protocol_loc_iterator PL = D->protocol_loc_begin(), |
| 388 | PLEnd = D->protocol_loc_end(); |
| 389 | PL != PLEnd; ++PL) |
| 390 | Writer.AddSourceLocation(*PL, Record); |
Ted Kremenek | 53b9441 | 2010-09-01 01:21:15 +0000 | [diff] [blame] | 391 | |
| 392 | // Write out the protocols that are transitively referenced. |
| 393 | Record.push_back(D->AllReferencedProtocols.size()); |
| 394 | for (ObjCList<ObjCProtocolDecl>::iterator |
| 395 | P = D->AllReferencedProtocols.begin(), |
| 396 | PEnd = D->AllReferencedProtocols.end(); |
| 397 | P != PEnd; ++P) |
| 398 | Writer.AddDeclRef(*P, Record); |
| 399 | |
| 400 | // Write out the ivars. |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 401 | Record.push_back(D->ivar_size()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 402 | for (ObjCInterfaceDecl::ivar_iterator I = D->ivar_begin(), |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 403 | IEnd = D->ivar_end(); I != IEnd; ++I) |
| 404 | Writer.AddDeclRef(*I, Record); |
| 405 | Writer.AddDeclRef(D->getCategoryList(), Record); |
Douglas Gregor | deacbdc | 2010-08-11 12:19:30 +0000 | [diff] [blame] | 406 | Record.push_back(D->isForwardDecl()); |
| 407 | Record.push_back(D->isImplicitInterfaceDecl()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 408 | Writer.AddSourceLocation(D->getClassLoc(), Record); |
| 409 | Writer.AddSourceLocation(D->getSuperClassLoc(), Record); |
| 410 | Writer.AddSourceLocation(D->getLocEnd(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 411 | Code = serialization::DECL_OBJC_INTERFACE; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 412 | } |
| 413 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 414 | void ASTDeclWriter::VisitObjCIvarDecl(ObjCIvarDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 415 | VisitFieldDecl(D); |
| 416 | // FIXME: stable encoding for @public/@private/@protected/@package |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 417 | Record.push_back(D->getAccessControl()); |
Fariborz Jahanian | ac0021b | 2010-07-17 18:35:47 +0000 | [diff] [blame] | 418 | Record.push_back(D->getSynthesize()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 419 | Code = serialization::DECL_OBJC_IVAR; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 420 | } |
| 421 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 422 | void ASTDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 423 | VisitObjCContainerDecl(D); |
| 424 | Record.push_back(D->isForwardDecl()); |
| 425 | Writer.AddSourceLocation(D->getLocEnd(), Record); |
| 426 | Record.push_back(D->protocol_size()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 427 | for (ObjCProtocolDecl::protocol_iterator |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 428 | I = D->protocol_begin(), IEnd = D->protocol_end(); I != IEnd; ++I) |
| 429 | Writer.AddDeclRef(*I, Record); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 430 | for (ObjCProtocolDecl::protocol_loc_iterator PL = D->protocol_loc_begin(), |
| 431 | PLEnd = D->protocol_loc_end(); |
| 432 | PL != PLEnd; ++PL) |
| 433 | Writer.AddSourceLocation(*PL, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 434 | Code = serialization::DECL_OBJC_PROTOCOL; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 435 | } |
| 436 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 437 | void ASTDeclWriter::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 438 | VisitFieldDecl(D); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 439 | Code = serialization::DECL_OBJC_AT_DEFS_FIELD; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 440 | } |
| 441 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 442 | void ASTDeclWriter::VisitObjCClassDecl(ObjCClassDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 443 | VisitDecl(D); |
| 444 | Record.push_back(D->size()); |
| 445 | for (ObjCClassDecl::iterator I = D->begin(), IEnd = D->end(); I != IEnd; ++I) |
Ted Kremenek | 321c22f | 2009-11-18 00:28:11 +0000 | [diff] [blame] | 446 | Writer.AddDeclRef(I->getInterface(), Record); |
| 447 | for (ObjCClassDecl::iterator I = D->begin(), IEnd = D->end(); I != IEnd; ++I) |
| 448 | Writer.AddSourceLocation(I->getLocation(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 449 | Code = serialization::DECL_OBJC_CLASS; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 452 | void ASTDeclWriter::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 453 | VisitDecl(D); |
| 454 | Record.push_back(D->protocol_size()); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 455 | for (ObjCForwardProtocolDecl::protocol_iterator |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 456 | I = D->protocol_begin(), IEnd = D->protocol_end(); I != IEnd; ++I) |
| 457 | Writer.AddDeclRef(*I, Record); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 458 | for (ObjCForwardProtocolDecl::protocol_loc_iterator |
| 459 | PL = D->protocol_loc_begin(), PLEnd = D->protocol_loc_end(); |
| 460 | PL != PLEnd; ++PL) |
| 461 | Writer.AddSourceLocation(*PL, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 462 | Code = serialization::DECL_OBJC_FORWARD_PROTOCOL; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 465 | void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 466 | VisitObjCContainerDecl(D); |
| 467 | Writer.AddDeclRef(D->getClassInterface(), Record); |
| 468 | Record.push_back(D->protocol_size()); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 469 | for (ObjCCategoryDecl::protocol_iterator |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 470 | I = D->protocol_begin(), IEnd = D->protocol_end(); I != IEnd; ++I) |
| 471 | Writer.AddDeclRef(*I, Record); |
Douglas Gregor | 18df52b | 2010-01-16 15:02:53 +0000 | [diff] [blame] | 472 | for (ObjCCategoryDecl::protocol_loc_iterator |
| 473 | PL = D->protocol_loc_begin(), PLEnd = D->protocol_loc_end(); |
| 474 | PL != PLEnd; ++PL) |
| 475 | Writer.AddSourceLocation(*PL, Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 476 | Writer.AddDeclRef(D->getNextClassCategory(), Record); |
Fariborz Jahanian | 000835d | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 477 | Record.push_back(D->hasSynthBitfield()); |
Douglas Gregor | 3db211b | 2010-01-16 16:38:58 +0000 | [diff] [blame] | 478 | Writer.AddSourceLocation(D->getAtLoc(), Record); |
| 479 | Writer.AddSourceLocation(D->getCategoryNameLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 480 | Code = serialization::DECL_OBJC_CATEGORY; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 481 | } |
| 482 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 483 | void ASTDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 484 | VisitNamedDecl(D); |
| 485 | Writer.AddDeclRef(D->getClassInterface(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 486 | Code = serialization::DECL_OBJC_COMPATIBLE_ALIAS; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 489 | void ASTDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 490 | VisitNamedDecl(D); |
Fariborz Jahanian | d050240 | 2010-01-21 17:36:00 +0000 | [diff] [blame] | 491 | Writer.AddSourceLocation(D->getAtLoc(), Record); |
John McCall | 83a230c | 2010-06-04 20:50:08 +0000 | [diff] [blame] | 492 | Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 493 | // FIXME: stable encoding |
| 494 | Record.push_back((unsigned)D->getPropertyAttributes()); |
Fariborz Jahanian | 80aa1cd | 2010-06-22 23:20:40 +0000 | [diff] [blame] | 495 | Record.push_back((unsigned)D->getPropertyAttributesAsWritten()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 496 | // FIXME: stable encoding |
| 497 | Record.push_back((unsigned)D->getPropertyImplementation()); |
| 498 | Writer.AddDeclarationName(D->getGetterName(), Record); |
| 499 | Writer.AddDeclarationName(D->getSetterName(), Record); |
| 500 | Writer.AddDeclRef(D->getGetterMethodDecl(), Record); |
| 501 | Writer.AddDeclRef(D->getSetterMethodDecl(), Record); |
| 502 | Writer.AddDeclRef(D->getPropertyIvarDecl(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 503 | Code = serialization::DECL_OBJC_PROPERTY; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 504 | } |
| 505 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 506 | void ASTDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) { |
Argyrios Kyrtzidis | aecae62 | 2009-07-27 19:04:32 +0000 | [diff] [blame] | 507 | VisitObjCContainerDecl(D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 508 | Writer.AddDeclRef(D->getClassInterface(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 509 | // Abstract class (no need to define a stable serialization::DECL code). |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 510 | } |
| 511 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 512 | void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 513 | VisitObjCImplDecl(D); |
| 514 | Writer.AddIdentifierRef(D->getIdentifier(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 515 | Code = serialization::DECL_OBJC_CATEGORY_IMPL; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 516 | } |
| 517 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 518 | void ASTDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 519 | VisitObjCImplDecl(D); |
| 520 | Writer.AddDeclRef(D->getSuperClass(), Record); |
Sean Hunt | cbb6748 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 521 | Writer.AddCXXCtorInitializers(D->IvarInitializers, D->NumIvarInitializers, |
| 522 | Record); |
Fariborz Jahanian | 000835d | 2010-08-23 18:51:39 +0000 | [diff] [blame] | 523 | Record.push_back(D->hasSynthBitfield()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 524 | Code = serialization::DECL_OBJC_IMPLEMENTATION; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 525 | } |
| 526 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 527 | void ASTDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 528 | VisitDecl(D); |
| 529 | Writer.AddSourceLocation(D->getLocStart(), Record); |
| 530 | Writer.AddDeclRef(D->getPropertyDecl(), Record); |
| 531 | Writer.AddDeclRef(D->getPropertyIvarDecl(), Record); |
Douglas Gregor | a4ffd85 | 2010-11-17 01:03:52 +0000 | [diff] [blame] | 532 | Writer.AddSourceLocation(D->getPropertyIvarDeclLoc(), Record); |
Argyrios Kyrtzidis | 2f92230 | 2010-08-09 10:54:37 +0000 | [diff] [blame] | 533 | Writer.AddStmt(D->getGetterCXXConstructor()); |
| 534 | Writer.AddStmt(D->getSetterCXXAssignment()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 535 | Code = serialization::DECL_OBJC_PROPERTY_IMPL; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 536 | } |
| 537 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 538 | void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 539 | VisitDeclaratorDecl(D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 540 | Record.push_back(D->isMutable()); |
| 541 | Record.push_back(D->getBitWidth()? 1 : 0); |
| 542 | if (D->getBitWidth()) |
| 543 | Writer.AddStmt(D->getBitWidth()); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 544 | if (!D->getDeclName()) |
| 545 | Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 546 | Code = serialization::DECL_FIELD; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 547 | } |
| 548 | |
Francois Pichet | 87c2e12 | 2010-11-21 06:08:52 +0000 | [diff] [blame] | 549 | void ASTDeclWriter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { |
| 550 | VisitValueDecl(D); |
| 551 | Record.push_back(D->getChainingSize()); |
| 552 | |
| 553 | for (IndirectFieldDecl::chain_iterator |
| 554 | P = D->chain_begin(), |
| 555 | PEnd = D->chain_end(); P != PEnd; ++P) |
| 556 | Writer.AddDeclRef(*P, Record); |
| 557 | Code = serialization::DECL_INDIRECTFIELD; |
| 558 | } |
| 559 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 560 | void ASTDeclWriter::VisitVarDecl(VarDecl *D) { |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 561 | VisitDeclaratorDecl(D); |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 562 | VisitRedeclarable(D); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 563 | Record.push_back(D->getStorageClass()); // FIXME: stable encoding |
Douglas Gregor | 16573fa | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 564 | Record.push_back(D->getStorageClassAsWritten()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 565 | Record.push_back(D->isThreadSpecified()); |
| 566 | Record.push_back(D->hasCXXDirectInitializer()); |
Douglas Gregor | 324b54d | 2010-05-03 18:51:14 +0000 | [diff] [blame] | 567 | Record.push_back(D->isExceptionVariable()); |
Douglas Gregor | 5077c38 | 2010-05-15 06:01:05 +0000 | [diff] [blame] | 568 | Record.push_back(D->isNRVOVariable()); |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 569 | Record.push_back(D->isCXXForRangeDecl()); |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 570 | Record.push_back(D->getInit() ? 1 : 0); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 571 | if (D->getInit()) |
| 572 | Writer.AddStmt(D->getInit()); |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 573 | |
| 574 | MemberSpecializationInfo *SpecInfo |
| 575 | = D->isStaticDataMember() ? D->getMemberSpecializationInfo() : 0; |
| 576 | Record.push_back(SpecInfo != 0); |
| 577 | if (SpecInfo) { |
| 578 | Writer.AddDeclRef(SpecInfo->getInstantiatedFrom(), Record); |
| 579 | Record.push_back(SpecInfo->getTemplateSpecializationKind()); |
| 580 | Writer.AddSourceLocation(SpecInfo->getPointOfInstantiation(), Record); |
| 581 | } |
| 582 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 583 | Code = serialization::DECL_VAR; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 584 | } |
| 585 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 586 | void ASTDeclWriter::VisitImplicitParamDecl(ImplicitParamDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 587 | VisitVarDecl(D); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 588 | Code = serialization::DECL_IMPLICIT_PARAM; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 589 | } |
| 590 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 591 | void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 592 | VisitVarDecl(D); |
John McCall | 7079886 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 593 | Record.push_back(D->isObjCMethodParameter()); |
John McCall | fb44de9 | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 594 | Record.push_back(D->getFunctionScopeDepth()); |
| 595 | Record.push_back(D->getFunctionScopeIndex()); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 596 | Record.push_back(D->getObjCDeclQualifier()); // FIXME: stable encoding |
John McCall | eecf5fa | 2011-03-09 04:22:44 +0000 | [diff] [blame] | 597 | Record.push_back(D->isKNRPromoted()); |
John McCall | bf73b35 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 598 | Record.push_back(D->hasInheritedDefaultArg()); |
Argyrios Kyrtzidis | 691d77f | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 599 | Record.push_back(D->hasUninstantiatedDefaultArg()); |
| 600 | if (D->hasUninstantiatedDefaultArg()) |
| 601 | Writer.AddStmt(D->getUninstantiatedDefaultArg()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 602 | Code = serialization::DECL_PARM_VAR; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 603 | |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 604 | // If the assumptions about the DECL_PARM_VAR abbrev are true, use it. Here |
| 605 | // we dynamically check for the properties that we optimize for, but don't |
| 606 | // know are true of all PARM_VAR_DECLs. |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 607 | if (!D->getTypeSourceInfo() && |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 608 | !D->hasAttrs() && |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 609 | !D->isImplicit() && |
Douglas Gregor | c070cc6 | 2010-06-17 23:14:26 +0000 | [diff] [blame] | 610 | !D->isUsed(false) && |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 611 | D->getAccess() == AS_none && |
Douglas Gregor | 7d1d49d | 2009-10-16 20:01:17 +0000 | [diff] [blame] | 612 | D->getPCHLevel() == 0 && |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 613 | D->getStorageClass() == 0 && |
| 614 | !D->hasCXXDirectInitializer() && // Can params have this ever? |
John McCall | 7079886 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 615 | D->getFunctionScopeDepth() == 0 && |
John McCall | bf73b35 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 616 | D->getObjCDeclQualifier() == 0 && |
John McCall | eecf5fa | 2011-03-09 04:22:44 +0000 | [diff] [blame] | 617 | !D->isKNRPromoted() && |
Chris Lattner | 030854b | 2010-05-09 06:40:08 +0000 | [diff] [blame] | 618 | !D->hasInheritedDefaultArg() && |
Argyrios Kyrtzidis | 691d77f | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 619 | D->getInit() == 0 && |
| 620 | !D->hasUninstantiatedDefaultArg()) // No default expr. |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 621 | AbbrevToUse = Writer.getParmVarDeclAbbrev(); |
| 622 | |
| 623 | // Check things we know are true of *every* PARM_VAR_DECL, which is more than |
| 624 | // just us assuming it. |
| 625 | assert(!D->isInvalidDecl() && "Shouldn't emit invalid decls"); |
| 626 | assert(!D->isThreadSpecified() && "PARM_VAR_DECL can't be __thread"); |
| 627 | assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private"); |
Douglas Gregor | 324b54d | 2010-05-03 18:51:14 +0000 | [diff] [blame] | 628 | assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var"); |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 629 | assert(D->getPreviousDeclaration() == 0 && "PARM_VAR_DECL can't be redecl"); |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 630 | assert(!D->isStaticDataMember() && |
| 631 | "PARM_VAR_DECL can't be static data member"); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 632 | } |
| 633 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 634 | void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 635 | VisitDecl(D); |
| 636 | Writer.AddStmt(D->getAsmString()); |
Abramo Bagnara | 21e006e | 2011-03-03 14:20:18 +0000 | [diff] [blame] | 637 | Writer.AddSourceLocation(D->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 638 | Code = serialization::DECL_FILE_SCOPE_ASM; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 639 | } |
| 640 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 641 | void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) { |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 642 | VisitDecl(D); |
| 643 | Writer.AddStmt(D->getBody()); |
John McCall | 82dc009 | 2010-06-04 11:21:44 +0000 | [diff] [blame] | 644 | Writer.AddTypeSourceInfo(D->getSignatureAsWritten(), Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 645 | Record.push_back(D->param_size()); |
| 646 | for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end(); |
| 647 | P != PEnd; ++P) |
| 648 | Writer.AddDeclRef(*P, Record); |
John McCall | 469a1eb | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 649 | Record.push_back(D->capturesCXXThis()); |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 650 | Record.push_back(D->getNumCaptures()); |
John McCall | 469a1eb | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 651 | for (BlockDecl::capture_iterator |
John McCall | 6b5a61b | 2011-02-07 10:33:21 +0000 | [diff] [blame] | 652 | i = D->capture_begin(), e = D->capture_end(); i != e; ++i) { |
| 653 | const BlockDecl::Capture &capture = *i; |
| 654 | Writer.AddDeclRef(capture.getVariable(), Record); |
| 655 | |
| 656 | unsigned flags = 0; |
| 657 | if (capture.isByRef()) flags |= 1; |
| 658 | if (capture.isNested()) flags |= 2; |
| 659 | if (capture.hasCopyExpr()) flags |= 4; |
| 660 | Record.push_back(flags); |
| 661 | |
| 662 | if (capture.hasCopyExpr()) Writer.AddStmt(capture.getCopyExpr()); |
| 663 | } |
John McCall | 469a1eb | 2011-02-02 13:00:07 +0000 | [diff] [blame] | 664 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 665 | Code = serialization::DECL_BLOCK; |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 666 | } |
| 667 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 668 | void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 669 | VisitDecl(D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 670 | Record.push_back(D->getLanguage()); |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 671 | Writer.AddSourceLocation(D->getExternLoc(), Record); |
Abramo Bagnara | 5f6bcbe | 2011-03-03 14:52:38 +0000 | [diff] [blame] | 672 | Writer.AddSourceLocation(D->getRBraceLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 673 | Code = serialization::DECL_LINKAGE_SPEC; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 674 | } |
| 675 | |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 676 | void ASTDeclWriter::VisitLabelDecl(LabelDecl *D) { |
| 677 | VisitNamedDecl(D); |
Abramo Bagnara | 6784304 | 2011-03-05 18:21:20 +0000 | [diff] [blame] | 678 | Writer.AddSourceLocation(D->getLocStart(), Record); |
Chris Lattner | ad8dcf4 | 2011-02-17 07:39:24 +0000 | [diff] [blame] | 679 | Code = serialization::DECL_LABEL; |
| 680 | } |
| 681 | |
| 682 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 683 | void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 684 | VisitNamedDecl(D); |
Douglas Gregor | 0a0c3e7 | 2010-10-05 20:41:58 +0000 | [diff] [blame] | 685 | Record.push_back(D->isInline()); |
Abramo Bagnara | acba90f | 2011-03-08 12:38:20 +0000 | [diff] [blame] | 686 | Writer.AddSourceLocation(D->getLocStart(), Record); |
| 687 | Writer.AddSourceLocation(D->getRBraceLoc(), Record); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 688 | Writer.AddDeclRef(D->getNextNamespace(), Record); |
| 689 | |
| 690 | // Only write one reference--original or anonymous |
| 691 | Record.push_back(D->isOriginalNamespace()); |
| 692 | if (D->isOriginalNamespace()) |
| 693 | Writer.AddDeclRef(D->getAnonymousNamespace(), Record); |
| 694 | else |
| 695 | Writer.AddDeclRef(D->getOriginalNamespace(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 696 | Code = serialization::DECL_NAMESPACE; |
Sebastian Redl | a7be506 | 2010-08-05 21:22:19 +0000 | [diff] [blame] | 697 | |
| 698 | if (Writer.hasChain() && !D->isOriginalNamespace() && |
| 699 | D->getOriginalNamespace()->getPCHLevel() > 0) { |
Argyrios Kyrtzidis | 0ad6dc3 | 2010-10-20 16:22:56 +0000 | [diff] [blame] | 700 | NamespaceDecl *NS = D->getOriginalNamespace(); |
Argyrios Kyrtzidis | 100050b | 2010-10-28 07:38:51 +0000 | [diff] [blame] | 701 | Writer.AddUpdatedDeclContext(NS); |
Argyrios Kyrtzidis | 0ad6dc3 | 2010-10-20 16:22:56 +0000 | [diff] [blame] | 702 | |
| 703 | // Make sure all visible decls are written. They will be recorded later. |
| 704 | NS->lookup(DeclarationName()); |
| 705 | StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(NS->getLookupPtr()); |
| 706 | if (Map) { |
| 707 | for (StoredDeclsMap::iterator D = Map->begin(), DEnd = Map->end(); |
| 708 | D != DEnd; ++D) { |
Argyrios Kyrtzidis | 0ad6dc3 | 2010-10-20 16:22:56 +0000 | [diff] [blame] | 709 | DeclContext::lookup_result Result = D->second.getLookupResult(); |
| 710 | while (Result.first != Result.second) { |
| 711 | Writer.GetDeclRef(*Result.first); |
| 712 | ++Result.first; |
| 713 | } |
| 714 | } |
| 715 | } |
Sebastian Redl | a7be506 | 2010-08-05 21:22:19 +0000 | [diff] [blame] | 716 | } |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 717 | |
Sebastian Redl | 74b485a | 2011-04-24 16:28:21 +0000 | [diff] [blame] | 718 | if (Writer.hasChain() && D->isAnonymousNamespace() && !D->getNextNamespace()){ |
| 719 | // This is a most recent reopening of the anonymous namespace. If its parent |
| 720 | // is in a previous PCH (or is the TU), mark that parent for update, because |
| 721 | // the original namespace always points to the latest re-opening of its |
| 722 | // anonymous namespace. |
| 723 | Decl *Parent = cast<Decl>( |
| 724 | D->getParent()->getRedeclContext()->getPrimaryContext()); |
Sebastian Redl | 7c0837f | 2011-04-24 16:28:13 +0000 | [diff] [blame] | 725 | if (Parent->getPCHLevel() > 0) { |
| 726 | ASTWriter::UpdateRecord &Record = Writer.DeclUpdates[Parent]; |
| 727 | Record.push_back(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE); |
| 728 | Writer.AddDeclRef(D, Record); |
| 729 | } |
| 730 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 731 | } |
| 732 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 733 | void ASTDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 734 | VisitNamedDecl(D); |
Douglas Gregor | 8ea5b9d | 2010-09-01 00:08:19 +0000 | [diff] [blame] | 735 | Writer.AddSourceLocation(D->getNamespaceLoc(), Record); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 736 | Writer.AddSourceLocation(D->getTargetNameLoc(), Record); |
Douglas Gregor | 0cfaf6a | 2011-02-25 17:08:07 +0000 | [diff] [blame] | 737 | Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 738 | Writer.AddDeclRef(D->getNamespace(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 739 | Code = serialization::DECL_NAMESPACE_ALIAS; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 740 | } |
| 741 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 742 | void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 743 | VisitNamedDecl(D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 744 | Writer.AddSourceLocation(D->getUsingLocation(), Record); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 745 | Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 746 | Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record); |
Argyrios Kyrtzidis | 826faa2 | 2010-11-10 05:40:41 +0000 | [diff] [blame] | 747 | Writer.AddDeclRef(D->FirstUsingShadow, Record); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 748 | Record.push_back(D->isTypeName()); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 749 | Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 750 | Code = serialization::DECL_USING; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 751 | } |
| 752 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 753 | void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 754 | VisitNamedDecl(D); |
| 755 | Writer.AddDeclRef(D->getTargetDecl(), Record); |
Argyrios Kyrtzidis | 826faa2 | 2010-11-10 05:40:41 +0000 | [diff] [blame] | 756 | Writer.AddDeclRef(D->UsingOrNextShadow, Record); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 757 | Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 758 | Code = serialization::DECL_USING_SHADOW; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 759 | } |
| 760 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 761 | void ASTDeclWriter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 762 | VisitNamedDecl(D); |
Douglas Gregor | 0a35bce | 2010-09-01 03:07:18 +0000 | [diff] [blame] | 763 | Writer.AddSourceLocation(D->getUsingLoc(), Record); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 764 | Writer.AddSourceLocation(D->getNamespaceKeyLocation(), Record); |
Douglas Gregor | db99241 | 2011-02-25 16:33:46 +0000 | [diff] [blame] | 765 | Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 766 | Writer.AddDeclRef(D->getNominatedNamespace(), Record); |
| 767 | Writer.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 768 | Code = serialization::DECL_USING_DIRECTIVE; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 769 | } |
| 770 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 771 | void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 772 | VisitValueDecl(D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 773 | Writer.AddSourceLocation(D->getUsingLoc(), Record); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 774 | Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record); |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 775 | Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 776 | Code = serialization::DECL_UNRESOLVED_USING_VALUE; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 777 | } |
| 778 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 779 | void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 780 | UnresolvedUsingTypenameDecl *D) { |
| 781 | VisitTypeDecl(D); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 782 | Writer.AddSourceLocation(D->getTypenameLoc(), Record); |
Douglas Gregor | dc35571 | 2011-02-25 00:36:19 +0000 | [diff] [blame] | 783 | Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 784 | Code = serialization::DECL_UNRESOLVED_USING_TYPENAME; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 785 | } |
| 786 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 787 | void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 788 | VisitRecordDecl(D); |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 789 | |
Argyrios Kyrtzidis | 134db1f | 2010-10-24 17:26:31 +0000 | [diff] [blame] | 790 | CXXRecordDecl *DefinitionDecl = 0; |
| 791 | if (D->DefinitionData) |
| 792 | DefinitionDecl = D->DefinitionData->Definition; |
| 793 | Writer.AddDeclRef(DefinitionDecl, Record); |
Argyrios Kyrtzidis | 89eaf3a | 2010-10-24 17:26:40 +0000 | [diff] [blame] | 794 | if (D == DefinitionDecl) |
| 795 | Writer.AddCXXDefinitionData(D, Record); |
Argyrios Kyrtzidis | 37ffed3 | 2010-07-02 11:55:32 +0000 | [diff] [blame] | 796 | |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 797 | enum { |
| 798 | CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization |
| 799 | }; |
| 800 | if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) { |
| 801 | Record.push_back(CXXRecTemplate); |
| 802 | Writer.AddDeclRef(TemplD, Record); |
| 803 | } else if (MemberSpecializationInfo *MSInfo |
| 804 | = D->getMemberSpecializationInfo()) { |
| 805 | Record.push_back(CXXRecMemberSpecialization); |
| 806 | Writer.AddDeclRef(MSInfo->getInstantiatedFrom(), Record); |
| 807 | Record.push_back(MSInfo->getTemplateSpecializationKind()); |
| 808 | Writer.AddSourceLocation(MSInfo->getPointOfInstantiation(), Record); |
| 809 | } else { |
| 810 | Record.push_back(CXXRecNotTemplate); |
| 811 | } |
| 812 | |
Argyrios Kyrtzidis | 36d2fd4 | 2010-10-14 20:14:38 +0000 | [diff] [blame] | 813 | // Store the key function to avoid deserializing every method so we can |
| 814 | // compute it. |
| 815 | if (D->IsDefinition) |
| 816 | Writer.AddDeclRef(Context.getKeyFunction(D), Record); |
| 817 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 818 | Code = serialization::DECL_CXX_RECORD; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 819 | } |
| 820 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 821 | void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 822 | VisitFunctionDecl(D); |
Argyrios Kyrtzidis | c91e9f4 | 2010-07-04 21:44:35 +0000 | [diff] [blame] | 823 | Record.push_back(D->size_overridden_methods()); |
| 824 | for (CXXMethodDecl::method_iterator |
| 825 | I = D->begin_overridden_methods(), E = D->end_overridden_methods(); |
| 826 | I != E; ++I) |
| 827 | Writer.AddDeclRef(*I, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 828 | Code = serialization::DECL_CXX_METHOD; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 829 | } |
| 830 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 831 | void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 832 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 833 | |
| 834 | Record.push_back(D->IsExplicitSpecified); |
| 835 | Record.push_back(D->ImplicitlyDefined); |
Sean Hunt | cbb6748 | 2011-01-08 20:30:50 +0000 | [diff] [blame] | 836 | Writer.AddCXXCtorInitializers(D->CtorInitializers, D->NumCtorInitializers, |
| 837 | Record); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 838 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 839 | Code = serialization::DECL_CXX_CONSTRUCTOR; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 840 | } |
| 841 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 842 | void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 843 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 844 | |
| 845 | Record.push_back(D->ImplicitlyDefined); |
| 846 | Writer.AddDeclRef(D->OperatorDelete, Record); |
| 847 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 848 | Code = serialization::DECL_CXX_DESTRUCTOR; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 849 | } |
| 850 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 851 | void ASTDeclWriter::VisitCXXConversionDecl(CXXConversionDecl *D) { |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 852 | VisitCXXMethodDecl(D); |
Argyrios Kyrtzidis | 9146832 | 2010-07-02 15:58:43 +0000 | [diff] [blame] | 853 | Record.push_back(D->IsExplicitSpecified); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 854 | Code = serialization::DECL_CXX_CONVERSION; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 855 | } |
| 856 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 857 | void ASTDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) { |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 858 | VisitDecl(D); |
| 859 | Writer.AddSourceLocation(D->getColonLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 860 | Code = serialization::DECL_ACCESS_SPEC; |
Abramo Bagnara | 6206d53 | 2010-06-05 05:09:32 +0000 | [diff] [blame] | 861 | } |
| 862 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 863 | void ASTDeclWriter::VisitFriendDecl(FriendDecl *D) { |
Argyrios Kyrtzidis | c8f9af2 | 2010-07-05 10:38:01 +0000 | [diff] [blame] | 864 | VisitDecl(D); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 865 | Record.push_back(D->Friend.is<TypeSourceInfo*>()); |
| 866 | if (D->Friend.is<TypeSourceInfo*>()) |
| 867 | Writer.AddTypeSourceInfo(D->Friend.get<TypeSourceInfo*>(), Record); |
| 868 | else |
| 869 | Writer.AddDeclRef(D->Friend.get<NamedDecl*>(), Record); |
Douglas Gregor | 69aecc6 | 2010-10-27 20:23:41 +0000 | [diff] [blame] | 870 | Writer.AddDeclRef(D->getNextFriend(), Record); |
John McCall | 6102ca1 | 2010-10-16 06:59:13 +0000 | [diff] [blame] | 871 | Record.push_back(D->UnsupportedFriend); |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 872 | Writer.AddSourceLocation(D->FriendLoc, Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 873 | Code = serialization::DECL_FRIEND; |
Argyrios Kyrtzidis | 6764334 | 2010-06-29 22:47:00 +0000 | [diff] [blame] | 874 | } |
| 875 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 876 | void ASTDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) { |
Argyrios Kyrtzidis | 554e6aa | 2010-07-22 16:04:10 +0000 | [diff] [blame] | 877 | VisitDecl(D); |
| 878 | Record.push_back(D->getNumTemplateParameters()); |
| 879 | for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i) |
| 880 | Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record); |
| 881 | Record.push_back(D->getFriendDecl() != 0); |
| 882 | if (D->getFriendDecl()) |
| 883 | Writer.AddDeclRef(D->getFriendDecl(), Record); |
| 884 | else |
| 885 | Writer.AddTypeSourceInfo(D->getFriendType(), Record); |
| 886 | Writer.AddSourceLocation(D->getFriendLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 887 | Code = serialization::DECL_FRIEND_TEMPLATE; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 888 | } |
| 889 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 890 | void ASTDeclWriter::VisitTemplateDecl(TemplateDecl *D) { |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 891 | VisitNamedDecl(D); |
| 892 | |
| 893 | Writer.AddDeclRef(D->getTemplatedDecl(), Record); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 894 | Writer.AddTemplateParameterList(D->getTemplateParameters(), Record); |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 895 | } |
| 896 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 897 | void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 898 | // Emit data to initialize CommonOrPrev before VisitTemplateDecl so that |
| 899 | // getCommonPtr() can be used while this is still initializing. |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 900 | |
| 901 | Writer.AddDeclRef(D->getPreviousDeclaration(), Record); |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 902 | if (D->getPreviousDeclaration()) |
| 903 | Writer.AddDeclRef(D->getFirstDeclaration(), Record); |
| 904 | |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 905 | if (D->getPreviousDeclaration() == 0) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 906 | // This TemplateDecl owns the CommonPtr; write it. |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 907 | assert(D->isCanonicalDecl()); |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 908 | |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 909 | Writer.AddDeclRef(D->getInstantiatedFromMemberTemplate(), Record); |
| 910 | if (D->getInstantiatedFromMemberTemplate()) |
| 911 | Record.push_back(D->isMemberSpecialization()); |
Peter Collingbourne | 8a798a7 | 2010-07-29 16:12:01 +0000 | [diff] [blame] | 912 | |
| 913 | Writer.AddDeclRef(D->getCommonPtr()->Latest, Record); |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 914 | } else { |
| 915 | RedeclarableTemplateDecl *First = D->getFirstDeclaration(); |
| 916 | assert(First != D); |
| 917 | // If this is a most recent redeclaration that is pointed to by a first decl |
| 918 | // in a chained PCH, keep track of the association with the map so we can |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 919 | // update the first decl during AST reading. |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 920 | if (First->getMostRecentDeclaration() == D && |
| 921 | First->getPCHLevel() > D->getPCHLevel()) { |
| 922 | assert(Writer.FirstLatestDecls.find(First)==Writer.FirstLatestDecls.end() |
| 923 | && "The latest is already set"); |
| 924 | Writer.FirstLatestDecls[First] = D; |
| 925 | } |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 926 | } |
Argyrios Kyrtzidis | 6b54151 | 2010-09-08 19:31:22 +0000 | [diff] [blame] | 927 | |
| 928 | VisitTemplateDecl(D); |
| 929 | Record.push_back(D->getIdentifierNamespace()); |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 930 | } |
| 931 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 932 | void ASTDeclWriter::VisitClassTemplateDecl(ClassTemplateDecl *D) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 933 | VisitRedeclarableTemplateDecl(D); |
| 934 | |
| 935 | if (D->getPreviousDeclaration() == 0) { |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 936 | typedef llvm::FoldingSet<ClassTemplateSpecializationDecl> CTSDSetTy; |
| 937 | CTSDSetTy &CTSDSet = D->getSpecializations(); |
| 938 | Record.push_back(CTSDSet.size()); |
Argyrios Kyrtzidis | 7d53048 | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 939 | for (CTSDSetTy::iterator I=CTSDSet.begin(), E = CTSDSet.end(); I!=E; ++I) { |
Argyrios Kyrtzidis | bc5ab7c | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 940 | assert(I->isCanonicalDecl() && "Expected only canonical decls in set"); |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 941 | Writer.AddDeclRef(&*I, Record); |
Argyrios Kyrtzidis | 7d53048 | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 942 | } |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 943 | |
| 944 | typedef llvm::FoldingSet<ClassTemplatePartialSpecializationDecl> CTPSDSetTy; |
| 945 | CTPSDSetTy &CTPSDSet = D->getPartialSpecializations(); |
| 946 | Record.push_back(CTPSDSet.size()); |
Argyrios Kyrtzidis | 7d53048 | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 947 | for (CTPSDSetTy::iterator I=CTPSDSet.begin(), E=CTPSDSet.end(); I!=E; ++I) { |
Argyrios Kyrtzidis | bc5ab7c | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 948 | assert(I->isCanonicalDecl() && "Expected only canonical decls in set"); |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 949 | Writer.AddDeclRef(&*I, Record); |
Argyrios Kyrtzidis | 7d53048 | 2010-07-02 11:55:37 +0000 | [diff] [blame] | 950 | } |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 951 | |
| 952 | // InjectedClassNameType is computed, no need to write it. |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 953 | } |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 954 | Code = serialization::DECL_CLASS_TEMPLATE; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 955 | } |
| 956 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 957 | void ASTDeclWriter::VisitClassTemplateSpecializationDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 958 | ClassTemplateSpecializationDecl *D) { |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 959 | VisitCXXRecordDecl(D); |
| 960 | |
| 961 | llvm::PointerUnion<ClassTemplateDecl *, |
| 962 | ClassTemplatePartialSpecializationDecl *> InstFrom |
| 963 | = D->getSpecializedTemplateOrPartial(); |
Sebastian Redl | 4153a06 | 2010-08-24 22:50:24 +0000 | [diff] [blame] | 964 | Decl *InstFromD; |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 965 | if (InstFrom.is<ClassTemplateDecl *>()) { |
Sebastian Redl | 4153a06 | 2010-08-24 22:50:24 +0000 | [diff] [blame] | 966 | InstFromD = InstFrom.get<ClassTemplateDecl *>(); |
| 967 | Writer.AddDeclRef(InstFromD, Record); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 968 | } else { |
Sebastian Redl | 4153a06 | 2010-08-24 22:50:24 +0000 | [diff] [blame] | 969 | InstFromD = InstFrom.get<ClassTemplatePartialSpecializationDecl *>(); |
| 970 | Writer.AddDeclRef(InstFromD, Record); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 971 | Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record); |
Sebastian Redl | 4153a06 | 2010-08-24 22:50:24 +0000 | [diff] [blame] | 972 | InstFromD = cast<ClassTemplatePartialSpecializationDecl>(InstFromD)-> |
| 973 | getSpecializedTemplate(); |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | // Explicit info. |
| 977 | Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record); |
| 978 | if (D->getTypeAsWritten()) { |
| 979 | Writer.AddSourceLocation(D->getExternLoc(), Record); |
| 980 | Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record); |
| 981 | } |
| 982 | |
| 983 | Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record); |
| 984 | Writer.AddSourceLocation(D->getPointOfInstantiation(), Record); |
| 985 | Record.push_back(D->getSpecializationKind()); |
| 986 | |
Argyrios Kyrtzidis | bc5ab7c | 2010-07-20 13:59:40 +0000 | [diff] [blame] | 987 | if (D->isCanonicalDecl()) { |
| 988 | // When reading, we'll add it to the folding set of the following template. |
Argyrios Kyrtzidis | ecf966e | 2010-07-09 21:11:43 +0000 | [diff] [blame] | 989 | Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record); |
| 990 | } |
| 991 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 992 | Code = serialization::DECL_CLASS_TEMPLATE_SPECIALIZATION; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 993 | } |
| 994 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 995 | void ASTDeclWriter::VisitClassTemplatePartialSpecializationDecl( |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 996 | ClassTemplatePartialSpecializationDecl *D) { |
Argyrios Kyrtzidis | dd41c14 | 2010-06-23 13:48:30 +0000 | [diff] [blame] | 997 | VisitClassTemplateSpecializationDecl(D); |
| 998 | |
| 999 | Writer.AddTemplateParameterList(D->getTemplateParameters(), Record); |
| 1000 | |
| 1001 | Record.push_back(D->getNumTemplateArgsAsWritten()); |
| 1002 | for (int i = 0, e = D->getNumTemplateArgsAsWritten(); i != e; ++i) |
| 1003 | Writer.AddTemplateArgumentLoc(D->getTemplateArgsAsWritten()[i], Record); |
| 1004 | |
| 1005 | Record.push_back(D->getSequenceNumber()); |
| 1006 | |
| 1007 | // These are read/set from/to the first declaration. |
| 1008 | if (D->getPreviousDeclaration() == 0) { |
| 1009 | Writer.AddDeclRef(D->getInstantiatedFromMember(), Record); |
| 1010 | Record.push_back(D->isMemberSpecialization()); |
| 1011 | } |
| 1012 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1013 | Code = serialization::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1014 | } |
| 1015 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1016 | void ASTDeclWriter::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { |
Peter Collingbourne | 9eabeba | 2010-07-29 16:11:51 +0000 | [diff] [blame] | 1017 | VisitRedeclarableTemplateDecl(D); |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1018 | |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1019 | if (D->getPreviousDeclaration() == 0) { |
| 1020 | // This FunctionTemplateDecl owns the CommonPtr; write it. |
| 1021 | |
Argyrios Kyrtzidis | 057d9af | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1022 | // Write the function specialization declarations. |
| 1023 | Record.push_back(D->getSpecializations().size()); |
| 1024 | for (llvm::FoldingSet<FunctionTemplateSpecializationInfo>::iterator |
| 1025 | I = D->getSpecializations().begin(), |
Argyrios Kyrtzidis | 2c853e4 | 2010-07-20 13:59:58 +0000 | [diff] [blame] | 1026 | E = D->getSpecializations().end() ; I != E; ++I) { |
| 1027 | assert(I->Function->isCanonicalDecl() && |
| 1028 | "Expected only canonical decls in set"); |
Argyrios Kyrtzidis | 057d9af | 2010-07-06 15:37:09 +0000 | [diff] [blame] | 1029 | Writer.AddDeclRef(I->Function, Record); |
Argyrios Kyrtzidis | 2c853e4 | 2010-07-20 13:59:58 +0000 | [diff] [blame] | 1030 | } |
Argyrios Kyrtzidis | f511ba6 | 2010-06-22 09:55:07 +0000 | [diff] [blame] | 1031 | } |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1032 | Code = serialization::DECL_FUNCTION_TEMPLATE; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1033 | } |
| 1034 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1035 | void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1036 | VisitTypeDecl(D); |
| 1037 | |
| 1038 | Record.push_back(D->wasDeclaredWithTypename()); |
Argyrios Kyrtzidis | 90b715e | 2010-06-19 19:28:53 +0000 | [diff] [blame] | 1039 | Record.push_back(D->defaultArgumentWasInherited()); |
| 1040 | Writer.AddTypeSourceInfo(D->getDefaultArgumentInfo(), Record); |
| 1041 | |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1042 | Code = serialization::DECL_TEMPLATE_TYPE_PARM; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1043 | } |
| 1044 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1045 | void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1046 | // For an expanded parameter pack, record the number of expansion types here |
| 1047 | // so that it's easier for |
| 1048 | if (D->isExpandedParameterPack()) |
| 1049 | Record.push_back(D->getNumExpansionTypes()); |
| 1050 | |
John McCall | 76a4021 | 2011-02-09 01:13:10 +0000 | [diff] [blame] | 1051 | VisitDeclaratorDecl(D); |
Argyrios Kyrtzidis | b24e199 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1052 | // TemplateParmPosition. |
| 1053 | Record.push_back(D->getDepth()); |
| 1054 | Record.push_back(D->getPosition()); |
Douglas Gregor | 6952f1e | 2011-01-19 20:10:05 +0000 | [diff] [blame] | 1055 | |
| 1056 | if (D->isExpandedParameterPack()) { |
| 1057 | for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { |
| 1058 | Writer.AddTypeRef(D->getExpansionType(I), Record); |
| 1059 | Writer.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I), Record); |
| 1060 | } |
| 1061 | |
| 1062 | Code = serialization::DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK; |
| 1063 | } else { |
| 1064 | // Rest of NonTypeTemplateParmDecl. |
| 1065 | Record.push_back(D->isParameterPack()); |
| 1066 | Record.push_back(D->getDefaultArgument() != 0); |
| 1067 | if (D->getDefaultArgument()) { |
| 1068 | Writer.AddStmt(D->getDefaultArgument()); |
| 1069 | Record.push_back(D->defaultArgumentWasInherited()); |
| 1070 | } |
| 1071 | Code = serialization::DECL_NON_TYPE_TEMPLATE_PARM; |
Argyrios Kyrtzidis | b24e199 | 2010-06-25 16:25:09 +0000 | [diff] [blame] | 1072 | } |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1073 | } |
| 1074 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1075 | void ASTDeclWriter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { |
Argyrios Kyrtzidis | bfcc92c | 2010-07-08 17:12:57 +0000 | [diff] [blame] | 1076 | VisitTemplateDecl(D); |
| 1077 | // TemplateParmPosition. |
| 1078 | Record.push_back(D->getDepth()); |
| 1079 | Record.push_back(D->getPosition()); |
| 1080 | // Rest of TemplateTemplateParmDecl. |
| 1081 | Writer.AddTemplateArgumentLoc(D->getDefaultArgument(), Record); |
| 1082 | Record.push_back(D->defaultArgumentWasInherited()); |
Douglas Gregor | 61c4d28 | 2011-01-05 15:48:55 +0000 | [diff] [blame] | 1083 | Record.push_back(D->isParameterPack()); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1084 | Code = serialization::DECL_TEMPLATE_TEMPLATE_PARM; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1085 | } |
| 1086 | |
Richard Smith | 3e4c6c4 | 2011-05-05 21:57:07 +0000 | [diff] [blame] | 1087 | void ASTDeclWriter::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { |
| 1088 | VisitRedeclarableTemplateDecl(D); |
| 1089 | Code = serialization::DECL_TYPE_ALIAS_TEMPLATE; |
| 1090 | } |
| 1091 | |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1092 | void ASTDeclWriter::VisitStaticAssertDecl(StaticAssertDecl *D) { |
Argyrios Kyrtzidis | 0d39689 | 2010-07-22 17:28:12 +0000 | [diff] [blame] | 1093 | VisitDecl(D); |
| 1094 | Writer.AddStmt(D->getAssertExpr()); |
| 1095 | Writer.AddStmt(D->getMessage()); |
Abramo Bagnara | a2026c9 | 2011-03-08 16:41:52 +0000 | [diff] [blame] | 1096 | Writer.AddSourceLocation(D->getRParenLoc(), Record); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1097 | Code = serialization::DECL_STATIC_ASSERT; |
Chris Lattner | 6ad9ac0 | 2010-05-07 21:43:38 +0000 | [diff] [blame] | 1098 | } |
| 1099 | |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1100 | /// \brief Emit the DeclContext part of a declaration context decl. |
| 1101 | /// |
| 1102 | /// \param LexicalOffset the offset at which the DECL_CONTEXT_LEXICAL |
| 1103 | /// block for this declaration context is stored. May be 0 to indicate |
| 1104 | /// that there are no declarations stored within this context. |
| 1105 | /// |
| 1106 | /// \param VisibleOffset the offset at which the DECL_CONTEXT_VISIBLE |
| 1107 | /// block for this declaration context is stored. May be 0 to indicate |
| 1108 | /// that there are no declarations visible from this context. Note |
| 1109 | /// that this value will not be emitted for non-primary declaration |
| 1110 | /// contexts. |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1111 | void ASTDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset, |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1112 | uint64_t VisibleOffset) { |
| 1113 | Record.push_back(LexicalOffset); |
| 1114 | Record.push_back(VisibleOffset); |
| 1115 | } |
| 1116 | |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1117 | template <typename T> |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1118 | void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) { |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1119 | enum { NoRedeclaration = 0, PointsToPrevious, PointsToLatest }; |
| 1120 | if (D->RedeclLink.getNext() == D) { |
| 1121 | Record.push_back(NoRedeclaration); |
| 1122 | } else { |
Argyrios Kyrtzidis | 0895d15 | 2011-02-12 07:50:47 +0000 | [diff] [blame] | 1123 | if (D->RedeclLink.NextIsPrevious()) { |
| 1124 | Record.push_back(PointsToPrevious); |
| 1125 | Writer.AddDeclRef(D->getPreviousDeclaration(), Record); |
| 1126 | Writer.AddDeclRef(D->getFirstDeclaration(), Record); |
| 1127 | } else { |
| 1128 | Record.push_back(PointsToLatest); |
| 1129 | Writer.AddDeclRef(D->RedeclLink.getPointer(), Record); |
| 1130 | } |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | T *First = D->getFirstDeclaration(); |
| 1134 | T *ThisDecl = static_cast<T*>(D); |
| 1135 | // If this is a most recent redeclaration that is pointed to by a first decl |
| 1136 | // in a chained PCH, keep track of the association with the map so we can |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1137 | // update the first decl during AST reading. |
Argyrios Kyrtzidis | a865005 | 2010-08-03 17:30:10 +0000 | [diff] [blame] | 1138 | if (ThisDecl != First && First->getMostRecentDeclaration() == ThisDecl && |
| 1139 | First->getPCHLevel() > ThisDecl->getPCHLevel()) { |
| 1140 | assert(Writer.FirstLatestDecls.find(First) == Writer.FirstLatestDecls.end() |
| 1141 | && "The latest is already set"); |
| 1142 | Writer.FirstLatestDecls[First] = ThisDecl; |
| 1143 | } |
| 1144 | } |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1145 | |
| 1146 | //===----------------------------------------------------------------------===// |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1147 | // ASTWriter Implementation |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1148 | //===----------------------------------------------------------------------===// |
| 1149 | |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1150 | void ASTWriter::WriteDeclsBlockAbbrevs() { |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1151 | using namespace llvm; |
| 1152 | // Abbreviation for DECL_PARM_VAR. |
| 1153 | BitCodeAbbrev *Abv = new BitCodeAbbrev(); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1154 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_PARM_VAR)); |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1155 | |
| 1156 | // Decl |
| 1157 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // DeclContext |
| 1158 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LexicalDeclContext |
| 1159 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Location |
| 1160 | Abv->Add(BitCodeAbbrevOp(0)); // isInvalidDecl (!?) |
| 1161 | Abv->Add(BitCodeAbbrevOp(0)); // HasAttrs |
| 1162 | Abv->Add(BitCodeAbbrevOp(0)); // isImplicit |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 1163 | Abv->Add(BitCodeAbbrevOp(0)); // isUsed |
Argyrios Kyrtzidis | 6b6b42a | 2011-04-19 19:51:10 +0000 | [diff] [blame] | 1164 | Abv->Add(BitCodeAbbrevOp(0)); // isReferenced |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1165 | Abv->Add(BitCodeAbbrevOp(AS_none)); // C++ AccessSpecifier |
Douglas Gregor | 7d1d49d | 2009-10-16 20:01:17 +0000 | [diff] [blame] | 1166 | Abv->Add(BitCodeAbbrevOp(0)); // PCH level |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1167 | |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1168 | // NamedDecl |
| 1169 | Abv->Add(BitCodeAbbrevOp(0)); // NameKind = Identifier |
| 1170 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Name |
| 1171 | // ValueDecl |
| 1172 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Type |
Argyrios Kyrtzidis | d4a7e54 | 2009-08-19 01:28:35 +0000 | [diff] [blame] | 1173 | // DeclaratorDecl |
Abramo Bagnara | ff676cb | 2011-03-08 08:55:46 +0000 | [diff] [blame] | 1174 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc |
Argyrios Kyrtzidis | 4045107 | 2010-10-15 18:21:24 +0000 | [diff] [blame] | 1175 | Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1176 | Abv->Add(BitCodeAbbrevOp(serialization::PREDEF_TYPE_NULL_ID)); // InfoType |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1177 | // VarDecl |
Andrew Trick | 220a9c8 | 2010-10-19 21:54:32 +0000 | [diff] [blame] | 1178 | Abv->Add(BitCodeAbbrevOp(0)); // No redeclaration |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1179 | Abv->Add(BitCodeAbbrevOp(0)); // StorageClass |
Douglas Gregor | 16573fa | 2010-04-19 22:54:31 +0000 | [diff] [blame] | 1180 | Abv->Add(BitCodeAbbrevOp(0)); // StorageClassAsWritten |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1181 | Abv->Add(BitCodeAbbrevOp(0)); // isThreadSpecified |
| 1182 | Abv->Add(BitCodeAbbrevOp(0)); // hasCXXDirectInitializer |
Douglas Gregor | 324b54d | 2010-05-03 18:51:14 +0000 | [diff] [blame] | 1183 | Abv->Add(BitCodeAbbrevOp(0)); // isExceptionVariable |
Douglas Gregor | 5077c38 | 2010-05-15 06:01:05 +0000 | [diff] [blame] | 1184 | Abv->Add(BitCodeAbbrevOp(0)); // isNRVOVariable |
Richard Smith | ad762fc | 2011-04-14 22:09:26 +0000 | [diff] [blame] | 1185 | Abv->Add(BitCodeAbbrevOp(0)); // isCXXForRangeDecl |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1186 | Abv->Add(BitCodeAbbrevOp(0)); // HasInit |
Argyrios Kyrtzidis | 9421adc | 2010-07-04 21:44:00 +0000 | [diff] [blame] | 1187 | Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1188 | // ParmVarDecl |
John McCall | 7079886 | 2011-05-02 00:30:12 +0000 | [diff] [blame] | 1189 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsObjCMethodParameter |
John McCall | fb44de9 | 2011-05-01 22:35:37 +0000 | [diff] [blame] | 1190 | Abv->Add(BitCodeAbbrevOp(0)); // ScopeDepth |
| 1191 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ScopeIndex |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1192 | Abv->Add(BitCodeAbbrevOp(0)); // ObjCDeclQualifier |
John McCall | eecf5fa | 2011-03-09 04:22:44 +0000 | [diff] [blame] | 1193 | Abv->Add(BitCodeAbbrevOp(0)); // KNRPromoted |
John McCall | bf73b35 | 2010-03-12 18:31:32 +0000 | [diff] [blame] | 1194 | Abv->Add(BitCodeAbbrevOp(0)); // HasInheritedDefaultArg |
Argyrios Kyrtzidis | 691d77f | 2010-07-04 21:44:07 +0000 | [diff] [blame] | 1195 | Abv->Add(BitCodeAbbrevOp(0)); // HasUninstantiatedDefaultArg |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1196 | |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1197 | ParmVarDeclAbbrev = Stream.EmitAbbrev(Abv); |
Sebastian Redl | 681d723 | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 1198 | |
| 1199 | Abv = new BitCodeAbbrev(); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1200 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_LEXICAL)); |
Sebastian Redl | 681d723 | 2010-07-27 00:17:23 +0000 | [diff] [blame] | 1201 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); |
| 1202 | DeclContextLexicalAbbrev = Stream.EmitAbbrev(Abv); |
Argyrios Kyrtzidis | 074dcc8 | 2010-08-20 16:04:35 +0000 | [diff] [blame] | 1203 | |
| 1204 | Abv = new BitCodeAbbrev(); |
| 1205 | Abv->Add(BitCodeAbbrevOp(serialization::DECL_CONTEXT_VISIBLE)); |
| 1206 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); |
| 1207 | Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); |
| 1208 | DeclContextVisibleLookupAbbrev = Stream.EmitAbbrev(Abv); |
Chris Lattner | ea5ce47 | 2009-04-27 07:35:58 +0000 | [diff] [blame] | 1209 | } |
| 1210 | |
Daniel Dunbar | e24d38f | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 1211 | /// isRequiredDecl - Check if this is a "required" Decl, which must be seen by |
| 1212 | /// consumers of the AST. |
| 1213 | /// |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1214 | /// Such decls will always be deserialized from the AST file, so we would like |
Daniel Dunbar | e24d38f | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 1215 | /// this to be as restrictive as possible. Currently the predicate is driven by |
| 1216 | /// code generation requirements, if other clients have a different notion of |
| 1217 | /// what is "required" then we may have to consider an alternate scheme where |
| 1218 | /// clients can iterate over the top-level decls and get information on them, |
| 1219 | /// without necessary deserializing them. We could explicitly require such |
| 1220 | /// clients to use a separate API call to "realize" the decl. This should be |
| 1221 | /// relatively painless since they would presumably only do it for top-level |
| 1222 | /// decls. |
Daniel Dunbar | e24d38f | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 1223 | static bool isRequiredDecl(const Decl *D, ASTContext &Context) { |
Argyrios Kyrtzidis | 9d50c06 | 2010-08-09 10:54:20 +0000 | [diff] [blame] | 1224 | // File scoped assembly or obj-c implementation must be seen. |
| 1225 | if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplementationDecl>(D)) |
Daniel Dunbar | e24d38f | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 1226 | return true; |
| 1227 | |
Argyrios Kyrtzidis | 4ac7c0b | 2010-07-29 20:08:05 +0000 | [diff] [blame] | 1228 | return Context.DeclMustBeEmitted(D); |
Daniel Dunbar | e24d38f | 2009-09-17 03:06:51 +0000 | [diff] [blame] | 1229 | } |
| 1230 | |
Sebastian Redl | a4232eb | 2010-08-18 23:56:21 +0000 | [diff] [blame] | 1231 | void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { |
Argyrios Kyrtzidis | e09a275 | 2010-10-28 09:29:32 +0000 | [diff] [blame] | 1232 | // Switch case IDs are per Decl. |
| 1233 | ClearSwitchCaseIDs(); |
| 1234 | |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1235 | RecordData Record; |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1236 | ASTDeclWriter W(*this, Context, Record); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1237 | |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1238 | // If this declaration is also a DeclContext, write blocks for the |
| 1239 | // declarations that lexically stored inside its context and those |
| 1240 | // declarations that are visible from its context. These blocks |
| 1241 | // are written before the declaration itself so that we can put |
| 1242 | // their offsets into the record for the declaration. |
| 1243 | uint64_t LexicalOffset = 0; |
| 1244 | uint64_t VisibleOffset = 0; |
| 1245 | DeclContext *DC = dyn_cast<DeclContext>(D); |
| 1246 | if (DC) { |
| 1247 | LexicalOffset = WriteDeclContextLexicalBlock(Context, DC); |
| 1248 | VisibleOffset = WriteDeclContextVisibleBlock(Context, DC); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1251 | // Determine the ID for this declaration |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1252 | serialization::DeclID &IDR = DeclIDs[D]; |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1253 | if (IDR == 0) |
| 1254 | IDR = NextDeclID++; |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1255 | serialization::DeclID ID = IDR; |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1256 | |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1257 | if (ID < FirstDeclID) { |
| 1258 | // We're replacing a decl in a previous file. |
| 1259 | ReplacedDecls.push_back(std::make_pair(ID, Stream.GetCurrentBitNo())); |
| 1260 | } else { |
| 1261 | unsigned Index = ID - FirstDeclID; |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1262 | |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1263 | // Record the offset for this declaration |
| 1264 | if (DeclOffsets.size() == Index) |
| 1265 | DeclOffsets.push_back(Stream.GetCurrentBitNo()); |
| 1266 | else if (DeclOffsets.size() < Index) { |
| 1267 | DeclOffsets.resize(Index+1); |
| 1268 | DeclOffsets[Index] = Stream.GetCurrentBitNo(); |
| 1269 | } |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | // Build and emit a record for this declaration |
| 1273 | Record.clear(); |
Sebastian Redl | 8538e8d | 2010-08-18 23:57:32 +0000 | [diff] [blame] | 1274 | W.Code = (serialization::DeclCode)0; |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1275 | W.AbbrevToUse = 0; |
| 1276 | W.Visit(D); |
| 1277 | if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset); |
| 1278 | |
Daniel Dunbar | 3367198 | 2009-12-03 09:13:36 +0000 | [diff] [blame] | 1279 | if (!W.Code) |
Chris Lattner | 83e7a78 | 2010-04-07 22:58:06 +0000 | [diff] [blame] | 1280 | llvm::report_fatal_error(llvm::StringRef("unexpected declaration kind '") + |
Daniel Dunbar | 3367198 | 2009-12-03 09:13:36 +0000 | [diff] [blame] | 1281 | D->getDeclKindName() + "'"); |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1282 | Stream.EmitRecord(W.Code, Record, W.AbbrevToUse); |
| 1283 | |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1284 | // Flush any expressions that were written as part of this declaration. |
| 1285 | FlushStmts(); |
Douglas Gregor | 7c789c1 | 2010-10-29 22:39:52 +0000 | [diff] [blame] | 1286 | |
| 1287 | // Flush C++ base specifiers, if there are any. |
| 1288 | FlushCXXBaseSpecifiers(); |
| 1289 | |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1290 | // Note "external" declarations so that we can add them to a record in the |
Sebastian Redl | 3397c55 | 2010-08-18 23:56:27 +0000 | [diff] [blame] | 1291 | // AST file later. |
Douglas Gregor | 61d60ee | 2009-10-17 00:13:19 +0000 | [diff] [blame] | 1292 | // |
| 1293 | // FIXME: This should be renamed, the predicate is much more complicated. |
| 1294 | if (isRequiredDecl(D, Context)) |
Sebastian Redl | 0b17c61 | 2010-08-13 00:28:03 +0000 | [diff] [blame] | 1295 | ExternalDefinitions.push_back(ID); |
Chris Lattner | 12b1c76 | 2009-04-27 06:16:06 +0000 | [diff] [blame] | 1296 | } |