2010-08-19 07:57:11 +08:00
|
|
|
//===--- ASTReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===//
|
2009-04-27 13:27:42 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-08-19 07:56:43 +08:00
|
|
|
// This file implements the ASTReader::ReadDeclRecord method, which is the
|
2009-04-27 13:27:42 +08:00
|
|
|
// entrypoint for loading a decl.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-08-19 07:57:17 +08:00
|
|
|
#include "clang/Serialization/ASTReader.h"
|
2009-04-27 13:27:42 +08:00
|
|
|
#include "clang/AST/ASTConsumer.h"
|
|
|
|
#include "clang/AST/ASTContext.h"
|
|
|
|
#include "clang/AST/DeclVisitor.h"
|
|
|
|
#include "clang/AST/DeclGroup.h"
|
2010-05-08 05:43:38 +08:00
|
|
|
#include "clang/AST/DeclCXX.h"
|
|
|
|
#include "clang/AST/DeclTemplate.h"
|
2009-04-27 13:27:42 +08:00
|
|
|
#include "clang/AST/Expr.h"
|
|
|
|
using namespace clang;
|
2010-08-19 07:57:32 +08:00
|
|
|
using namespace clang::serialization;
|
2009-04-27 13:27:42 +08:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Declaration deserialization
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2010-06-30 06:47:00 +08:00
|
|
|
namespace clang {
|
2010-08-19 07:56:48 +08:00
|
|
|
class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
|
2010-08-19 07:56:43 +08:00
|
|
|
ASTReader &Reader;
|
2010-10-05 23:59:54 +08:00
|
|
|
ASTReader::PerFileData &F;
|
2010-07-23 06:43:28 +08:00
|
|
|
llvm::BitstreamCursor &Cursor;
|
2010-08-19 07:57:32 +08:00
|
|
|
const DeclID ThisDeclID;
|
2010-08-19 07:56:43 +08:00
|
|
|
const ASTReader::RecordData &Record;
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned &Idx;
|
2010-08-19 07:57:32 +08:00
|
|
|
TypeID TypeIDForTypeDecl;
|
2009-04-27 13:27:42 +08:00
|
|
|
|
2010-07-23 06:43:28 +08:00
|
|
|
uint64_t GetCurrentCursorOffset();
|
2010-10-05 23:59:54 +08:00
|
|
|
SourceLocation ReadSourceLocation(const ASTReader::RecordData &R,
|
|
|
|
unsigned &I) {
|
|
|
|
return Reader.ReadSourceLocation(F, R, I);
|
|
|
|
}
|
|
|
|
SourceRange ReadSourceRange(const ASTReader::RecordData &R, unsigned &I) {
|
|
|
|
return Reader.ReadSourceRange(F, R, I);
|
|
|
|
}
|
|
|
|
TypeSourceInfo *GetTypeSourceInfo(const ASTReader::RecordData &R,
|
|
|
|
unsigned &I) {
|
|
|
|
return Reader.GetTypeSourceInfo(F, R, I);
|
|
|
|
}
|
2010-10-16 02:21:24 +08:00
|
|
|
void ReadQualifierInfo(QualifierInfo &Info,
|
|
|
|
const ASTReader::RecordData &R, unsigned &I) {
|
|
|
|
Reader.ReadQualifierInfo(F, Info, R, I);
|
|
|
|
}
|
|
|
|
void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
|
|
|
|
const ASTReader::RecordData &R, unsigned &I) {
|
|
|
|
Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
|
|
|
|
}
|
|
|
|
void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
|
|
|
|
const ASTReader::RecordData &R, unsigned &I) {
|
|
|
|
Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
|
|
|
|
}
|
2010-07-23 06:43:28 +08:00
|
|
|
|
2009-04-27 13:27:42 +08:00
|
|
|
public:
|
2010-10-05 23:59:54 +08:00
|
|
|
ASTDeclReader(ASTReader &Reader, ASTReader::PerFileData &F,
|
|
|
|
llvm::BitstreamCursor &Cursor, DeclID thisDeclID,
|
|
|
|
const ASTReader::RecordData &Record, unsigned &Idx)
|
|
|
|
: Reader(Reader), F(F), Cursor(Cursor), ThisDeclID(thisDeclID),
|
|
|
|
Record(Record), Idx(Idx), TypeIDForTypeDecl(0) { }
|
2009-04-27 13:27:42 +08:00
|
|
|
|
2010-07-02 19:55:01 +08:00
|
|
|
void Visit(Decl *D);
|
|
|
|
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitDecl(Decl *D);
|
|
|
|
void VisitTranslationUnitDecl(TranslationUnitDecl *TU);
|
|
|
|
void VisitNamedDecl(NamedDecl *ND);
|
2010-02-22 02:22:14 +08:00
|
|
|
void VisitNamespaceDecl(NamespaceDecl *D);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
|
|
|
|
void VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitTypeDecl(TypeDecl *TD);
|
|
|
|
void VisitTypedefDecl(TypedefDecl *TD);
|
2010-06-30 16:49:30 +08:00
|
|
|
void VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitTagDecl(TagDecl *TD);
|
|
|
|
void VisitEnumDecl(EnumDecl *ED);
|
|
|
|
void VisitRecordDecl(RecordDecl *RD);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitCXXRecordDecl(CXXRecordDecl *D);
|
|
|
|
void VisitClassTemplateSpecializationDecl(
|
|
|
|
ClassTemplateSpecializationDecl *D);
|
|
|
|
void VisitClassTemplatePartialSpecializationDecl(
|
|
|
|
ClassTemplatePartialSpecializationDecl *D);
|
|
|
|
void VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D);
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitValueDecl(ValueDecl *VD);
|
|
|
|
void VisitEnumConstantDecl(EnumConstantDecl *ECD);
|
2010-06-30 16:49:30 +08:00
|
|
|
void VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
|
2009-08-19 09:28:35 +08:00
|
|
|
void VisitDeclaratorDecl(DeclaratorDecl *DD);
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitFunctionDecl(FunctionDecl *FD);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitCXXMethodDecl(CXXMethodDecl *D);
|
|
|
|
void VisitCXXConstructorDecl(CXXConstructorDecl *D);
|
|
|
|
void VisitCXXDestructorDecl(CXXDestructorDecl *D);
|
|
|
|
void VisitCXXConversionDecl(CXXConversionDecl *D);
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitFieldDecl(FieldDecl *FD);
|
|
|
|
void VisitVarDecl(VarDecl *VD);
|
|
|
|
void VisitImplicitParamDecl(ImplicitParamDecl *PD);
|
|
|
|
void VisitParmVarDecl(ParmVarDecl *PD);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
|
|
|
|
void VisitTemplateDecl(TemplateDecl *D);
|
2010-07-30 00:11:51 +08:00
|
|
|
void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitClassTemplateDecl(ClassTemplateDecl *D);
|
2010-06-22 17:55:07 +08:00
|
|
|
void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
|
2010-06-20 22:40:59 +08:00
|
|
|
void VisitUsingDecl(UsingDecl *D);
|
|
|
|
void VisitUsingShadowDecl(UsingShadowDecl *D);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
|
2010-06-05 13:09:32 +08:00
|
|
|
void VisitAccessSpecDecl(AccessSpecDecl *D);
|
2010-06-30 06:47:00 +08:00
|
|
|
void VisitFriendDecl(FriendDecl *D);
|
2010-05-08 05:43:38 +08:00
|
|
|
void VisitFriendTemplateDecl(FriendTemplateDecl *D);
|
|
|
|
void VisitStaticAssertDecl(StaticAssertDecl *D);
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitBlockDecl(BlockDecl *BD);
|
2010-05-08 05:43:38 +08:00
|
|
|
|
2009-04-27 13:27:42 +08:00
|
|
|
std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC);
|
2010-08-04 01:30:10 +08:00
|
|
|
template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
|
2010-05-08 05:43:38 +08:00
|
|
|
|
2010-05-30 15:21:58 +08:00
|
|
|
// FIXME: Reorder according to DeclNodes.td?
|
2009-04-27 13:27:42 +08:00
|
|
|
void VisitObjCMethodDecl(ObjCMethodDecl *D);
|
|
|
|
void VisitObjCContainerDecl(ObjCContainerDecl *D);
|
|
|
|
void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
|
|
|
|
void VisitObjCIvarDecl(ObjCIvarDecl *D);
|
|
|
|
void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
|
|
|
|
void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D);
|
|
|
|
void VisitObjCClassDecl(ObjCClassDecl *D);
|
|
|
|
void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D);
|
|
|
|
void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
|
|
|
|
void VisitObjCImplDecl(ObjCImplDecl *D);
|
|
|
|
void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
|
|
|
|
void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
|
|
|
|
void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
|
|
|
|
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
|
|
|
|
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
uint64_t ASTDeclReader::GetCurrentCursorOffset() {
|
2010-07-23 06:43:28 +08:00
|
|
|
uint64_t Off = 0;
|
|
|
|
for (unsigned I = 0, N = Reader.Chain.size(); I != N; ++I) {
|
2010-08-19 07:56:43 +08:00
|
|
|
ASTReader::PerFileData &F = *Reader.Chain[N - I - 1];
|
2010-07-23 06:43:28 +08:00
|
|
|
if (&Cursor == &F.DeclsCursor) {
|
|
|
|
Off += F.DeclsCursor.GetCurrentBitNo();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Off += F.SizeInBits;
|
|
|
|
}
|
|
|
|
return Off;
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::Visit(Decl *D) {
|
|
|
|
DeclVisitor<ASTDeclReader, void>::Visit(D);
|
2010-07-02 19:55:01 +08:00
|
|
|
|
2010-07-02 23:58:43 +08:00
|
|
|
if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
|
2010-08-11 20:19:30 +08:00
|
|
|
// if we have a fully initialized TypeDecl, we can safely read its type now.
|
|
|
|
TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtr());
|
2010-07-02 23:58:43 +08:00
|
|
|
} else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
|
|
|
|
// FunctionDecl's body was written last after all other Stmts/Exprs.
|
|
|
|
if (Record[Idx++])
|
2010-07-23 06:43:28 +08:00
|
|
|
FD->setLazyBody(GetCurrentCursorOffset());
|
2010-07-02 23:58:43 +08:00
|
|
|
}
|
2010-07-02 19:55:01 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitDecl(Decl *D) {
|
2009-04-27 13:27:42 +08:00
|
|
|
D->setDeclContext(cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setLexicalDeclContext(
|
|
|
|
cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])));
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setLocation(ReadSourceLocation(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
D->setInvalidDecl(Record[Idx++]);
|
2010-10-19 03:20:11 +08:00
|
|
|
if (Record[Idx++]) { // hasAttrs
|
2010-08-19 07:23:40 +08:00
|
|
|
AttrVec Attrs;
|
2010-10-19 03:20:11 +08:00
|
|
|
Reader.ReadAttributes(F, Attrs, Record, Idx);
|
2010-08-19 07:23:40 +08:00
|
|
|
D->setAttrs(Attrs);
|
|
|
|
}
|
2009-04-27 13:27:42 +08:00
|
|
|
D->setImplicit(Record[Idx++]);
|
2009-06-20 07:52:42 +08:00
|
|
|
D->setUsed(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
D->setAccess((AccessSpecifier)Record[Idx++]);
|
2010-10-06 00:15:19 +08:00
|
|
|
D->setPCHLevel(Record[Idx++] + (F.Type <= ASTReader::PCH));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitDecl(TU);
|
2010-05-08 05:43:38 +08:00
|
|
|
TU->setAnonymousNamespace(
|
|
|
|
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitDecl(ND);
|
2009-09-09 23:08:12 +08:00
|
|
|
ND->setDeclName(Reader.ReadDeclarationName(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitNamedDecl(TD);
|
2010-07-02 19:55:01 +08:00
|
|
|
// Delay type reading until after we have fully initialized the decl.
|
2010-08-11 20:19:30 +08:00
|
|
|
TypeIDForTypeDecl = Record[Idx++];
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) {
|
2010-07-02 19:55:01 +08:00
|
|
|
VisitTypeDecl(TD);
|
2010-10-05 23:59:54 +08:00
|
|
|
TD->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitTagDecl(TagDecl *TD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitTypeDecl(TD);
|
2010-08-04 01:30:10 +08:00
|
|
|
VisitRedeclarable(TD);
|
2010-09-09 03:31:22 +08:00
|
|
|
TD->IdentifierNamespace = Record[Idx++];
|
2009-04-27 13:27:42 +08:00
|
|
|
TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
|
|
|
|
TD->setDefinition(Record[Idx++]);
|
2010-02-13 01:40:34 +08:00
|
|
|
TD->setEmbeddedInDeclarator(Record[Idx++]);
|
2010-10-05 23:59:54 +08:00
|
|
|
TD->setRBraceLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
TD->setTagKeywordLoc(ReadSourceLocation(Record, Idx));
|
2010-10-16 02:21:24 +08:00
|
|
|
if (Record[Idx++]) { // hasExtInfo
|
|
|
|
TagDecl::ExtInfo *Info = new (*Reader.getContext()) TagDecl::ExtInfo();
|
|
|
|
ReadQualifierInfo(*Info, Record, Idx);
|
|
|
|
TD->TypedefDeclOrQualifier = Info;
|
|
|
|
} else
|
|
|
|
TD->setTypedefForAnonDecl(
|
|
|
|
cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitTagDecl(ED);
|
2010-10-09 07:50:27 +08:00
|
|
|
if (TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx))
|
|
|
|
ED->setIntegerTypeSourceInfo(TI);
|
|
|
|
else
|
|
|
|
ED->setIntegerType(Reader.GetType(Record[Idx++]));
|
2009-12-09 17:09:27 +08:00
|
|
|
ED->setPromotionType(Reader.GetType(Record[Idx++]));
|
2010-05-06 16:49:23 +08:00
|
|
|
ED->setNumPositiveBits(Record[Idx++]);
|
|
|
|
ED->setNumNegativeBits(Record[Idx++]);
|
2010-10-09 07:50:27 +08:00
|
|
|
ED->IsScoped = Record[Idx++];
|
|
|
|
ED->IsFixed = Record[Idx++];
|
2010-07-06 23:36:48 +08:00
|
|
|
ED->setInstantiationOfMemberEnum(
|
|
|
|
cast_or_null<EnumDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitRecordDecl(RecordDecl *RD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitTagDecl(RD);
|
|
|
|
RD->setHasFlexibleArrayMember(Record[Idx++]);
|
|
|
|
RD->setAnonymousStructOrUnion(Record[Idx++]);
|
2009-07-09 00:37:44 +08:00
|
|
|
RD->setHasObjectMember(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitValueDecl(ValueDecl *VD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitNamedDecl(VD);
|
|
|
|
VD->setType(Reader.GetType(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitValueDecl(ECD);
|
|
|
|
if (Record[Idx++])
|
2010-10-05 23:59:54 +08:00
|
|
|
ECD->setInitExpr(Reader.ReadExpr(F));
|
2009-04-27 13:27:42 +08:00
|
|
|
ECD->setInitVal(Reader.ReadAPSInt(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) {
|
2009-08-19 09:28:35 +08:00
|
|
|
VisitValueDecl(DD);
|
2010-10-16 02:21:24 +08:00
|
|
|
if (Record[Idx++]) { // hasExtInfo
|
|
|
|
DeclaratorDecl::ExtInfo *Info
|
|
|
|
= new (*Reader.getContext()) DeclaratorDecl::ExtInfo();
|
|
|
|
ReadQualifierInfo(*Info, Record, Idx);
|
|
|
|
Info->TInfo = GetTypeSourceInfo(Record, Idx);
|
|
|
|
DD->DeclInfo = Info;
|
|
|
|
} else
|
|
|
|
DD->DeclInfo = GetTypeSourceInfo(Record, Idx);
|
2009-08-19 09:28:35 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
2009-08-19 09:28:35 +08:00
|
|
|
VisitDeclaratorDecl(FD);
|
2010-09-09 03:31:22 +08:00
|
|
|
VisitRedeclarable(FD);
|
2010-05-08 05:43:38 +08:00
|
|
|
|
2010-10-16 02:21:24 +08:00
|
|
|
ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName(), Record, Idx);
|
2010-07-05 18:38:01 +08:00
|
|
|
FD->IdentifierNamespace = Record[Idx++];
|
2010-06-22 17:55:07 +08:00
|
|
|
switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
|
2010-06-28 17:31:34 +08:00
|
|
|
default: assert(false && "Unhandled TemplatedKind!");
|
|
|
|
break;
|
2010-06-22 17:55:07 +08:00
|
|
|
case FunctionDecl::TK_NonTemplate:
|
|
|
|
break;
|
|
|
|
case FunctionDecl::TK_FunctionTemplate:
|
|
|
|
FD->setDescribedFunctionTemplate(
|
|
|
|
cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
break;
|
|
|
|
case FunctionDecl::TK_MemberSpecialization: {
|
|
|
|
FunctionDecl *InstFD = cast<FunctionDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
|
2010-10-05 23:59:54 +08:00
|
|
|
SourceLocation POI = ReadSourceLocation(Record, Idx);
|
2010-09-09 03:31:22 +08:00
|
|
|
FD->setInstantiationOfMemberFunction(*Reader.getContext(), InstFD, TSK);
|
2010-06-22 17:55:07 +08:00
|
|
|
FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FunctionDecl::TK_FunctionTemplateSpecialization: {
|
|
|
|
FunctionTemplateDecl *Template
|
|
|
|
= cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
|
|
|
|
|
|
|
|
// Template arguments.
|
|
|
|
llvm::SmallVector<TemplateArgument, 8> TemplArgs;
|
2010-10-05 23:59:54 +08:00
|
|
|
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
|
2010-06-22 17:55:07 +08:00
|
|
|
|
|
|
|
// Template args as written.
|
|
|
|
llvm::SmallVector<TemplateArgumentLoc, 8> TemplArgLocs;
|
|
|
|
SourceLocation LAngleLoc, RAngleLoc;
|
2010-07-02 19:55:40 +08:00
|
|
|
if (Record[Idx++]) { // TemplateArgumentsAsWritten != 0
|
|
|
|
unsigned NumTemplateArgLocs = Record[Idx++];
|
|
|
|
TemplArgLocs.reserve(NumTemplateArgLocs);
|
|
|
|
for (unsigned i=0; i != NumTemplateArgLocs; ++i)
|
2010-07-23 06:43:28 +08:00
|
|
|
TemplArgLocs.push_back(
|
2010-10-05 23:59:54 +08:00
|
|
|
Reader.ReadTemplateArgumentLoc(F, Record, Idx));
|
2010-07-02 19:55:40 +08:00
|
|
|
|
2010-10-05 23:59:54 +08:00
|
|
|
LAngleLoc = ReadSourceLocation(Record, Idx);
|
|
|
|
RAngleLoc = ReadSourceLocation(Record, Idx);
|
2010-06-22 17:55:07 +08:00
|
|
|
}
|
2010-07-05 18:37:55 +08:00
|
|
|
|
2010-10-05 23:59:54 +08:00
|
|
|
SourceLocation POI = ReadSourceLocation(Record, Idx);
|
2010-06-22 17:55:07 +08:00
|
|
|
|
2010-09-09 19:28:23 +08:00
|
|
|
ASTContext &C = *Reader.getContext();
|
|
|
|
TemplateArgumentList *TemplArgList
|
|
|
|
= new (C) TemplateArgumentList(C, TemplArgs.data(), TemplArgs.size());
|
|
|
|
TemplateArgumentListInfo *TemplArgsInfo
|
|
|
|
= new (C) TemplateArgumentListInfo(LAngleLoc, RAngleLoc);
|
|
|
|
for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i)
|
|
|
|
TemplArgsInfo->addArgument(TemplArgLocs[i]);
|
|
|
|
FunctionTemplateSpecializationInfo *FTInfo
|
|
|
|
= FunctionTemplateSpecializationInfo::Create(C, FD, Template, TSK,
|
|
|
|
TemplArgList,
|
|
|
|
TemplArgsInfo, POI);
|
|
|
|
FD->TemplateOrSpecialization = FTInfo;
|
2010-09-09 03:31:22 +08:00
|
|
|
|
2010-09-09 19:28:23 +08:00
|
|
|
if (FD->isCanonicalDecl()) { // if canonical add to template's set.
|
2010-09-13 19:45:48 +08:00
|
|
|
// The template that contains the specializations set. It's not safe to
|
|
|
|
// use getCanonicalDecl on Template since it may still be initializing.
|
|
|
|
FunctionTemplateDecl *CanonTemplate
|
|
|
|
= cast<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-09-09 19:28:23 +08:00
|
|
|
// Get the InsertPos by FindNodeOrInsertPos() instead of calling
|
|
|
|
// InsertNode(FTInfo) directly to avoid the getASTContext() call in
|
|
|
|
// FunctionTemplateSpecializationInfo's Profile().
|
|
|
|
// We avoid getASTContext because a decl in the parent hierarchy may
|
|
|
|
// be initializing.
|
2010-09-09 03:31:22 +08:00
|
|
|
llvm::FoldingSetNodeID ID;
|
|
|
|
FunctionTemplateSpecializationInfo::Profile(ID, TemplArgs.data(),
|
|
|
|
TemplArgs.size(), C);
|
|
|
|
void *InsertPos = 0;
|
2010-09-13 19:45:48 +08:00
|
|
|
CanonTemplate->getSpecializations().FindNodeOrInsertPos(ID, InsertPos);
|
2010-09-09 19:28:23 +08:00
|
|
|
assert(InsertPos && "Another specialization already inserted!");
|
2010-09-13 19:45:48 +08:00
|
|
|
CanonTemplate->getSpecializations().InsertNode(FTInfo, InsertPos);
|
2010-09-09 03:31:22 +08:00
|
|
|
}
|
2010-06-28 17:31:34 +08:00
|
|
|
break;
|
2010-06-22 17:55:07 +08:00
|
|
|
}
|
|
|
|
case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
|
|
|
|
// Templates.
|
|
|
|
UnresolvedSet<8> TemplDecls;
|
|
|
|
unsigned NumTemplates = Record[Idx++];
|
|
|
|
while (NumTemplates--)
|
|
|
|
TemplDecls.addDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
|
|
|
|
// Templates args.
|
|
|
|
TemplateArgumentListInfo TemplArgs;
|
|
|
|
unsigned NumArgs = Record[Idx++];
|
|
|
|
while (NumArgs--)
|
2010-10-05 23:59:54 +08:00
|
|
|
TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx));
|
|
|
|
TemplArgs.setLAngleLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
TemplArgs.setRAngleLoc(ReadSourceLocation(Record, Idx));
|
2010-06-22 17:55:07 +08:00
|
|
|
|
|
|
|
FD->setDependentTemplateSpecialization(*Reader.getContext(),
|
|
|
|
TemplDecls, TemplArgs);
|
2010-06-28 17:31:34 +08:00
|
|
|
break;
|
2010-06-22 17:55:07 +08:00
|
|
|
}
|
|
|
|
}
|
2010-07-02 19:55:40 +08:00
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
// FunctionDecl's body is handled last at ASTDeclReader::Visit,
|
2010-07-02 23:58:43 +08:00
|
|
|
// after everything else is read.
|
|
|
|
|
2010-08-26 11:08:43 +08:00
|
|
|
FD->setStorageClass((StorageClass)Record[Idx++]);
|
|
|
|
FD->setStorageClassAsWritten((StorageClass)Record[Idx++]);
|
2010-07-02 19:55:40 +08:00
|
|
|
FD->setInlineSpecified(Record[Idx++]);
|
|
|
|
FD->setVirtualAsWritten(Record[Idx++]);
|
|
|
|
FD->setPure(Record[Idx++]);
|
|
|
|
FD->setHasInheritedPrototype(Record[Idx++]);
|
|
|
|
FD->setHasWrittenPrototype(Record[Idx++]);
|
|
|
|
FD->setDeleted(Record[Idx++]);
|
|
|
|
FD->setTrivial(Record[Idx++]);
|
|
|
|
FD->setHasImplicitReturnZero(Record[Idx++]);
|
2010-10-05 23:59:54 +08:00
|
|
|
FD->setLocEnd(ReadSourceLocation(Record, Idx));
|
2010-07-02 19:55:40 +08:00
|
|
|
|
2010-05-08 05:43:38 +08:00
|
|
|
// Read in the parameters.
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned NumParams = Record[Idx++];
|
|
|
|
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
|
|
|
Params.reserve(NumParams);
|
|
|
|
for (unsigned I = 0; I != NumParams; ++I)
|
|
|
|
Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-09-09 03:31:22 +08:00
|
|
|
FD->setParams(*Reader.getContext(), Params.data(), NumParams);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitNamedDecl(MD);
|
|
|
|
if (Record[Idx++]) {
|
|
|
|
// In practice, this won't be executed (since method definitions
|
|
|
|
// don't occur in header files).
|
2010-10-05 23:59:54 +08:00
|
|
|
MD->setBody(Reader.ReadStmt(F));
|
2009-04-27 13:27:42 +08:00
|
|
|
MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
MD->setInstanceMethod(Record[Idx++]);
|
|
|
|
MD->setVariadic(Record[Idx++]);
|
|
|
|
MD->setSynthesized(Record[Idx++]);
|
2010-07-23 02:24:20 +08:00
|
|
|
MD->setDefined(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
|
|
|
|
MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
|
2010-04-09 05:29:11 +08:00
|
|
|
MD->setNumSelectorArgs(unsigned(Record[Idx++]));
|
2009-04-27 13:27:42 +08:00
|
|
|
MD->setResultType(Reader.GetType(Record[Idx++]));
|
2010-10-05 23:59:54 +08:00
|
|
|
MD->setResultTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
|
|
|
|
MD->setEndLoc(ReadSourceLocation(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned NumParams = Record[Idx++];
|
|
|
|
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
|
|
|
Params.reserve(NumParams);
|
|
|
|
for (unsigned I = 0; I != NumParams; ++I)
|
|
|
|
Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-04-09 23:40:42 +08:00
|
|
|
MD->setMethodParams(*Reader.getContext(), Params.data(), NumParams,
|
|
|
|
NumParams);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitNamedDecl(CD);
|
2010-10-05 23:59:54 +08:00
|
|
|
SourceLocation A = ReadSourceLocation(Record, Idx);
|
|
|
|
SourceLocation B = ReadSourceLocation(Record, Idx);
|
2010-01-07 09:20:12 +08:00
|
|
|
CD->setAtEndRange(SourceRange(A, B));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitObjCContainerDecl(ID);
|
2010-08-11 20:19:30 +08:00
|
|
|
ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
|
2009-04-27 13:27:42 +08:00
|
|
|
ID->setSuperClass(cast_or_null<ObjCInterfaceDecl>
|
|
|
|
(Reader.GetDecl(Record[Idx++])));
|
2010-09-01 09:21:15 +08:00
|
|
|
|
|
|
|
// Read the directly referenced protocols and their SourceLocations.
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned NumProtocols = Record[Idx++];
|
|
|
|
llvm::SmallVector<ObjCProtocolDecl *, 16> Protocols;
|
|
|
|
Protocols.reserve(NumProtocols);
|
|
|
|
for (unsigned I = 0; I != NumProtocols; ++I)
|
|
|
|
Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-01-16 23:02:53 +08:00
|
|
|
llvm::SmallVector<SourceLocation, 16> ProtoLocs;
|
|
|
|
ProtoLocs.reserve(NumProtocols);
|
|
|
|
for (unsigned I = 0; I != NumProtocols; ++I)
|
2010-10-05 23:59:54 +08:00
|
|
|
ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
|
2010-01-16 23:02:53 +08:00
|
|
|
ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(),
|
|
|
|
*Reader.getContext());
|
2010-09-01 09:21:15 +08:00
|
|
|
|
|
|
|
// Read the transitive closure of protocols referenced by this class.
|
|
|
|
NumProtocols = Record[Idx++];
|
|
|
|
Protocols.clear();
|
|
|
|
Protocols.reserve(NumProtocols);
|
|
|
|
for (unsigned I = 0; I != NumProtocols; ++I)
|
|
|
|
Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
ID->AllReferencedProtocols.set(Protocols.data(), NumProtocols,
|
|
|
|
*Reader.getContext());
|
|
|
|
|
|
|
|
// Read the ivars.
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned NumIvars = Record[Idx++];
|
|
|
|
llvm::SmallVector<ObjCIvarDecl *, 16> IVars;
|
|
|
|
IVars.reserve(NumIvars);
|
|
|
|
for (unsigned I = 0; I != NumIvars; ++I)
|
|
|
|
IVars.push_back(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
ID->setCategoryList(
|
|
|
|
cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-08-21 05:21:08 +08:00
|
|
|
// We will rebuild this list lazily.
|
|
|
|
ID->setIvarList(0);
|
2010-08-11 20:19:30 +08:00
|
|
|
ID->setForwardDecl(Record[Idx++]);
|
|
|
|
ID->setImplicitInterfaceDecl(Record[Idx++]);
|
2010-10-05 23:59:54 +08:00
|
|
|
ID->setClassLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
ID->setSuperClassLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
ID->setLocEnd(ReadSourceLocation(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitFieldDecl(IVD);
|
|
|
|
IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]);
|
2010-08-21 05:21:08 +08:00
|
|
|
// This field will be built lazily.
|
|
|
|
IVD->setNextIvar(0);
|
2010-07-18 02:35:47 +08:00
|
|
|
bool synth = Record[Idx++];
|
|
|
|
IVD->setSynthesize(synth);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitObjCContainerDecl(PD);
|
|
|
|
PD->setForwardDecl(Record[Idx++]);
|
2010-10-05 23:59:54 +08:00
|
|
|
PD->setLocEnd(ReadSourceLocation(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned NumProtoRefs = Record[Idx++];
|
|
|
|
llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
|
|
|
|
ProtoRefs.reserve(NumProtoRefs);
|
|
|
|
for (unsigned I = 0; I != NumProtoRefs; ++I)
|
|
|
|
ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-01-16 23:02:53 +08:00
|
|
|
llvm::SmallVector<SourceLocation, 16> ProtoLocs;
|
|
|
|
ProtoLocs.reserve(NumProtoRefs);
|
|
|
|
for (unsigned I = 0; I != NumProtoRefs; ++I)
|
2010-10-05 23:59:54 +08:00
|
|
|
ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
|
2010-01-16 23:02:53 +08:00
|
|
|
PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
|
|
|
|
*Reader.getContext());
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitFieldDecl(FD);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitDecl(CD);
|
|
|
|
unsigned NumClassRefs = Record[Idx++];
|
|
|
|
llvm::SmallVector<ObjCInterfaceDecl *, 16> ClassRefs;
|
|
|
|
ClassRefs.reserve(NumClassRefs);
|
|
|
|
for (unsigned I = 0; I != NumClassRefs; ++I)
|
|
|
|
ClassRefs.push_back(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-11-18 08:28:11 +08:00
|
|
|
llvm::SmallVector<SourceLocation, 16> SLocs;
|
|
|
|
SLocs.reserve(NumClassRefs);
|
|
|
|
for (unsigned I = 0; I != NumClassRefs; ++I)
|
2010-10-05 23:59:54 +08:00
|
|
|
SLocs.push_back(ReadSourceLocation(Record, Idx));
|
2009-11-18 08:28:11 +08:00
|
|
|
CD->setClassList(*Reader.getContext(), ClassRefs.data(), SLocs.data(),
|
|
|
|
NumClassRefs);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitDecl(FPD);
|
|
|
|
unsigned NumProtoRefs = Record[Idx++];
|
|
|
|
llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
|
|
|
|
ProtoRefs.reserve(NumProtoRefs);
|
|
|
|
for (unsigned I = 0; I != NumProtoRefs; ++I)
|
|
|
|
ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-01-16 23:02:53 +08:00
|
|
|
llvm::SmallVector<SourceLocation, 16> ProtoLocs;
|
|
|
|
ProtoLocs.reserve(NumProtoRefs);
|
|
|
|
for (unsigned I = 0; I != NumProtoRefs; ++I)
|
2010-10-05 23:59:54 +08:00
|
|
|
ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
|
2010-01-16 23:02:53 +08:00
|
|
|
FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
|
|
|
|
*Reader.getContext());
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitObjCContainerDecl(CD);
|
|
|
|
CD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
unsigned NumProtoRefs = Record[Idx++];
|
|
|
|
llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
|
|
|
|
ProtoRefs.reserve(NumProtoRefs);
|
|
|
|
for (unsigned I = 0; I != NumProtoRefs; ++I)
|
|
|
|
ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-01-16 23:02:53 +08:00
|
|
|
llvm::SmallVector<SourceLocation, 16> ProtoLocs;
|
|
|
|
ProtoLocs.reserve(NumProtoRefs);
|
|
|
|
for (unsigned I = 0; I != NumProtoRefs; ++I)
|
2010-10-05 23:59:54 +08:00
|
|
|
ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
|
2010-01-16 23:02:53 +08:00
|
|
|
CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
|
|
|
|
*Reader.getContext());
|
2009-04-27 13:27:42 +08:00
|
|
|
CD->setNextClassCategory(cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-08-24 02:51:39 +08:00
|
|
|
CD->setHasSynthBitfield(Record[Idx++]);
|
2010-10-05 23:59:54 +08:00
|
|
|
CD->setAtLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
CD->setCategoryNameLoc(ReadSourceLocation(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitNamedDecl(CAD);
|
|
|
|
CAD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitNamedDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setAtLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
D->setType(GetTypeSourceInfo(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
// FIXME: stable encoding
|
|
|
|
D->setPropertyAttributes(
|
|
|
|
(ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
|
2010-06-23 07:20:40 +08:00
|
|
|
D->setPropertyAttributesAsWritten(
|
|
|
|
(ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
// FIXME: stable encoding
|
|
|
|
D->setPropertyImplementation(
|
|
|
|
(ObjCPropertyDecl::PropertyControl)Record[Idx++]);
|
|
|
|
D->setGetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector());
|
|
|
|
D->setSetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector());
|
|
|
|
D->setGetterMethodDecl(
|
|
|
|
cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setSetterMethodDecl(
|
|
|
|
cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setPropertyIvarDecl(
|
|
|
|
cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) {
|
2009-07-28 03:04:32 +08:00
|
|
|
VisitObjCContainerDecl(D);
|
2009-04-27 13:27:42 +08:00
|
|
|
D->setClassInterface(
|
|
|
|
cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitObjCImplDecl(D);
|
|
|
|
D->setIdentifier(Reader.GetIdentifierInfo(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitObjCImplDecl(D);
|
|
|
|
D->setSuperClass(
|
|
|
|
cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-08-09 18:54:20 +08:00
|
|
|
llvm::tie(D->IvarInitializers, D->NumIvarInitializers)
|
2010-10-05 23:59:54 +08:00
|
|
|
= Reader.ReadCXXBaseOrMemberInitializers(F, Record, Idx);
|
2010-08-24 02:51:39 +08:00
|
|
|
D->setHasSynthBitfield(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setAtLoc(ReadSourceLocation(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
D->setPropertyDecl(
|
|
|
|
cast_or_null<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setPropertyIvarDecl(
|
|
|
|
cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setGetterCXXConstructor(Reader.ReadExpr(F));
|
|
|
|
D->setSetterCXXAssignment(Reader.ReadExpr(F));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) {
|
2009-08-19 09:28:35 +08:00
|
|
|
VisitDeclaratorDecl(FD);
|
2009-04-27 13:27:42 +08:00
|
|
|
FD->setMutable(Record[Idx++]);
|
|
|
|
if (Record[Idx++])
|
2010-10-05 23:59:54 +08:00
|
|
|
FD->setBitWidth(Reader.ReadExpr(F));
|
2010-07-05 05:44:35 +08:00
|
|
|
if (!FD->getDeclName()) {
|
|
|
|
FieldDecl *Tmpl = cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
if (Tmpl)
|
|
|
|
Reader.getContext()->setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
|
|
|
|
}
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitVarDecl(VarDecl *VD) {
|
2009-08-19 09:28:35 +08:00
|
|
|
VisitDeclaratorDecl(VD);
|
2010-09-09 03:31:22 +08:00
|
|
|
VisitRedeclarable(VD);
|
2010-08-26 11:08:43 +08:00
|
|
|
VD->setStorageClass((StorageClass)Record[Idx++]);
|
|
|
|
VD->setStorageClassAsWritten((StorageClass)Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
VD->setThreadSpecified(Record[Idx++]);
|
|
|
|
VD->setCXXDirectInitializer(Record[Idx++]);
|
2010-05-04 02:51:14 +08:00
|
|
|
VD->setExceptionVariable(Record[Idx++]);
|
2010-05-15 14:01:05 +08:00
|
|
|
VD->setNRVOVariable(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
if (Record[Idx++])
|
2010-10-05 23:59:54 +08:00
|
|
|
VD->setInit(Reader.ReadExpr(F));
|
2010-07-05 05:44:00 +08:00
|
|
|
|
|
|
|
if (Record[Idx++]) { // HasMemberSpecializationInfo.
|
|
|
|
VarDecl *Tmpl = cast<VarDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
|
2010-10-05 23:59:54 +08:00
|
|
|
SourceLocation POI = ReadSourceLocation(Record, Idx);
|
2010-07-05 05:44:00 +08:00
|
|
|
Reader.getContext()->setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
|
|
|
|
}
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitVarDecl(PD);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitVarDecl(PD);
|
|
|
|
PD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
|
2010-03-13 02:31:32 +08:00
|
|
|
PD->setHasInheritedDefaultArg(Record[Idx++]);
|
2010-07-05 05:44:07 +08:00
|
|
|
if (Record[Idx++]) // hasUninstantiatedDefaultArg.
|
2010-10-05 23:59:54 +08:00
|
|
|
PD->setUninstantiatedDefaultArg(Reader.ReadExpr(F));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitDecl(AD);
|
2010-10-05 23:59:54 +08:00
|
|
|
AD->setAsmString(cast<StringLiteral>(Reader.ReadExpr(F)));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) {
|
2009-04-27 13:27:42 +08:00
|
|
|
VisitDecl(BD);
|
2010-10-05 23:59:54 +08:00
|
|
|
BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F)));
|
|
|
|
BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned NumParams = Record[Idx++];
|
|
|
|
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
|
|
|
Params.reserve(NumParams);
|
|
|
|
for (unsigned I = 0; I != NumParams; ++I)
|
|
|
|
Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-02-11 09:19:42 +08:00
|
|
|
BD->setParams(Params.data(), NumParams);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitDecl(D);
|
|
|
|
D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]);
|
|
|
|
D->setHasBraces(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitNamedDecl(D);
|
2010-10-06 04:41:58 +08:00
|
|
|
D->IsInline = Record[Idx++];
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setLBracLoc(ReadSourceLocation(Record, Idx));
|
|
|
|
D->setRBracLoc(ReadSourceLocation(Record, Idx));
|
2010-05-08 05:43:38 +08:00
|
|
|
D->setNextNamespace(
|
|
|
|
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
|
|
|
|
bool IsOriginal = Record[Idx++];
|
2010-07-03 15:57:53 +08:00
|
|
|
D->OrigOrAnonNamespace.setInt(IsOriginal);
|
|
|
|
D->OrigOrAnonNamespace.setPointer(
|
2010-05-08 05:43:38 +08:00
|
|
|
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitNamedDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->NamespaceLoc = ReadSourceLocation(Record, Idx);
|
|
|
|
D->setQualifierRange(ReadSourceRange(Record, Idx));
|
2010-05-08 05:43:38 +08:00
|
|
|
D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
2010-10-05 23:59:54 +08:00
|
|
|
D->IdentLoc = ReadSourceLocation(Record, Idx);
|
2010-09-01 08:08:19 +08:00
|
|
|
D->Namespace = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitUsingDecl(UsingDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitNamedDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setUsingLocation(ReadSourceLocation(Record, Idx));
|
|
|
|
D->setNestedNameRange(ReadSourceRange(Record, Idx));
|
2010-05-08 05:43:38 +08:00
|
|
|
D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx));
|
2010-10-16 02:21:24 +08:00
|
|
|
ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx);
|
2010-05-08 05:43:38 +08:00
|
|
|
|
|
|
|
// FIXME: It would probably be more efficient to read these into a vector
|
|
|
|
// and then re-cosntruct the shadow decl set over that vector since it
|
|
|
|
// would avoid existence checks.
|
|
|
|
unsigned NumShadows = Record[Idx++];
|
|
|
|
for(unsigned I = 0; I != NumShadows; ++I) {
|
2010-07-08 21:09:41 +08:00
|
|
|
// Avoid invariant checking of UsingDecl::addShadowDecl, the decl may still
|
|
|
|
// be initializing.
|
|
|
|
D->Shadows.insert(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
D->setTypeName(Record[Idx++]);
|
2010-07-05 05:44:35 +08:00
|
|
|
NamedDecl *Pattern = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
if (Pattern)
|
|
|
|
Reader.getContext()->setInstantiatedFromUsingDecl(D, Pattern);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitNamedDecl(D);
|
|
|
|
D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-07-05 05:44:35 +08:00
|
|
|
UsingShadowDecl *Pattern
|
|
|
|
= cast_or_null<UsingShadowDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
if (Pattern)
|
|
|
|
Reader.getContext()->setInstantiatedFromUsingShadowDecl(D, Pattern);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitNamedDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->UsingLoc = ReadSourceLocation(Record, Idx);
|
|
|
|
D->NamespaceLoc = ReadSourceLocation(Record, Idx);
|
|
|
|
D->QualifierRange = ReadSourceRange(Record, Idx);
|
2010-09-01 11:07:18 +08:00
|
|
|
D->Qualifier = Reader.ReadNestedNameSpecifier(Record, Idx);
|
|
|
|
D->NominatedNamespace = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
D->CommonAncestor = cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++]));
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitValueDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setTargetNestedNameRange(ReadSourceRange(Record, Idx));
|
|
|
|
D->setUsingLoc(ReadSourceLocation(Record, Idx));
|
2010-05-08 05:43:38 +08:00
|
|
|
D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
2010-10-16 02:21:24 +08:00
|
|
|
ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitUnresolvedUsingTypenameDecl(
|
2010-05-08 05:43:38 +08:00
|
|
|
UnresolvedUsingTypenameDecl *D) {
|
|
|
|
VisitTypeDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->TargetNestedNameRange = ReadSourceRange(Record, Idx);
|
|
|
|
D->UsingLocation = ReadSourceLocation(Record, Idx);
|
|
|
|
D->TypenameLocation = ReadSourceLocation(Record, Idx);
|
2010-09-02 03:52:22 +08:00
|
|
|
D->TargetNestedNameSpecifier = Reader.ReadNestedNameSpecifier(Record, Idx);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
|
2010-07-02 19:55:32 +08:00
|
|
|
ASTContext &C = *Reader.getContext();
|
|
|
|
|
2010-07-06 23:36:58 +08:00
|
|
|
// We need to allocate the DefinitionData struct ahead of VisitRecordDecl
|
|
|
|
// so that the other CXXRecordDecls can get a pointer even when the owner
|
|
|
|
// is still initializing.
|
|
|
|
enum DataOwnership { Data_NoDefData, Data_Owner, Data_NotOwner };
|
2010-10-21 00:22:49 +08:00
|
|
|
DataOwnership DefOwnership = (DataOwnership)Record[Idx++];
|
|
|
|
switch (DefOwnership) {
|
2010-07-06 23:36:58 +08:00
|
|
|
default:
|
2010-08-19 07:56:48 +08:00
|
|
|
assert(0 && "Out of sync with ASTDeclWriter or messed up reading");
|
2010-07-06 23:36:58 +08:00
|
|
|
case Data_NoDefData:
|
|
|
|
break;
|
|
|
|
case Data_Owner:
|
|
|
|
D->DefinitionData = new (C) struct CXXRecordDecl::DefinitionData(D);
|
|
|
|
break;
|
|
|
|
case Data_NotOwner:
|
|
|
|
D->DefinitionData
|
|
|
|
= cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++]))->DefinitionData;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
VisitRecordDecl(D);
|
|
|
|
|
2010-10-21 00:22:49 +08:00
|
|
|
// Spread the DefinitionData pointer if it's the definition (it may have
|
|
|
|
// come from a chained PCH and earlier redeclarations don't know it), or
|
|
|
|
// if it just acquired a pointer that it's not supposed to have (a definition
|
|
|
|
// from a chained PCH updated it).
|
|
|
|
if (D->DefinitionData && DefOwnership != Data_NotOwner) {
|
2010-10-20 08:11:15 +08:00
|
|
|
llvm::SmallPtrSet<CXXRecordDecl *, 16> PrevRedecls;
|
|
|
|
PrevRedecls.insert(D);
|
|
|
|
CXXRecordDecl *Redecl = cast<CXXRecordDecl>(D->RedeclLink.getNext());
|
|
|
|
while (!PrevRedecls.count(Redecl)) {
|
|
|
|
PrevRedecls.insert(Redecl);
|
|
|
|
assert((!Redecl->DefinitionData ||
|
|
|
|
Redecl->DefinitionData == D->DefinitionData) &&
|
|
|
|
"Multiple definitions in the redeclaration chain ?");
|
|
|
|
Redecl->DefinitionData = D->DefinitionData;
|
|
|
|
Redecl = cast<CXXRecordDecl>(Redecl->RedeclLink.getNext());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-21 00:22:49 +08:00
|
|
|
if (DefOwnership == Data_Owner) {
|
2010-07-06 23:36:58 +08:00
|
|
|
assert(D->DefinitionData);
|
|
|
|
struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData;
|
|
|
|
|
|
|
|
Data.UserDeclaredConstructor = Record[Idx++];
|
|
|
|
Data.UserDeclaredCopyConstructor = Record[Idx++];
|
|
|
|
Data.UserDeclaredCopyAssignment = Record[Idx++];
|
|
|
|
Data.UserDeclaredDestructor = Record[Idx++];
|
|
|
|
Data.Aggregate = Record[Idx++];
|
|
|
|
Data.PlainOldData = Record[Idx++];
|
|
|
|
Data.Empty = Record[Idx++];
|
|
|
|
Data.Polymorphic = Record[Idx++];
|
|
|
|
Data.Abstract = Record[Idx++];
|
|
|
|
Data.HasTrivialConstructor = Record[Idx++];
|
|
|
|
Data.HasTrivialCopyConstructor = Record[Idx++];
|
|
|
|
Data.HasTrivialCopyAssignment = Record[Idx++];
|
|
|
|
Data.HasTrivialDestructor = Record[Idx++];
|
|
|
|
Data.ComputedVisibleConversions = Record[Idx++];
|
|
|
|
Data.DeclaredDefaultConstructor = Record[Idx++];
|
|
|
|
Data.DeclaredCopyConstructor = Record[Idx++];
|
|
|
|
Data.DeclaredCopyAssignment = Record[Idx++];
|
|
|
|
Data.DeclaredDestructor = Record[Idx++];
|
|
|
|
|
|
|
|
// setBases() is unsuitable since it may try to iterate the bases of an
|
2010-07-27 00:56:01 +08:00
|
|
|
// uninitialized base.
|
2010-07-06 23:36:58 +08:00
|
|
|
Data.NumBases = Record[Idx++];
|
|
|
|
Data.Bases = new(C) CXXBaseSpecifier [Data.NumBases];
|
|
|
|
for (unsigned i = 0; i != Data.NumBases; ++i)
|
2010-10-05 23:59:54 +08:00
|
|
|
Data.Bases[i] = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
|
2010-07-06 23:36:58 +08:00
|
|
|
|
|
|
|
// FIXME: Make VBases lazily computed when needed to avoid storing them.
|
|
|
|
Data.NumVBases = Record[Idx++];
|
|
|
|
Data.VBases = new(C) CXXBaseSpecifier [Data.NumVBases];
|
|
|
|
for (unsigned i = 0; i != Data.NumVBases; ++i)
|
2010-10-05 23:59:54 +08:00
|
|
|
Data.VBases[i] = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
|
2010-07-06 23:36:58 +08:00
|
|
|
|
|
|
|
Reader.ReadUnresolvedSet(Data.Conversions, Record, Idx);
|
|
|
|
Reader.ReadUnresolvedSet(Data.VisibleConversions, Record, Idx);
|
|
|
|
assert(Data.Definition && "Data.Definition should be already set!");
|
|
|
|
Data.FirstFriend
|
|
|
|
= cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-07-02 19:55:32 +08:00
|
|
|
}
|
|
|
|
|
2010-06-20 03:29:09 +08:00
|
|
|
enum CXXRecKind {
|
|
|
|
CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
|
|
|
|
};
|
|
|
|
switch ((CXXRecKind)Record[Idx++]) {
|
|
|
|
default:
|
2010-08-19 07:56:48 +08:00
|
|
|
assert(false && "Out of sync with ASTDeclWriter::VisitCXXRecordDecl?");
|
2010-06-20 03:29:09 +08:00
|
|
|
case CXXRecNotTemplate:
|
|
|
|
break;
|
|
|
|
case CXXRecTemplate:
|
2010-09-13 19:45:25 +08:00
|
|
|
D->TemplateOrInstantiation
|
|
|
|
= cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-06-20 03:29:09 +08:00
|
|
|
break;
|
|
|
|
case CXXRecMemberSpecialization: {
|
|
|
|
CXXRecordDecl *RD = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
|
2010-10-05 23:59:54 +08:00
|
|
|
SourceLocation POI = ReadSourceLocation(Record, Idx);
|
2010-09-13 19:45:25 +08:00
|
|
|
MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK);
|
|
|
|
MSI->setPointOfInstantiation(POI);
|
|
|
|
D->TemplateOrInstantiation = MSI;
|
2010-06-20 03:29:09 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-10-15 04:14:38 +08:00
|
|
|
|
|
|
|
// Load the key function to avoid deserializing every method so we can
|
|
|
|
// compute it.
|
|
|
|
if (D->IsDefinition) {
|
|
|
|
CXXMethodDecl *Key
|
|
|
|
= cast_or_null<CXXMethodDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
if (Key)
|
|
|
|
C.KeyFunctions[D] = Key;
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitFunctionDecl(D);
|
2010-07-05 05:44:35 +08:00
|
|
|
unsigned NumOverridenMethods = Record[Idx++];
|
|
|
|
while (NumOverridenMethods--) {
|
|
|
|
CXXMethodDecl *MD = cast<CXXMethodDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
// Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
|
|
|
|
// MD may be initializing.
|
|
|
|
Reader.getContext()->addOverriddenMethod(D, MD);
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitCXXMethodDecl(D);
|
2010-07-02 23:58:43 +08:00
|
|
|
|
|
|
|
D->IsExplicitSpecified = Record[Idx++];
|
|
|
|
D->ImplicitlyDefined = Record[Idx++];
|
2010-08-09 18:54:12 +08:00
|
|
|
llvm::tie(D->BaseOrMemberInitializers, D->NumBaseOrMemberInitializers)
|
2010-10-05 23:59:54 +08:00
|
|
|
= Reader.ReadCXXBaseOrMemberInitializers(F, Record, Idx);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitCXXMethodDecl(D);
|
2010-07-02 23:58:43 +08:00
|
|
|
|
|
|
|
D->ImplicitlyDefined = Record[Idx++];
|
|
|
|
D->OperatorDelete = cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitCXXMethodDecl(D);
|
2010-07-02 23:58:43 +08:00
|
|
|
D->IsExplicitSpecified = Record[Idx++];
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) {
|
2010-06-05 13:09:32 +08:00
|
|
|
VisitDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->setColonLoc(ReadSourceLocation(Record, Idx));
|
2010-06-05 13:09:32 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitFriendDecl(FriendDecl *D) {
|
2010-07-05 18:38:01 +08:00
|
|
|
VisitDecl(D);
|
2010-06-30 06:47:00 +08:00
|
|
|
if (Record[Idx++])
|
2010-10-05 23:59:54 +08:00
|
|
|
D->Friend = GetTypeSourceInfo(Record, Idx);
|
2010-06-30 06:47:00 +08:00
|
|
|
else
|
|
|
|
D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
D->NextFriend = cast_or_null<FriendDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-10-16 14:59:13 +08:00
|
|
|
D->UnsupportedFriend = (Record[Idx++] != 0);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->FriendLoc = ReadSourceLocation(Record, Idx);
|
2010-06-30 06:47:00 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
|
2010-07-23 00:04:10 +08:00
|
|
|
VisitDecl(D);
|
|
|
|
unsigned NumParams = Record[Idx++];
|
|
|
|
D->NumParams = NumParams;
|
|
|
|
D->Params = new TemplateParameterList*[NumParams];
|
|
|
|
for (unsigned i = 0; i != NumParams; ++i)
|
2010-10-05 23:59:54 +08:00
|
|
|
D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx);
|
2010-07-23 00:04:10 +08:00
|
|
|
if (Record[Idx++]) // HasFriendDecl
|
|
|
|
D->Friend = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
else
|
2010-10-05 23:59:54 +08:00
|
|
|
D->Friend = GetTypeSourceInfo(Record, Idx);
|
|
|
|
D->FriendLoc = ReadSourceLocation(Record, Idx);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) {
|
2010-06-20 03:29:09 +08:00
|
|
|
VisitNamedDecl(D);
|
|
|
|
|
2010-07-09 01:12:57 +08:00
|
|
|
NamedDecl *TemplatedDecl
|
|
|
|
= cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-06-23 21:48:30 +08:00
|
|
|
TemplateParameterList* TemplateParams
|
2010-10-05 23:59:54 +08:00
|
|
|
= Reader.ReadTemplateParameterList(F, Record, Idx);
|
2010-06-20 03:29:09 +08:00
|
|
|
D->init(TemplatedDecl, TemplateParams);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
|
2010-09-09 03:31:22 +08:00
|
|
|
// Initialize CommonOrPrev before VisitTemplateDecl so that getCommonPtr()
|
|
|
|
// can be used while this is still initializing.
|
2010-06-20 03:29:09 +08:00
|
|
|
|
2010-09-09 03:31:22 +08:00
|
|
|
assert(D->CommonOrPrev.isNull() && "getCommonPtr was called earlier on this");
|
2010-07-30 00:11:51 +08:00
|
|
|
RedeclarableTemplateDecl *PrevDecl =
|
|
|
|
cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
assert((PrevDecl == 0 || PrevDecl->getKind() == D->getKind()) &&
|
|
|
|
"PrevDecl kind mismatch");
|
|
|
|
if (PrevDecl)
|
|
|
|
D->CommonOrPrev = PrevDecl;
|
2010-06-20 03:29:09 +08:00
|
|
|
if (PrevDecl == 0) {
|
2010-09-09 03:31:22 +08:00
|
|
|
D->CommonOrPrev = D->newCommon(*Reader.getContext());
|
2010-07-30 00:11:51 +08:00
|
|
|
if (RedeclarableTemplateDecl *RTD
|
|
|
|
= cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++]))) {
|
|
|
|
assert(RTD->getKind() == D->getKind() &&
|
|
|
|
"InstantiatedFromMemberTemplate kind mismatch");
|
|
|
|
D->setInstantiatedFromMemberTemplateImpl(RTD);
|
|
|
|
if (Record[Idx++])
|
|
|
|
D->setMemberSpecialization();
|
|
|
|
}
|
2010-07-30 00:12:01 +08:00
|
|
|
|
|
|
|
RedeclarableTemplateDecl *LatestDecl =
|
|
|
|
cast_or_null<RedeclarableTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-08-04 01:30:10 +08:00
|
|
|
|
|
|
|
// This decl is a first one and the latest declaration that it points to is
|
2010-08-19 07:57:06 +08:00
|
|
|
// in the same AST file. However, if this actually needs to point to a
|
|
|
|
// redeclaration in another AST file, we need to update it by checking
|
2010-08-04 01:30:10 +08:00
|
|
|
// the FirstLatestDeclIDs map which tracks this kind of decls.
|
|
|
|
assert(Reader.GetDecl(ThisDeclID) == D && "Invalid ThisDeclID ?");
|
2010-08-19 07:56:43 +08:00
|
|
|
ASTReader::FirstLatestDeclIDMap::iterator I
|
2010-08-04 01:30:10 +08:00
|
|
|
= Reader.FirstLatestDeclIDs.find(ThisDeclID);
|
|
|
|
if (I != Reader.FirstLatestDeclIDs.end()) {
|
|
|
|
Decl *NewLatest = Reader.GetDecl(I->second);
|
|
|
|
assert((LatestDecl->getLocation().isInvalid() ||
|
|
|
|
NewLatest->getLocation().isInvalid() ||
|
|
|
|
Reader.SourceMgr.isBeforeInTranslationUnit(
|
|
|
|
LatestDecl->getLocation(),
|
|
|
|
NewLatest->getLocation())) &&
|
|
|
|
"The new latest is supposed to come after the previous latest");
|
|
|
|
LatestDecl = cast<RedeclarableTemplateDecl>(NewLatest);
|
|
|
|
}
|
|
|
|
|
2010-07-30 00:12:01 +08:00
|
|
|
assert(LatestDecl->getKind() == D->getKind() && "Latest kind mismatch");
|
|
|
|
D->getCommonPtr()->Latest = LatestDecl;
|
2010-07-30 00:11:51 +08:00
|
|
|
}
|
2010-09-09 03:31:22 +08:00
|
|
|
|
|
|
|
VisitTemplateDecl(D);
|
|
|
|
D->IdentifierNamespace = Record[Idx++];
|
2010-07-30 00:11:51 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
|
2010-07-30 00:11:51 +08:00
|
|
|
VisitRedeclarableTemplateDecl(D);
|
|
|
|
|
|
|
|
if (D->getPreviousDeclaration() == 0) {
|
2010-06-20 03:29:09 +08:00
|
|
|
// This ClassTemplateDecl owns a CommonPtr; read it.
|
|
|
|
|
2010-07-10 05:11:43 +08:00
|
|
|
// FoldingSets are filled in VisitClassTemplateSpecializationDecl.
|
2010-06-20 03:29:09 +08:00
|
|
|
unsigned size = Record[Idx++];
|
2010-07-10 05:11:43 +08:00
|
|
|
while (size--)
|
|
|
|
cast<ClassTemplateSpecializationDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-06-20 03:29:09 +08:00
|
|
|
|
|
|
|
size = Record[Idx++];
|
2010-07-10 05:11:43 +08:00
|
|
|
while (size--)
|
|
|
|
cast<ClassTemplatePartialSpecializationDecl>(
|
2010-06-20 03:29:09 +08:00
|
|
|
Reader.GetDecl(Record[Idx++]));
|
|
|
|
|
|
|
|
// InjectedClassNameType is computed.
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitClassTemplateSpecializationDecl(
|
2010-05-08 05:43:38 +08:00
|
|
|
ClassTemplateSpecializationDecl *D) {
|
2010-06-23 21:48:30 +08:00
|
|
|
VisitCXXRecordDecl(D);
|
2010-09-13 19:45:32 +08:00
|
|
|
|
|
|
|
ASTContext &C = *Reader.getContext();
|
2010-06-23 21:48:30 +08:00
|
|
|
if (Decl *InstD = Reader.GetDecl(Record[Idx++])) {
|
|
|
|
if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
|
2010-09-13 19:45:32 +08:00
|
|
|
D->SpecializedTemplate = CTD;
|
2010-06-23 21:48:30 +08:00
|
|
|
} else {
|
|
|
|
llvm::SmallVector<TemplateArgument, 8> TemplArgs;
|
2010-10-05 23:59:54 +08:00
|
|
|
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
|
2010-09-13 19:45:32 +08:00
|
|
|
TemplateArgumentList *ArgList
|
|
|
|
= new (C) TemplateArgumentList(C, TemplArgs.data(), TemplArgs.size());
|
|
|
|
ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
|
|
|
|
= new (C) ClassTemplateSpecializationDecl::
|
|
|
|
SpecializedPartialSpecialization();
|
|
|
|
PS->PartialSpecialization
|
|
|
|
= cast<ClassTemplatePartialSpecializationDecl>(InstD);
|
|
|
|
PS->TemplateArgs = ArgList;
|
|
|
|
D->SpecializedTemplate = PS;
|
2010-06-23 21:48:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Explicit info.
|
2010-10-05 23:59:54 +08:00
|
|
|
if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) {
|
2010-09-13 19:45:32 +08:00
|
|
|
ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo
|
|
|
|
= new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
|
|
|
|
ExplicitInfo->TypeAsWritten = TyInfo;
|
2010-10-05 23:59:54 +08:00
|
|
|
ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx);
|
|
|
|
ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx);
|
2010-09-13 19:45:32 +08:00
|
|
|
D->ExplicitInfo = ExplicitInfo;
|
2010-06-23 21:48:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
llvm::SmallVector<TemplateArgument, 8> TemplArgs;
|
2010-10-05 23:59:54 +08:00
|
|
|
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
|
2010-09-13 19:45:32 +08:00
|
|
|
D->TemplateArgs.init(C, TemplArgs.data(), TemplArgs.size());
|
2010-10-05 23:59:54 +08:00
|
|
|
D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
|
2010-09-13 19:45:32 +08:00
|
|
|
D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
|
2010-07-10 05:11:43 +08:00
|
|
|
|
2010-07-20 21:59:40 +08:00
|
|
|
if (D->isCanonicalDecl()) { // It's kept in the folding set.
|
2010-07-10 05:11:43 +08:00
|
|
|
ClassTemplateDecl *CanonPattern
|
|
|
|
= cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
if (ClassTemplatePartialSpecializationDecl *Partial
|
|
|
|
= dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
|
2010-07-13 05:41:31 +08:00
|
|
|
CanonPattern->getPartialSpecializations().InsertNode(Partial);
|
2010-07-10 05:11:43 +08:00
|
|
|
} else {
|
2010-07-13 05:41:31 +08:00
|
|
|
CanonPattern->getSpecializations().InsertNode(D);
|
2010-07-10 05:11:43 +08:00
|
|
|
}
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl(
|
2010-05-08 05:43:38 +08:00
|
|
|
ClassTemplatePartialSpecializationDecl *D) {
|
2010-06-23 21:48:30 +08:00
|
|
|
VisitClassTemplateSpecializationDecl(D);
|
|
|
|
|
2010-09-13 19:45:41 +08:00
|
|
|
ASTContext &C = *Reader.getContext();
|
2010-10-05 23:59:54 +08:00
|
|
|
D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx);
|
2010-09-13 19:45:41 +08:00
|
|
|
|
2010-06-23 21:48:30 +08:00
|
|
|
unsigned NumArgs = Record[Idx++];
|
2010-09-13 19:45:41 +08:00
|
|
|
if (NumArgs) {
|
|
|
|
D->NumArgsAsWritten = NumArgs;
|
|
|
|
D->ArgsAsWritten = new (C) TemplateArgumentLoc[NumArgs];
|
|
|
|
for (unsigned i=0; i != NumArgs; ++i)
|
2010-10-05 23:59:54 +08:00
|
|
|
D->ArgsAsWritten[i] = Reader.ReadTemplateArgumentLoc(F, Record, Idx);
|
2010-09-13 19:45:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
D->SequenceNumber = Record[Idx++];
|
2010-06-23 21:48:30 +08:00
|
|
|
|
|
|
|
// These are read/set from/to the first declaration.
|
|
|
|
if (D->getPreviousDeclaration() == 0) {
|
2010-09-13 19:45:41 +08:00
|
|
|
D->InstantiatedFromMember.setPointer(
|
2010-06-23 21:48:30 +08:00
|
|
|
cast_or_null<ClassTemplatePartialSpecializationDecl>(
|
|
|
|
Reader.GetDecl(Record[Idx++])));
|
2010-09-13 19:45:41 +08:00
|
|
|
D->InstantiatedFromMember.setInt(Record[Idx++]);
|
2010-06-23 21:48:30 +08:00
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
|
2010-07-30 00:11:51 +08:00
|
|
|
VisitRedeclarableTemplateDecl(D);
|
2010-06-22 17:55:07 +08:00
|
|
|
|
2010-07-30 00:11:51 +08:00
|
|
|
if (D->getPreviousDeclaration() == 0) {
|
2010-06-22 17:55:07 +08:00
|
|
|
// This FunctionTemplateDecl owns a CommonPtr; read it.
|
|
|
|
|
2010-07-06 23:37:09 +08:00
|
|
|
// Read the function specialization declarations.
|
|
|
|
// FunctionTemplateDecl's FunctionTemplateSpecializationInfos are filled
|
2010-09-13 19:45:48 +08:00
|
|
|
// when reading the specialized FunctionDecl.
|
2010-07-06 23:37:09 +08:00
|
|
|
unsigned NumSpecs = Record[Idx++];
|
|
|
|
while (NumSpecs--)
|
|
|
|
Reader.GetDecl(Record[Idx++]);
|
2010-06-22 17:55:07 +08:00
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
|
2010-06-20 03:29:09 +08:00
|
|
|
VisitTypeDecl(D);
|
|
|
|
|
|
|
|
D->setDeclaredWithTypename(Record[Idx++]);
|
|
|
|
D->setParameterPack(Record[Idx++]);
|
|
|
|
|
|
|
|
bool Inherited = Record[Idx++];
|
2010-10-05 23:59:54 +08:00
|
|
|
TypeSourceInfo *DefArg = GetTypeSourceInfo(Record, Idx);
|
2010-06-20 03:29:09 +08:00
|
|
|
D->setDefaultArgument(DefArg, Inherited);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
|
2010-06-26 00:25:09 +08:00
|
|
|
VisitVarDecl(D);
|
|
|
|
// TemplateParmPosition.
|
|
|
|
D->setDepth(Record[Idx++]);
|
|
|
|
D->setPosition(Record[Idx++]);
|
|
|
|
// Rest of NonTypeTemplateParmDecl.
|
|
|
|
if (Record[Idx++]) {
|
2010-10-05 23:59:54 +08:00
|
|
|
Expr *DefArg = Reader.ReadExpr(F);
|
2010-06-26 00:25:09 +08:00
|
|
|
bool Inherited = Record[Idx++];
|
|
|
|
D->setDefaultArgument(DefArg, Inherited);
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
|
2010-07-09 01:12:57 +08:00
|
|
|
VisitTemplateDecl(D);
|
|
|
|
// TemplateParmPosition.
|
|
|
|
D->setDepth(Record[Idx++]);
|
|
|
|
D->setPosition(Record[Idx++]);
|
|
|
|
// Rest of TemplateTemplateParmDecl.
|
2010-10-05 23:59:54 +08:00
|
|
|
TemplateArgumentLoc Arg = Reader.ReadTemplateArgumentLoc(F, Record, Idx);
|
2010-07-09 01:12:57 +08:00
|
|
|
bool IsInherited = Record[Idx++];
|
|
|
|
D->setDefaultArgument(Arg, IsInherited);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) {
|
2010-07-23 01:28:12 +08:00
|
|
|
VisitDecl(D);
|
2010-10-05 23:59:54 +08:00
|
|
|
D->AssertExpr = Reader.ReadExpr(F);
|
|
|
|
D->Message = cast<StringLiteral>(Reader.ReadExpr(F));
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
std::pair<uint64_t, uint64_t>
|
2010-08-19 07:56:48 +08:00
|
|
|
ASTDeclReader::VisitDeclContext(DeclContext *DC) {
|
2009-04-27 13:27:42 +08:00
|
|
|
uint64_t LexicalOffset = Record[Idx++];
|
|
|
|
uint64_t VisibleOffset = Record[Idx++];
|
|
|
|
return std::make_pair(LexicalOffset, VisibleOffset);
|
|
|
|
}
|
|
|
|
|
2010-08-04 01:30:10 +08:00
|
|
|
template <typename T>
|
2010-08-19 07:56:48 +08:00
|
|
|
void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
|
2010-08-04 01:30:10 +08:00
|
|
|
enum RedeclKind { NoRedeclaration = 0, PointsToPrevious, PointsToLatest };
|
|
|
|
RedeclKind Kind = (RedeclKind)Record[Idx++];
|
|
|
|
switch (Kind) {
|
|
|
|
default:
|
2010-08-19 07:56:48 +08:00
|
|
|
assert(0 && "Out of sync with ASTDeclWriter::VisitRedeclarable or messed up"
|
2010-08-04 01:30:10 +08:00
|
|
|
" reading");
|
|
|
|
case NoRedeclaration:
|
|
|
|
break;
|
|
|
|
case PointsToPrevious:
|
|
|
|
D->RedeclLink = typename Redeclarable<T>::PreviousDeclLink(
|
|
|
|
cast_or_null<T>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
break;
|
|
|
|
case PointsToLatest:
|
|
|
|
D->RedeclLink = typename Redeclarable<T>::LatestDeclLink(
|
|
|
|
cast_or_null<T>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(!(Kind == PointsToPrevious &&
|
|
|
|
Reader.FirstLatestDeclIDs.find(ThisDeclID) !=
|
|
|
|
Reader.FirstLatestDeclIDs.end()) &&
|
|
|
|
"This decl is not first, it should not be in the map");
|
|
|
|
if (Kind == PointsToPrevious)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// This decl is a first one and the latest declaration that it points to is in
|
2010-08-19 07:57:06 +08:00
|
|
|
// the same AST file. However, if this actually needs to point to a
|
|
|
|
// redeclaration in another AST file, we need to update it by checking the
|
2010-08-04 01:30:10 +08:00
|
|
|
// FirstLatestDeclIDs map which tracks this kind of decls.
|
|
|
|
assert(Reader.GetDecl(ThisDeclID) == static_cast<T*>(D) &&
|
|
|
|
"Invalid ThisDeclID ?");
|
2010-08-19 07:56:43 +08:00
|
|
|
ASTReader::FirstLatestDeclIDMap::iterator I
|
2010-08-04 01:30:10 +08:00
|
|
|
= Reader.FirstLatestDeclIDs.find(ThisDeclID);
|
|
|
|
if (I != Reader.FirstLatestDeclIDs.end()) {
|
|
|
|
Decl *NewLatest = Reader.GetDecl(I->second);
|
|
|
|
assert((D->getMostRecentDeclaration()->getLocation().isInvalid() ||
|
|
|
|
NewLatest->getLocation().isInvalid() ||
|
|
|
|
Reader.SourceMgr.isBeforeInTranslationUnit(
|
|
|
|
D->getMostRecentDeclaration()->getLocation(),
|
|
|
|
NewLatest->getLocation())) &&
|
|
|
|
"The new latest is supposed to come after the previous latest");
|
|
|
|
D->RedeclLink
|
|
|
|
= typename Redeclarable<T>::LatestDeclLink(cast_or_null<T>(NewLatest));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-27 13:27:42 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-04-27 14:01:06 +08:00
|
|
|
// Attribute Reading
|
2009-04-27 13:27:42 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-04-27 14:01:06 +08:00
|
|
|
/// \brief Reads attributes from the current stream position.
|
2010-10-19 03:20:11 +08:00
|
|
|
void ASTReader::ReadAttributes(PerFileData &F, AttrVec &Attrs,
|
|
|
|
const RecordData &Record, unsigned &Idx) {
|
|
|
|
for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) {
|
2009-04-27 14:01:06 +08:00
|
|
|
Attr *New = 0;
|
2010-06-17 07:43:53 +08:00
|
|
|
attr::Kind Kind = (attr::Kind)Record[Idx++];
|
2010-10-05 23:59:54 +08:00
|
|
|
SourceLocation Loc = ReadSourceLocation(F, Record, Idx);
|
2010-08-19 07:23:40 +08:00
|
|
|
bool isInherited = Record[Idx++];
|
2009-04-27 14:01:06 +08:00
|
|
|
|
2010-08-19 07:23:40 +08:00
|
|
|
#include "clang/Serialization/AttrPCHRead.inc"
|
2009-04-27 14:01:06 +08:00
|
|
|
|
|
|
|
assert(New && "Unable to decode attribute?");
|
2010-08-19 07:23:40 +08:00
|
|
|
New->setInherited(isInherited);
|
|
|
|
Attrs.push_back(New);
|
2009-04-27 14:01:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2010-08-19 07:56:43 +08:00
|
|
|
// ASTReader Implementation
|
2009-04-27 14:01:06 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-04-27 13:27:42 +08:00
|
|
|
|
|
|
|
/// \brief Note that we have loaded the declaration with the given
|
|
|
|
/// Index.
|
2009-09-09 23:08:12 +08:00
|
|
|
///
|
2009-04-27 13:27:42 +08:00
|
|
|
/// This routine notes that this declaration has already been loaded,
|
|
|
|
/// so that future GetDecl calls will return this declaration rather
|
|
|
|
/// than trying to load a new declaration.
|
2010-08-19 07:56:43 +08:00
|
|
|
inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) {
|
2009-04-27 13:27:42 +08:00
|
|
|
assert(!DeclsLoaded[Index] && "Decl loaded twice?");
|
|
|
|
DeclsLoaded[Index] = D;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// \brief Determine whether the consumer will be interested in seeing
|
|
|
|
/// this declaration (via HandleTopLevelDecl).
|
|
|
|
///
|
|
|
|
/// This routine should return true for anything that might affect
|
|
|
|
/// code generation, e.g., inline function definitions, Objective-C
|
|
|
|
/// declarations with metadata, etc.
|
|
|
|
static bool isConsumerInterestedIn(Decl *D) {
|
2009-09-17 11:06:44 +08:00
|
|
|
if (isa<FileScopeAsmDecl>(D))
|
|
|
|
return true;
|
2009-04-27 13:27:42 +08:00
|
|
|
if (VarDecl *Var = dyn_cast<VarDecl>(D))
|
2010-08-05 17:47:59 +08:00
|
|
|
return Var->isFileVarDecl() &&
|
|
|
|
Var->isThisDeclarationADefinition() == VarDecl::Definition;
|
2009-04-27 13:27:42 +08:00
|
|
|
if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D))
|
|
|
|
return Func->isThisDeclarationADefinition();
|
2010-08-09 18:54:20 +08:00
|
|
|
return isa<ObjCProtocolDecl>(D) || isa<ObjCImplementationDecl>(D);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
2010-07-21 06:46:15 +08:00
|
|
|
/// \brief Get the correct cursor and offset for loading a type.
|
2010-08-19 07:56:43 +08:00
|
|
|
ASTReader::RecordLocation
|
2010-08-19 07:57:32 +08:00
|
|
|
ASTReader::DeclCursorForIndex(unsigned Index, DeclID ID) {
|
2010-08-13 08:28:03 +08:00
|
|
|
// See if there's an override.
|
|
|
|
DeclReplacementMap::iterator It = ReplacedDecls.find(ID);
|
|
|
|
if (It != ReplacedDecls.end())
|
2010-10-05 23:59:54 +08:00
|
|
|
return RecordLocation(It->second.first, It->second.second);
|
2010-08-13 08:28:03 +08:00
|
|
|
|
2010-07-21 06:46:15 +08:00
|
|
|
PerFileData *F = 0;
|
|
|
|
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
|
|
|
|
F = Chain[N - I - 1];
|
|
|
|
if (Index < F->LocalNumDecls)
|
|
|
|
break;
|
|
|
|
Index -= F->LocalNumDecls;
|
|
|
|
}
|
|
|
|
assert(F && F->LocalNumDecls > Index && "Broken chain");
|
2010-10-05 23:59:54 +08:00
|
|
|
return RecordLocation(F, F->DeclOffsets[Index]);
|
2010-07-21 06:46:15 +08:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
/// \brief Read the declaration at the given offset from the AST file.
|
2010-08-19 07:57:32 +08:00
|
|
|
Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) {
|
2010-08-13 08:28:03 +08:00
|
|
|
RecordLocation Loc = DeclCursorForIndex(Index, ID);
|
2010-10-05 23:59:54 +08:00
|
|
|
llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
|
2009-04-27 13:27:42 +08:00
|
|
|
// Keep track of where we are in the stream, then jump back there
|
|
|
|
// after reading this declaration.
|
2009-04-27 13:58:23 +08:00
|
|
|
SavedStreamPosition SavedPosition(DeclsCursor);
|
2009-04-27 13:27:42 +08:00
|
|
|
|
2010-06-29 06:28:35 +08:00
|
|
|
ReadingKindTracker ReadingKind(Read_Decl, *this);
|
|
|
|
|
2009-07-07 02:54:52 +08:00
|
|
|
// Note that we are loading a declaration record.
|
2010-07-30 18:03:16 +08:00
|
|
|
Deserializing ADecl(this);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-10-05 23:59:54 +08:00
|
|
|
DeclsCursor.JumpToBit(Loc.Offset);
|
2009-04-27 13:27:42 +08:00
|
|
|
RecordData Record;
|
2009-04-27 13:58:23 +08:00
|
|
|
unsigned Code = DeclsCursor.ReadCode();
|
2009-04-27 13:27:42 +08:00
|
|
|
unsigned Idx = 0;
|
2010-10-05 23:59:54 +08:00
|
|
|
ASTDeclReader Reader(*this, *Loc.F, DeclsCursor, ID, Record, Idx);
|
2009-04-27 13:27:42 +08:00
|
|
|
|
2009-04-27 13:58:23 +08:00
|
|
|
Decl *D = 0;
|
2010-08-19 07:57:32 +08:00
|
|
|
switch ((DeclCode)DeclsCursor.ReadRecord(Code, Record)) {
|
|
|
|
case DECL_CONTEXT_LEXICAL:
|
|
|
|
case DECL_CONTEXT_VISIBLE:
|
2009-04-27 13:27:42 +08:00
|
|
|
assert(false && "Record cannot be de-serialized with ReadDeclRecord");
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_TRANSLATION_UNIT:
|
2009-04-27 13:27:42 +08:00
|
|
|
assert(Index == 0 && "Translation unit must be at index 0");
|
2009-04-28 05:45:14 +08:00
|
|
|
D = Context->getTranslationUnitDecl();
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_TYPEDEF:
|
2009-10-24 16:00:42 +08:00
|
|
|
D = TypedefDecl::Create(*Context, 0, SourceLocation(), 0, 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_ENUM:
|
2010-07-02 19:54:55 +08:00
|
|
|
D = EnumDecl::Create(*Context, Decl::EmptyShell());
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_RECORD:
|
2010-07-02 19:54:55 +08:00
|
|
|
D = RecordDecl::Create(*Context, Decl::EmptyShell());
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_ENUM_CONSTANT:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = EnumConstantDecl::Create(*Context, 0, SourceLocation(), 0, QualType(),
|
2009-04-27 13:27:42 +08:00
|
|
|
0, llvm::APSInt());
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_FUNCTION:
|
2009-09-09 23:08:12 +08:00
|
|
|
D = FunctionDecl::Create(*Context, 0, SourceLocation(), DeclarationName(),
|
2009-08-19 09:27:57 +08:00
|
|
|
QualType(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_LINKAGE_SPEC:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = LinkageSpecDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
(LinkageSpecDecl::LanguageIDs)0,
|
|
|
|
false);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_NAMESPACE:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = NamespaceDecl::Create(*Context, 0, SourceLocation(), 0);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_NAMESPACE_ALIAS:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = NamespaceAliasDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceLocation(), 0, SourceRange(), 0,
|
|
|
|
SourceLocation(), 0);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_USING:
|
2010-08-12 19:46:03 +08:00
|
|
|
D = UsingDecl::Create(*Context, 0, SourceRange(), SourceLocation(),
|
|
|
|
0, DeclarationNameInfo(), false);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_USING_SHADOW:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_USING_DIRECTIVE:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = UsingDirectiveDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceLocation(), SourceRange(), 0,
|
|
|
|
SourceLocation(), 0, 0);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_UNRESOLVED_USING_VALUE:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(),
|
2010-08-12 19:46:03 +08:00
|
|
|
SourceRange(), 0,
|
|
|
|
DeclarationNameInfo());
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_UNRESOLVED_USING_TYPENAME:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceLocation(), SourceRange(),
|
|
|
|
0, SourceLocation(),
|
|
|
|
DeclarationName());
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CXX_RECORD:
|
2010-07-02 19:54:55 +08:00
|
|
|
D = CXXRecordDecl::Create(*Context, Decl::EmptyShell());
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CXX_METHOD:
|
2010-08-12 06:01:17 +08:00
|
|
|
D = CXXMethodDecl::Create(*Context, 0, DeclarationNameInfo(),
|
2010-05-08 05:43:38 +08:00
|
|
|
QualType(), 0);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CXX_CONSTRUCTOR:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = CXXConstructorDecl::Create(*Context, Decl::EmptyShell());
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CXX_DESTRUCTOR:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = CXXDestructorDecl::Create(*Context, Decl::EmptyShell());
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CXX_CONVERSION:
|
2010-05-08 05:43:38 +08:00
|
|
|
D = CXXConversionDecl::Create(*Context, Decl::EmptyShell());
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_ACCESS_SPEC:
|
2010-09-09 05:32:35 +08:00
|
|
|
D = AccessSpecDecl::Create(*Context, Decl::EmptyShell());
|
2010-06-05 13:09:32 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_FRIEND:
|
2010-06-30 06:47:00 +08:00
|
|
|
D = FriendDecl::Create(*Context, Decl::EmptyShell());
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_FRIEND_TEMPLATE:
|
2010-07-23 00:04:10 +08:00
|
|
|
D = FriendTemplateDecl::Create(*Context, Decl::EmptyShell());
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CLASS_TEMPLATE:
|
2010-06-21 18:57:41 +08:00
|
|
|
D = ClassTemplateDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
DeclarationName(), 0, 0, 0);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CLASS_TEMPLATE_SPECIALIZATION:
|
2010-07-02 19:54:55 +08:00
|
|
|
D = ClassTemplateSpecializationDecl::Create(*Context, Decl::EmptyShell());
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION:
|
2010-07-02 19:54:55 +08:00
|
|
|
D = ClassTemplatePartialSpecializationDecl::Create(*Context,
|
|
|
|
Decl::EmptyShell());
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_FUNCTION_TEMPLATE:
|
2010-06-22 17:55:07 +08:00
|
|
|
D = FunctionTemplateDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
DeclarationName(), 0, 0);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_TEMPLATE_TYPE_PARM:
|
2010-07-02 19:54:55 +08:00
|
|
|
D = TemplateTypeParmDecl::Create(*Context, Decl::EmptyShell());
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_NON_TYPE_TEMPLATE_PARM:
|
2010-06-26 00:25:09 +08:00
|
|
|
D = NonTypeTemplateParmDecl::Create(*Context, 0, SourceLocation(), 0,0,0,
|
|
|
|
QualType(),0);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_TEMPLATE_TEMPLATE_PARM:
|
2010-07-09 01:12:57 +08:00
|
|
|
D = TemplateTemplateParmDecl::Create(*Context, 0, SourceLocation(),0,0,0,0);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_STATIC_ASSERT:
|
2010-07-23 01:28:12 +08:00
|
|
|
D = StaticAssertDecl::Create(*Context, 0, SourceLocation(), 0, 0);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_METHOD:
|
2009-09-09 23:08:12 +08:00
|
|
|
D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(),
|
2010-03-08 22:59:44 +08:00
|
|
|
Selector(), QualType(), 0, 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_INTERFACE:
|
2010-08-11 20:19:30 +08:00
|
|
|
D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_IVAR:
|
2009-08-19 09:27:57 +08:00
|
|
|
D = ObjCIvarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
|
2009-04-27 13:27:42 +08:00
|
|
|
ObjCIvarDecl::None);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_PROTOCOL:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCProtocolDecl::Create(*Context, 0, SourceLocation(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_AT_DEFS_FIELD:
|
2009-09-09 23:08:12 +08:00
|
|
|
D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), 0,
|
2009-04-27 13:27:42 +08:00
|
|
|
QualType(), 0);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_CLASS:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCClassDecl::Create(*Context, 0, SourceLocation());
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_FORWARD_PROTOCOL:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCForwardProtocolDecl::Create(*Context, 0, SourceLocation());
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_CATEGORY:
|
2010-01-17 00:38:58 +08:00
|
|
|
D = ObjCCategoryDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceLocation(), SourceLocation(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_CATEGORY_IMPL:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCCategoryImplDecl::Create(*Context, 0, SourceLocation(), 0, 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_IMPLEMENTATION:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCImplementationDecl::Create(*Context, 0, SourceLocation(), 0, 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_COMPATIBLE_ALIAS:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCCompatibleAliasDecl::Create(*Context, 0, SourceLocation(), 0, 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_PROPERTY:
|
2010-01-22 01:36:00 +08:00
|
|
|
D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(),
|
2010-06-05 04:50:08 +08:00
|
|
|
0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_OBJC_PROPERTY_IMPL:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(),
|
2009-09-09 23:08:12 +08:00
|
|
|
SourceLocation(), 0,
|
2009-04-27 13:27:42 +08:00
|
|
|
ObjCPropertyImplDecl::Dynamic, 0);
|
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_FIELD:
|
2009-09-09 23:08:12 +08:00
|
|
|
D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0,
|
2009-08-21 08:31:54 +08:00
|
|
|
false);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_VAR:
|
2009-08-19 09:27:57 +08:00
|
|
|
D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
|
2010-08-26 11:08:43 +08:00
|
|
|
SC_None, SC_None);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_IMPLICIT_PARAM:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ImplicitParamDecl::Create(*Context, 0, SourceLocation(), 0, QualType());
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
|
|
|
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_PARM_VAR:
|
2009-09-09 23:08:12 +08:00
|
|
|
D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
|
2010-08-26 11:08:43 +08:00
|
|
|
SC_None, SC_None, 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_FILE_SCOPE_ASM:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = FileScopeAsmDecl::Create(*Context, 0, SourceLocation(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2010-08-19 07:57:32 +08:00
|
|
|
case DECL_BLOCK:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = BlockDecl::Create(*Context, 0, SourceLocation());
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:56:48 +08:00
|
|
|
assert(D && "Unknown declaration reading AST file");
|
2009-04-27 14:01:06 +08:00
|
|
|
LoadedDecl(Index, D);
|
|
|
|
Reader.Visit(D);
|
2009-04-27 13:27:42 +08:00
|
|
|
|
|
|
|
// If this declaration is also a declaration context, get the
|
|
|
|
// offsets for its tables of lexical and visible declarations.
|
|
|
|
if (DeclContext *DC = dyn_cast<DeclContext>(D)) {
|
|
|
|
std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC);
|
|
|
|
if (Offsets.first || Offsets.second) {
|
|
|
|
DC->setHasExternalLexicalStorage(Offsets.first != 0);
|
|
|
|
DC->setHasExternalVisibleStorage(Offsets.second != 0);
|
2010-07-27 08:17:23 +08:00
|
|
|
DeclContextInfo Info;
|
|
|
|
if (ReadDeclContextStorage(DeclsCursor, Offsets, Info))
|
|
|
|
return 0;
|
2010-07-28 02:24:41 +08:00
|
|
|
DeclContextInfos &Infos = DeclContextOffsets[DC];
|
2010-08-24 08:50:04 +08:00
|
|
|
// Reading the TU will happen after reading its lexical update blocks,
|
|
|
|
// so we need to make sure we insert in front. For all other contexts,
|
|
|
|
// the vector is empty here anyway, so there's no loss in efficiency.
|
2010-07-28 02:24:41 +08:00
|
|
|
Infos.insert(Infos.begin(), Info);
|
2010-08-24 08:50:04 +08:00
|
|
|
|
|
|
|
// Now add the pending visible updates for this decl context, if it has
|
|
|
|
// any.
|
|
|
|
DeclContextVisibleUpdatesPending::iterator I =
|
|
|
|
PendingVisibleUpdates.find(ID);
|
|
|
|
if (I != PendingVisibleUpdates.end()) {
|
|
|
|
DeclContextVisibleUpdates &U = I->second;
|
|
|
|
Info.LexicalDecls = 0;
|
|
|
|
Info.NumLexicalDecls = 0;
|
|
|
|
for (DeclContextVisibleUpdates::iterator UI = U.begin(), UE = U.end();
|
|
|
|
UI != UE; ++UI) {
|
|
|
|
Info.NameLookupTableData = *UI;
|
|
|
|
Infos.push_back(Info);
|
|
|
|
}
|
|
|
|
PendingVisibleUpdates.erase(I);
|
|
|
|
}
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
}
|
2010-08-25 06:50:19 +08:00
|
|
|
|
|
|
|
// If this is a template, read additional specializations that may be in a
|
|
|
|
// different part of the chain.
|
|
|
|
if (isa<RedeclarableTemplateDecl>(D)) {
|
|
|
|
AdditionalTemplateSpecializationsMap::iterator F =
|
|
|
|
AdditionalTemplateSpecializationsPending.find(ID);
|
|
|
|
if (F != AdditionalTemplateSpecializationsPending.end()) {
|
|
|
|
for (AdditionalTemplateSpecializations::iterator I = F->second.begin(),
|
|
|
|
E = F->second.end();
|
|
|
|
I != E; ++I)
|
|
|
|
GetDecl(*I);
|
|
|
|
AdditionalTemplateSpecializationsPending.erase(F);
|
|
|
|
}
|
|
|
|
}
|
2009-04-27 13:27:42 +08:00
|
|
|
assert(Idx == Record.size());
|
|
|
|
|
|
|
|
// If we have deserialized a declaration that has a definition the
|
2010-07-07 23:46:26 +08:00
|
|
|
// AST consumer might need to know about, queue it.
|
|
|
|
// We don't pass it to the consumer immediately because we may be in recursive
|
|
|
|
// loading, and some declarations may still be initializing.
|
|
|
|
if (isConsumerInterestedIn(D))
|
|
|
|
InterestingDecls.push_back(D);
|
2009-04-27 13:27:42 +08:00
|
|
|
|
|
|
|
return D;
|
|
|
|
}
|