2009-04-27 13:27:42 +08:00
|
|
|
//===--- PCHReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the PCHReader::ReadDeclRecord method, which is the
|
|
|
|
// entrypoint for loading a decl.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Frontend/PCHReader.h"
|
|
|
|
#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;
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Declaration deserialization
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class PCHDeclReader : public DeclVisitor<PCHDeclReader, void> {
|
|
|
|
PCHReader &Reader;
|
|
|
|
const PCHReader::RecordData &Record;
|
|
|
|
unsigned &Idx;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PCHDeclReader(PCHReader &Reader, const PCHReader::RecordData &Record,
|
|
|
|
unsigned &Idx)
|
|
|
|
: Reader(Reader), Record(Record), Idx(Idx) { }
|
|
|
|
|
2010-06-04 03:28:45 +08:00
|
|
|
CXXBaseSpecifier *ReadCXXBaseSpecifier();
|
|
|
|
|
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-05-08 05:43:38 +08:00
|
|
|
void VisitUnresolvedUsingTypename(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-05-08 05:43:38 +08:00
|
|
|
void VisitUnresolvedUsingValue(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);
|
|
|
|
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-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-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);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitDecl(Decl *D) {
|
|
|
|
D->setDeclContext(cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setLexicalDeclContext(
|
|
|
|
cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
D->setInvalidDecl(Record[Idx++]);
|
|
|
|
if (Record[Idx++])
|
2010-06-12 07:09:25 +08:00
|
|
|
D->initAttrs(Reader.ReadAttributes());
|
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++]);
|
2009-10-17 04:01:17 +08:00
|
|
|
D->setPCHLevel(Record[Idx++] + 1);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitNamedDecl(NamedDecl *ND) {
|
|
|
|
VisitDecl(ND);
|
2009-09-09 23:08:12 +08:00
|
|
|
ND->setDeclName(Reader.ReadDeclarationName(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitTypeDecl(TypeDecl *TD) {
|
|
|
|
VisitNamedDecl(TD);
|
|
|
|
TD->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitTypedefDecl(TypedefDecl *TD) {
|
|
|
|
// Note that we cannot use VisitTypeDecl here, because we need to
|
|
|
|
// set the underlying type of the typedef *before* we try to read
|
|
|
|
// the type associated with the TypedefDecl.
|
|
|
|
VisitNamedDecl(TD);
|
2009-10-24 16:00:42 +08:00
|
|
|
uint64_t TypeData = Record[Idx++];
|
2009-12-07 10:54:59 +08:00
|
|
|
TD->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
|
2009-10-24 16:00:42 +08:00
|
|
|
TD->setTypeForDecl(Reader.GetType(TypeData).getTypePtr());
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitTagDecl(TagDecl *TD) {
|
|
|
|
VisitTypeDecl(TD);
|
2009-07-30 07:36:44 +08:00
|
|
|
TD->setPreviousDeclaration(
|
|
|
|
cast_or_null<TagDecl>(Reader.GetDecl(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++]);
|
2009-07-14 11:18:02 +08:00
|
|
|
TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-07-21 22:46:17 +08:00
|
|
|
TD->setTagKeywordLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-03-15 18:12:16 +08:00
|
|
|
// FIXME: maybe read optional qualifier and its range.
|
|
|
|
TD->setTypedefForAnonDecl(
|
|
|
|
cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++])));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitEnumDecl(EnumDecl *ED) {
|
|
|
|
VisitTagDecl(ED);
|
|
|
|
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++]);
|
2009-05-28 01:20:35 +08:00
|
|
|
// FIXME: C++ InstantiatedFrom
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitRecordDecl(RecordDecl *RD) {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitValueDecl(ValueDecl *VD) {
|
|
|
|
VisitNamedDecl(VD);
|
|
|
|
VD->setType(Reader.GetType(Record[Idx++]));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) {
|
|
|
|
VisitValueDecl(ECD);
|
|
|
|
if (Record[Idx++])
|
2009-04-27 13:58:23 +08:00
|
|
|
ECD->setInitExpr(Reader.ReadDeclExpr());
|
2009-04-27 13:27:42 +08:00
|
|
|
ECD->setInitVal(Reader.ReadAPSInt(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2009-08-19 09:28:35 +08:00
|
|
|
void PCHDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) {
|
|
|
|
VisitValueDecl(DD);
|
2009-12-07 10:54:59 +08:00
|
|
|
TypeSourceInfo *TInfo = Reader.GetTypeSourceInfo(Record, Idx);
|
|
|
|
if (TInfo)
|
|
|
|
DD->setTypeSourceInfo(TInfo);
|
2010-03-15 18:12:16 +08:00
|
|
|
// FIXME: read optional qualifier and its range.
|
2009-08-19 09:28:35 +08:00
|
|
|
}
|
|
|
|
|
2009-04-27 13:27:42 +08:00
|
|
|
void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
2009-08-19 09:28:35 +08:00
|
|
|
VisitDeclaratorDecl(FD);
|
2009-04-27 13:27:42 +08:00
|
|
|
if (Record[Idx++])
|
2009-04-27 13:58:23 +08:00
|
|
|
FD->setLazyBody(Reader.getDeclsCursor().GetCurrentBitNo());
|
2009-04-27 13:27:42 +08:00
|
|
|
FD->setPreviousDeclaration(
|
|
|
|
cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]);
|
2010-04-20 06:54:31 +08:00
|
|
|
FD->setStorageClassAsWritten((FunctionDecl::StorageClass)Record[Idx++]);
|
2009-10-28 05:01:01 +08:00
|
|
|
FD->setInlineSpecified(Record[Idx++]);
|
2009-05-15 06:15:41 +08:00
|
|
|
FD->setVirtualAsWritten(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
FD->setPure(Record[Idx++]);
|
2009-05-15 05:46:00 +08:00
|
|
|
FD->setHasInheritedPrototype(Record[Idx++]);
|
|
|
|
FD->setHasWrittenPrototype(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
FD->setDeleted(Record[Idx++]);
|
2009-09-22 13:38:14 +08:00
|
|
|
FD->setTrivial(Record[Idx++]);
|
|
|
|
FD->setCopyAssignment(Record[Idx++]);
|
|
|
|
FD->setHasImplicitReturnZero(Record[Idx++]);
|
2009-06-20 16:09:34 +08:00
|
|
|
FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-05-08 05:43:38 +08:00
|
|
|
|
2010-06-22 17:55:07 +08:00
|
|
|
switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
|
|
|
|
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++];
|
|
|
|
SourceLocation POI = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
FD->setInstantiationOfMemberFunction(InstFD, TSK);
|
|
|
|
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-06-23 21:48:30 +08:00
|
|
|
Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx);
|
2010-06-22 17:55:07 +08:00
|
|
|
|
|
|
|
// Template args as written.
|
|
|
|
unsigned NumTemplateArgLocs = Record[Idx++];
|
|
|
|
llvm::SmallVector<TemplateArgumentLoc, 8> TemplArgLocs;
|
|
|
|
TemplArgLocs.reserve(NumTemplateArgLocs);
|
|
|
|
for (unsigned i=0; i != NumTemplateArgLocs; ++i)
|
|
|
|
TemplArgLocs.push_back(Reader.ReadTemplateArgumentLoc(Record, Idx));
|
|
|
|
|
|
|
|
SourceLocation LAngleLoc, RAngleLoc;
|
|
|
|
if (NumTemplateArgLocs) {
|
|
|
|
LAngleLoc = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
RAngleLoc = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
}
|
|
|
|
|
2010-06-23 21:48:30 +08:00
|
|
|
FD->setFunctionTemplateSpecialization(Template, TemplArgs.size(),
|
2010-06-22 17:55:07 +08:00
|
|
|
TemplArgs.data(), TSK,
|
|
|
|
NumTemplateArgLocs,
|
|
|
|
NumTemplateArgLocs ? TemplArgLocs.data() : 0,
|
|
|
|
LAngleLoc, RAngleLoc);
|
|
|
|
}
|
|
|
|
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--)
|
|
|
|
TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(Record, Idx));
|
|
|
|
|
|
|
|
FD->setDependentTemplateSpecialization(*Reader.getContext(),
|
|
|
|
TemplDecls, TemplArgs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-02-11 09:19:42 +08:00
|
|
|
FD->setParams(Params.data(), NumParams);
|
2010-04-24 09:30:58 +08:00
|
|
|
|
|
|
|
// FIXME: order this properly w.r.t. friendness
|
|
|
|
// FIXME: this same thing needs to happen for function templates
|
|
|
|
if (FD->isOverloadedOperator() && !FD->getDeclContext()->isRecord())
|
|
|
|
FD->setNonMemberOperator();
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
|
|
|
|
VisitNamedDecl(MD);
|
|
|
|
if (Record[Idx++]) {
|
|
|
|
// In practice, this won't be executed (since method definitions
|
|
|
|
// don't occur in header files).
|
2009-04-27 13:58:23 +08:00
|
|
|
MD->setBody(Reader.ReadDeclStmt());
|
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++]);
|
|
|
|
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-03-08 22:59:44 +08:00
|
|
|
MD->setResultTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
|
2009-04-27 13:27:42 +08:00
|
|
|
MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) {
|
|
|
|
VisitNamedDecl(CD);
|
2010-01-07 09:20:12 +08:00
|
|
|
SourceLocation A = SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
SourceLocation B = SourceLocation::getFromRawEncoding(Record[Idx++]);
|
|
|
|
CD->setAtEndRange(SourceRange(A, B));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
|
|
|
|
VisitObjCContainerDecl(ID);
|
|
|
|
ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
|
|
|
|
ID->setSuperClass(cast_or_null<ObjCInterfaceDecl>
|
|
|
|
(Reader.GetDecl(Record[Idx++])));
|
|
|
|
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)
|
|
|
|
ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(),
|
|
|
|
*Reader.getContext());
|
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++])));
|
|
|
|
ID->setForwardDecl(Record[Idx++]);
|
|
|
|
ID->setImplicitInterfaceDecl(Record[Idx++]);
|
|
|
|
ID->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
ID->setSuperClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-07-18 08:33:23 +08:00
|
|
|
ID->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) {
|
|
|
|
VisitFieldDecl(IVD);
|
|
|
|
IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) {
|
|
|
|
VisitObjCContainerDecl(PD);
|
|
|
|
PD->setForwardDecl(Record[Idx++]);
|
|
|
|
PD->setLocEnd(SourceLocation::getFromRawEncoding(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)
|
|
|
|
ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
|
|
|
|
*Reader.getContext());
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) {
|
|
|
|
VisitFieldDecl(FD);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) {
|
|
|
|
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)
|
|
|
|
SLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
CD->setClassList(*Reader.getContext(), ClassRefs.data(), SLocs.data(),
|
|
|
|
NumClassRefs);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) {
|
|
|
|
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)
|
|
|
|
ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
|
|
|
|
*Reader.getContext());
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) {
|
|
|
|
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)
|
|
|
|
ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
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-01-17 00:38:58 +08:00
|
|
|
CD->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
CD->setCategoryNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) {
|
|
|
|
VisitNamedDecl(CAD);
|
|
|
|
CAD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
|
|
|
|
VisitNamedDecl(D);
|
2010-01-22 01:36:00 +08:00
|
|
|
D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
2010-06-05 04:50:08 +08:00
|
|
|
D->setType(Reader.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++])));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::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++])));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
|
|
|
|
VisitObjCImplDecl(D);
|
|
|
|
D->setIdentifier(Reader.GetIdentifierInfo(Record, Idx));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
|
|
|
|
VisitObjCImplDecl(D);
|
|
|
|
D->setSuperClass(
|
|
|
|
cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-04-29 00:11:27 +08:00
|
|
|
// FIXME. Add reading of IvarInitializers and NumIvarInitializers.
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
|
|
|
|
VisitDecl(D);
|
|
|
|
D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
|
|
|
D->setPropertyDecl(
|
|
|
|
cast_or_null<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setPropertyIvarDecl(
|
|
|
|
cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
|
2010-05-06 05:52:17 +08:00
|
|
|
// FIXME. read GetterCXXConstructor and SetterCXXAssignment
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::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++])
|
2009-04-27 13:58:23 +08:00
|
|
|
FD->setBitWidth(Reader.ReadDeclExpr());
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitVarDecl(VarDecl *VD) {
|
2009-08-19 09:28:35 +08:00
|
|
|
VisitDeclaratorDecl(VD);
|
2009-04-27 13:27:42 +08:00
|
|
|
VD->setStorageClass((VarDecl::StorageClass)Record[Idx++]);
|
2010-04-20 06:54:31 +08:00
|
|
|
VD->setStorageClassAsWritten((VarDecl::StorageClass)Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
VD->setThreadSpecified(Record[Idx++]);
|
|
|
|
VD->setCXXDirectInitializer(Record[Idx++]);
|
|
|
|
VD->setDeclaredInCondition(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
|
|
|
VD->setPreviousDeclaration(
|
|
|
|
cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
if (Record[Idx++])
|
2010-02-11 09:19:42 +08:00
|
|
|
VD->setInit(Reader.ReadDeclExpr());
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
|
|
|
|
VisitVarDecl(PD);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
|
|
|
|
VisitVarDecl(PD);
|
|
|
|
PD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
|
2010-03-13 02:31:32 +08:00
|
|
|
PD->setHasInheritedDefaultArg(Record[Idx++]);
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) {
|
|
|
|
VisitDecl(AD);
|
2009-04-27 13:58:23 +08:00
|
|
|
AD->setAsmString(cast<StringLiteral>(Reader.ReadDeclExpr()));
|
2009-04-27 13:27:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) {
|
|
|
|
VisitDecl(BD);
|
2009-04-27 13:58:23 +08:00
|
|
|
BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadDeclStmt()));
|
2010-06-04 19:21:44 +08:00
|
|
|
BD->setSignatureAsWritten(Reader.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-05-08 05:43:38 +08:00
|
|
|
void PCHDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
|
|
|
|
VisitDecl(D);
|
|
|
|
D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]);
|
|
|
|
D->setHasBraces(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
|
|
|
|
VisitNamedDecl(D);
|
|
|
|
D->setLBracLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setRBracLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setNextNamespace(
|
|
|
|
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
|
|
|
|
// Only read one reference--the original or anonymous namespace.
|
|
|
|
bool IsOriginal = Record[Idx++];
|
|
|
|
if (IsOriginal)
|
|
|
|
D->setAnonymousNamespace(
|
|
|
|
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
else
|
|
|
|
D->setOriginalNamespace(
|
|
|
|
cast_or_null<NamespaceDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
|
|
|
|
VisitNamedDecl(D);
|
|
|
|
|
|
|
|
D->setAliasLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setQualifierRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
D->setTargetNameLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setAliasedNamespace(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
2010-06-20 22:40:59 +08:00
|
|
|
void PCHDeclReader::VisitUsingDecl(UsingDecl *D) {
|
2010-05-08 05:43:38 +08:00
|
|
|
VisitNamedDecl(D);
|
|
|
|
D->setUsingLocation(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setNestedNameRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
D->setTargetNestedNameDecl(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
D->addShadowDecl(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
D->setTypeName(Record[Idx++]);
|
|
|
|
}
|
|
|
|
|
2010-06-20 22:40:59 +08:00
|
|
|
void PCHDeclReader::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++])));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
|
|
|
|
VisitNamedDecl(D);
|
|
|
|
D->setNamespaceKeyLocation(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setQualifierRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
D->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
D->setIdentLocation(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setNominatedNamespace(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
D->setCommonAncestor(cast_or_null<DeclContext>(
|
|
|
|
Reader.GetDecl(Record[Idx++])));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitUnresolvedUsingValue(UnresolvedUsingValueDecl *D) {
|
|
|
|
VisitValueDecl(D);
|
|
|
|
D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitUnresolvedUsingTypename(
|
|
|
|
UnresolvedUsingTypenameDecl *D) {
|
|
|
|
VisitTypeDecl(D);
|
|
|
|
D->setTargetNestedNameRange(Reader.ReadSourceRange(Record, Idx));
|
|
|
|
D->setUsingLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setTypenameLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setTargetNestedNameSpecifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-06-04 03:28:45 +08:00
|
|
|
CXXBaseSpecifier *PCHDeclReader::ReadCXXBaseSpecifier() {
|
|
|
|
bool isVirtual = static_cast<bool>(Record[Idx++]);
|
|
|
|
bool isBaseOfClass = static_cast<bool>(Record[Idx++]);
|
|
|
|
AccessSpecifier AS = static_cast<AccessSpecifier>(Record[Idx++]);
|
|
|
|
QualType T = Reader.GetType(Record[Idx++]);
|
|
|
|
SourceRange Range = Reader.ReadSourceRange(Record, Idx);
|
|
|
|
return new (*Reader.getContext())
|
|
|
|
CXXBaseSpecifier(Range, isVirtual, isBaseOfClass, AS, T);
|
|
|
|
}
|
|
|
|
|
2010-05-08 05:43:38 +08:00
|
|
|
void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
|
|
|
|
// assert(false && "cannot read CXXRecordDecl");
|
|
|
|
VisitRecordDecl(D);
|
2010-06-20 03:29:09 +08:00
|
|
|
|
|
|
|
enum CXXRecKind {
|
|
|
|
CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
|
|
|
|
};
|
|
|
|
switch ((CXXRecKind)Record[Idx++]) {
|
|
|
|
default:
|
|
|
|
assert(false && "Out of sync with PCHDeclWriter::VisitCXXRecordDecl?");
|
|
|
|
case CXXRecNotTemplate:
|
|
|
|
break;
|
|
|
|
case CXXRecTemplate:
|
|
|
|
D->setDescribedClassTemplate(
|
|
|
|
cast<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++])));
|
|
|
|
break;
|
|
|
|
case CXXRecMemberSpecialization: {
|
|
|
|
CXXRecordDecl *RD = cast<CXXRecordDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
|
|
|
|
SourceLocation POI = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
D->setInstantiationOfMemberClass(RD, TSK);
|
|
|
|
D->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-04 03:28:45 +08:00
|
|
|
|
2010-06-20 03:29:21 +08:00
|
|
|
// FIXME: Hack. See PCHDeclWriter::VisitTypeDecl.
|
|
|
|
D->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
|
|
|
|
|
2010-06-04 03:28:45 +08:00
|
|
|
// FIXME: this is far from complete
|
|
|
|
|
|
|
|
if (D->isDefinition()) {
|
|
|
|
D->setDefinition(false); // make peace with an assertion
|
|
|
|
D->startDefinition();
|
|
|
|
|
|
|
|
unsigned NumBases = Record[Idx++];
|
|
|
|
|
|
|
|
llvm::SmallVector<CXXBaseSpecifier*, 4> Bases;
|
|
|
|
Bases.reserve(NumBases);
|
|
|
|
for (unsigned I = 0; I != NumBases; ++I)
|
|
|
|
Bases.push_back(ReadCXXBaseSpecifier());
|
|
|
|
D->setBases(Bases.begin(), NumBases);
|
|
|
|
|
|
|
|
// FIXME: there's a lot of stuff we do here that's kindof sketchy
|
|
|
|
// if we're leaving the context incomplete.
|
|
|
|
D->completeDefinition();
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
|
|
|
// assert(false && "cannot read CXXMethodDecl");
|
|
|
|
VisitFunctionDecl(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
|
|
|
// assert(false && "cannot read CXXConstructorDecl");
|
|
|
|
VisitCXXMethodDecl(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
|
|
|
|
// assert(false && "cannot read CXXDestructorDecl");
|
|
|
|
VisitCXXMethodDecl(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) {
|
|
|
|
// assert(false && "cannot read CXXConversionDecl");
|
|
|
|
VisitCXXMethodDecl(D);
|
|
|
|
}
|
|
|
|
|
2010-06-05 13:09:32 +08:00
|
|
|
void PCHDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) {
|
|
|
|
VisitDecl(D);
|
|
|
|
D->setColonLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
}
|
|
|
|
|
2010-05-08 05:43:38 +08:00
|
|
|
void PCHDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
|
|
|
|
assert(false && "cannot read FriendTemplateDecl");
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitTemplateDecl(TemplateDecl *D) {
|
2010-06-20 03:29:09 +08:00
|
|
|
VisitNamedDecl(D);
|
|
|
|
|
|
|
|
NamedDecl *TemplatedDecl = cast<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-06-23 21:48:30 +08:00
|
|
|
TemplateParameterList* TemplateParams
|
|
|
|
= Reader.ReadTemplateParameterList(Record, Idx);
|
2010-06-20 03:29:09 +08:00
|
|
|
D->init(TemplatedDecl, TemplateParams);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitClassTemplateDecl(ClassTemplateDecl *D) {
|
2010-06-20 03:29:09 +08:00
|
|
|
VisitTemplateDecl(D);
|
|
|
|
|
|
|
|
ClassTemplateDecl *PrevDecl =
|
|
|
|
cast_or_null<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
2010-06-21 18:57:41 +08:00
|
|
|
D->setPreviousDeclaration(PrevDecl);
|
2010-06-20 03:29:09 +08:00
|
|
|
if (PrevDecl == 0) {
|
|
|
|
// This ClassTemplateDecl owns a CommonPtr; read it.
|
|
|
|
|
|
|
|
unsigned size = Record[Idx++];
|
|
|
|
while (size--) {
|
|
|
|
ClassTemplateSpecializationDecl *CTSD
|
|
|
|
= cast<ClassTemplateSpecializationDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
llvm::FoldingSetNodeID ID;
|
|
|
|
void *InsertPos = 0;
|
|
|
|
ClassTemplateSpecializationDecl::Profile(ID,
|
|
|
|
CTSD->getTemplateArgs().getFlatArgumentList(),
|
|
|
|
CTSD->getTemplateArgs().flat_size(),
|
|
|
|
*Reader.getContext());
|
|
|
|
D->getSpecializations().FindNodeOrInsertPos(ID, InsertPos);
|
|
|
|
D->getSpecializations().InsertNode(CTSD, InsertPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
size = Record[Idx++];
|
|
|
|
while (size--) {
|
|
|
|
ClassTemplatePartialSpecializationDecl *CTSD
|
|
|
|
= cast<ClassTemplatePartialSpecializationDecl>(
|
|
|
|
Reader.GetDecl(Record[Idx++]));
|
|
|
|
llvm::FoldingSetNodeID ID;
|
|
|
|
void *InsertPos = 0;
|
|
|
|
ClassTemplatePartialSpecializationDecl::Profile(ID,
|
|
|
|
CTSD->getTemplateArgs().getFlatArgumentList(),
|
|
|
|
CTSD->getTemplateArgs().flat_size(),
|
|
|
|
*Reader.getContext());
|
|
|
|
D->getPartialSpecializations().FindNodeOrInsertPos(ID, InsertPos);
|
|
|
|
D->getPartialSpecializations().InsertNode(CTSD, InsertPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
// InjectedClassNameType is computed.
|
|
|
|
|
|
|
|
if (ClassTemplateDecl *CTD
|
|
|
|
= cast_or_null<ClassTemplateDecl>(Reader.GetDecl(Record[Idx++]))) {
|
|
|
|
D->setInstantiatedFromMemberTemplate(CTD);
|
|
|
|
if (Record[Idx++])
|
|
|
|
D->setMemberSpecialization();
|
|
|
|
}
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitClassTemplateSpecializationDecl(
|
|
|
|
ClassTemplateSpecializationDecl *D) {
|
2010-06-23 21:48:30 +08:00
|
|
|
VisitCXXRecordDecl(D);
|
|
|
|
|
|
|
|
if (Decl *InstD = Reader.GetDecl(Record[Idx++])) {
|
|
|
|
if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
|
|
|
|
D->setInstantiationOf(CTD);
|
|
|
|
} else {
|
|
|
|
llvm::SmallVector<TemplateArgument, 8> TemplArgs;
|
|
|
|
Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx);
|
|
|
|
D->setInstantiationOf(cast<ClassTemplatePartialSpecializationDecl>(InstD),
|
|
|
|
TemplArgs.data(), TemplArgs.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Explicit info.
|
|
|
|
if (TypeSourceInfo *TyInfo = Reader.GetTypeSourceInfo(Record, Idx)) {
|
|
|
|
D->setTypeAsWritten(TyInfo);
|
|
|
|
D->setExternLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
D->setTemplateKeywordLoc(Reader.ReadSourceLocation(Record, Idx));
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::SmallVector<TemplateArgument, 8> TemplArgs;
|
|
|
|
Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx);
|
|
|
|
D->initTemplateArgs(TemplArgs.data(), TemplArgs.size());
|
|
|
|
SourceLocation POI = Reader.ReadSourceLocation(Record, Idx);
|
|
|
|
if (POI.isValid())
|
|
|
|
D->setPointOfInstantiation(POI);
|
|
|
|
D->setSpecializationKind((TemplateSpecializationKind)Record[Idx++]);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitClassTemplatePartialSpecializationDecl(
|
|
|
|
ClassTemplatePartialSpecializationDecl *D) {
|
2010-06-23 21:48:30 +08:00
|
|
|
VisitClassTemplateSpecializationDecl(D);
|
|
|
|
|
|
|
|
D->initTemplateParameters(Reader.ReadTemplateParameterList(Record, Idx));
|
|
|
|
|
|
|
|
TemplateArgumentListInfo ArgInfos;
|
|
|
|
unsigned NumArgs = Record[Idx++];
|
|
|
|
while (NumArgs--)
|
|
|
|
ArgInfos.addArgument(Reader.ReadTemplateArgumentLoc(Record, Idx));
|
|
|
|
D->initTemplateArgsAsWritten(ArgInfos);
|
|
|
|
|
|
|
|
D->setSequenceNumber(Record[Idx++]);
|
|
|
|
|
|
|
|
// These are read/set from/to the first declaration.
|
|
|
|
if (D->getPreviousDeclaration() == 0) {
|
|
|
|
D->setInstantiatedFromMember(
|
|
|
|
cast_or_null<ClassTemplatePartialSpecializationDecl>(
|
|
|
|
Reader.GetDecl(Record[Idx++])));
|
|
|
|
if (Record[Idx++])
|
|
|
|
D->isMemberSpecialization();
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2010-06-22 17:55:07 +08:00
|
|
|
void PCHDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
|
|
|
|
VisitTemplateDecl(D);
|
|
|
|
|
|
|
|
FunctionTemplateDecl *PrevDecl =
|
|
|
|
cast_or_null<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]));
|
|
|
|
D->setPreviousDeclaration(PrevDecl);
|
|
|
|
if (PrevDecl == 0) {
|
|
|
|
// This FunctionTemplateDecl owns a CommonPtr; read it.
|
|
|
|
|
|
|
|
// FunctionTemplateSpecializationInfos are filled through the
|
|
|
|
// templated FunctionDecl's setFunctionTemplateSpecialization, no need to
|
|
|
|
// read them here.
|
|
|
|
|
|
|
|
if (FunctionTemplateDecl *CTD
|
|
|
|
= cast_or_null<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]))) {
|
|
|
|
D->setInstantiatedFromMemberTemplate(CTD);
|
|
|
|
if (Record[Idx++])
|
|
|
|
D->setMemberSpecialization();
|
|
|
|
}
|
|
|
|
}
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::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++];
|
|
|
|
TypeSourceInfo *DefArg = Reader.GetTypeSourceInfo(Record, Idx);
|
|
|
|
D->setDefaultArgument(DefArg, Inherited);
|
2010-05-08 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
|
|
|
|
assert(false && "cannot read NonTypeTemplateParmDecl");
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
|
|
|
|
assert(false && "cannot read TemplateTemplateParmDecl");
|
|
|
|
}
|
|
|
|
|
|
|
|
void PCHDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) {
|
|
|
|
assert(false && "cannot read StaticAssertDecl");
|
|
|
|
}
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
std::pair<uint64_t, uint64_t>
|
2009-04-27 13:27:42 +08:00
|
|
|
PCHDeclReader::VisitDeclContext(DeclContext *DC) {
|
|
|
|
uint64_t LexicalOffset = Record[Idx++];
|
|
|
|
uint64_t VisibleOffset = Record[Idx++];
|
|
|
|
return std::make_pair(LexicalOffset, VisibleOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
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.
|
|
|
|
Attr *PCHReader::ReadAttributes() {
|
|
|
|
unsigned Code = DeclsCursor.ReadCode();
|
2009-09-09 23:08:12 +08:00
|
|
|
assert(Code == llvm::bitc::UNABBREV_RECORD &&
|
2009-04-27 14:01:06 +08:00
|
|
|
"Expected unabbreviated record"); (void)Code;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 14:01:06 +08:00
|
|
|
RecordData Record;
|
|
|
|
unsigned Idx = 0;
|
|
|
|
unsigned RecCode = DeclsCursor.ReadRecord(Code, Record);
|
2009-09-09 23:08:12 +08:00
|
|
|
assert(RecCode == pch::DECL_ATTR && "Expected attribute record");
|
2009-04-27 14:01:06 +08:00
|
|
|
(void)RecCode;
|
|
|
|
|
|
|
|
#define SIMPLE_ATTR(Name) \
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Name: \
|
2009-04-28 05:45:14 +08:00
|
|
|
New = ::new (*Context) Name##Attr(); \
|
2009-04-27 14:01:06 +08:00
|
|
|
break
|
|
|
|
|
|
|
|
#define STRING_ATTR(Name) \
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Name: \
|
2010-02-11 13:28:37 +08:00
|
|
|
New = ::new (*Context) Name##Attr(*Context, ReadString(Record, Idx)); \
|
2009-04-27 14:01:06 +08:00
|
|
|
break
|
|
|
|
|
|
|
|
#define UNSIGNED_ATTR(Name) \
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Name: \
|
2009-04-28 05:45:14 +08:00
|
|
|
New = ::new (*Context) Name##Attr(Record[Idx++]); \
|
2009-04-27 14:01:06 +08:00
|
|
|
break
|
|
|
|
|
|
|
|
Attr *Attrs = 0;
|
|
|
|
while (Idx < Record.size()) {
|
|
|
|
Attr *New = 0;
|
2010-06-17 07:43:53 +08:00
|
|
|
attr::Kind Kind = (attr::Kind)Record[Idx++];
|
2009-04-27 14:01:06 +08:00
|
|
|
bool IsInherited = Record[Idx++];
|
|
|
|
|
|
|
|
switch (Kind) {
|
2010-01-10 20:58:08 +08:00
|
|
|
default:
|
|
|
|
assert(0 && "Unknown attribute!");
|
|
|
|
break;
|
2009-04-27 14:01:06 +08:00
|
|
|
STRING_ATTR(Alias);
|
2010-05-27 10:25:39 +08:00
|
|
|
SIMPLE_ATTR(AlignMac68k);
|
2009-04-27 14:01:06 +08:00
|
|
|
UNSIGNED_ATTR(Aligned);
|
|
|
|
SIMPLE_ATTR(AlwaysInline);
|
|
|
|
SIMPLE_ATTR(AnalyzerNoReturn);
|
|
|
|
STRING_ATTR(Annotate);
|
|
|
|
STRING_ATTR(AsmLabel);
|
2009-11-25 12:20:27 +08:00
|
|
|
SIMPLE_ATTR(BaseCheck);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Blocks:
|
2009-04-28 05:45:14 +08:00
|
|
|
New = ::new (*Context) BlocksAttr(
|
2009-04-27 14:01:06 +08:00
|
|
|
(BlocksAttr::BlocksAttrTypes)Record[Idx++]);
|
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-11-10 02:38:53 +08:00
|
|
|
SIMPLE_ATTR(CDecl);
|
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Cleanup:
|
2009-04-28 05:45:14 +08:00
|
|
|
New = ::new (*Context) CleanupAttr(
|
2009-04-27 14:01:06 +08:00
|
|
|
cast<FunctionDecl>(GetDecl(Record[Idx++])));
|
|
|
|
break;
|
|
|
|
|
|
|
|
SIMPLE_ATTR(Const);
|
|
|
|
UNSIGNED_ATTR(Constructor);
|
|
|
|
SIMPLE_ATTR(DLLExport);
|
|
|
|
SIMPLE_ATTR(DLLImport);
|
|
|
|
SIMPLE_ATTR(Deprecated);
|
|
|
|
UNSIGNED_ATTR(Destructor);
|
|
|
|
SIMPLE_ATTR(FastCall);
|
2009-11-21 16:43:09 +08:00
|
|
|
SIMPLE_ATTR(Final);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Format: {
|
2009-04-27 14:01:06 +08:00
|
|
|
std::string Type = ReadString(Record, Idx);
|
|
|
|
unsigned FormatIdx = Record[Idx++];
|
|
|
|
unsigned FirstArg = Record[Idx++];
|
2010-02-11 13:28:37 +08:00
|
|
|
New = ::new (*Context) FormatAttr(*Context, Type, FormatIdx, FirstArg);
|
2009-04-27 14:01:06 +08:00
|
|
|
break;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::FormatArg: {
|
2009-05-21 01:41:43 +08:00
|
|
|
unsigned FormatIdx = Record[Idx++];
|
|
|
|
New = ::new (*Context) FormatArgAttr(FormatIdx);
|
|
|
|
break;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Sentinel: {
|
2009-05-14 02:09:35 +08:00
|
|
|
int sentinel = Record[Idx++];
|
|
|
|
int nullPos = Record[Idx++];
|
|
|
|
New = ::new (*Context) SentinelAttr(sentinel, nullPos);
|
|
|
|
break;
|
|
|
|
}
|
2009-04-27 14:01:06 +08:00
|
|
|
|
|
|
|
SIMPLE_ATTR(GNUInline);
|
2009-11-25 12:20:27 +08:00
|
|
|
SIMPLE_ATTR(Hiding);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::IBAction:
|
2010-02-17 10:37:45 +08:00
|
|
|
New = ::new (*Context) IBActionAttr();
|
|
|
|
break;
|
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::IBOutlet:
|
2009-04-28 05:45:14 +08:00
|
|
|
New = ::new (*Context) IBOutletAttr();
|
2009-04-27 14:01:06 +08:00
|
|
|
break;
|
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::IBOutletCollection: {
|
2010-05-20 01:38:06 +08:00
|
|
|
ObjCInterfaceDecl *D =
|
|
|
|
cast_or_null<ObjCInterfaceDecl>(GetDecl(Record[Idx++]));
|
|
|
|
New = ::new (*Context) IBOutletCollectionAttr(D);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-08-10 04:07:29 +08:00
|
|
|
SIMPLE_ATTR(Malloc);
|
2009-08-27 06:31:08 +08:00
|
|
|
SIMPLE_ATTR(NoDebug);
|
|
|
|
SIMPLE_ATTR(NoInline);
|
2009-04-27 14:01:06 +08:00
|
|
|
SIMPLE_ATTR(NoReturn);
|
|
|
|
SIMPLE_ATTR(NoThrow);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::NonNull: {
|
2009-04-27 14:01:06 +08:00
|
|
|
unsigned Size = Record[Idx++];
|
|
|
|
llvm::SmallVector<unsigned, 16> ArgNums;
|
|
|
|
ArgNums.insert(ArgNums.end(), &Record[Idx], &Record[Idx] + Size);
|
|
|
|
Idx += Size;
|
2010-02-11 15:31:47 +08:00
|
|
|
New = ::new (*Context) NonNullAttr(*Context, ArgNums.data(), Size);
|
2009-04-27 14:01:06 +08:00
|
|
|
break;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::ReqdWorkGroupSize: {
|
2009-06-26 14:32:41 +08:00
|
|
|
unsigned X = Record[Idx++];
|
|
|
|
unsigned Y = Record[Idx++];
|
|
|
|
unsigned Z = Record[Idx++];
|
|
|
|
New = ::new (*Context) ReqdWorkGroupSizeAttr(X, Y, Z);
|
|
|
|
break;
|
|
|
|
}
|
2009-04-27 14:01:06 +08:00
|
|
|
|
|
|
|
SIMPLE_ATTR(ObjCException);
|
|
|
|
SIMPLE_ATTR(ObjCNSObject);
|
2010-02-18 08:05:45 +08:00
|
|
|
SIMPLE_ATTR(CFReturnsNotRetained);
|
2009-05-09 10:44:38 +08:00
|
|
|
SIMPLE_ATTR(CFReturnsRetained);
|
2010-02-18 08:05:45 +08:00
|
|
|
SIMPLE_ATTR(NSReturnsNotRetained);
|
2009-05-09 10:44:38 +08:00
|
|
|
SIMPLE_ATTR(NSReturnsRetained);
|
2009-04-27 14:01:06 +08:00
|
|
|
SIMPLE_ATTR(Overloadable);
|
2009-11-25 12:20:27 +08:00
|
|
|
SIMPLE_ATTR(Override);
|
2009-08-09 02:23:56 +08:00
|
|
|
SIMPLE_ATTR(Packed);
|
2010-05-27 09:12:46 +08:00
|
|
|
UNSIGNED_ATTR(MaxFieldAlignment);
|
2009-04-27 14:01:06 +08:00
|
|
|
SIMPLE_ATTR(Pure);
|
|
|
|
UNSIGNED_ATTR(Regparm);
|
|
|
|
STRING_ATTR(Section);
|
|
|
|
SIMPLE_ATTR(StdCall);
|
2010-05-19 00:57:00 +08:00
|
|
|
SIMPLE_ATTR(ThisCall);
|
2009-04-27 14:01:06 +08:00
|
|
|
SIMPLE_ATTR(TransparentUnion);
|
|
|
|
SIMPLE_ATTR(Unavailable);
|
|
|
|
SIMPLE_ATTR(Unused);
|
|
|
|
SIMPLE_ATTR(Used);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-06-17 07:43:53 +08:00
|
|
|
case attr::Visibility:
|
2009-04-28 05:45:14 +08:00
|
|
|
New = ::new (*Context) VisibilityAttr(
|
2009-04-27 14:01:06 +08:00
|
|
|
(VisibilityAttr::VisibilityTypes)Record[Idx++]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
SIMPLE_ATTR(WarnUnusedResult);
|
|
|
|
SIMPLE_ATTR(Weak);
|
2010-02-24 06:00:30 +08:00
|
|
|
SIMPLE_ATTR(WeakRef);
|
2009-04-27 14:01:06 +08:00
|
|
|
SIMPLE_ATTR(WeakImport);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(New && "Unable to decode attribute?");
|
|
|
|
New->setInherited(IsInherited);
|
|
|
|
New->setNext(Attrs);
|
|
|
|
Attrs = New;
|
|
|
|
}
|
|
|
|
#undef UNSIGNED_ATTR
|
|
|
|
#undef STRING_ATTR
|
|
|
|
#undef SIMPLE_ATTR
|
|
|
|
|
|
|
|
// The list of attributes was built backwards. Reverse the list
|
|
|
|
// before returning it.
|
|
|
|
Attr *PrevAttr = 0, *NextAttr = 0;
|
|
|
|
while (Attrs) {
|
|
|
|
NextAttr = Attrs->getNext();
|
|
|
|
Attrs->setNext(PrevAttr);
|
|
|
|
PrevAttr = Attrs;
|
|
|
|
Attrs = NextAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return PrevAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// PCHReader Implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
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.
|
|
|
|
inline void PCHReader::LoadedDecl(unsigned Index, Decl *D) {
|
|
|
|
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))
|
|
|
|
return Var->isFileVarDecl() && Var->getInit();
|
|
|
|
if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D))
|
|
|
|
return Func->isThisDeclarationADefinition();
|
|
|
|
return isa<ObjCProtocolDecl>(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Read the declaration at the given offset from the PCH file.
|
|
|
|
Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
|
|
|
|
// 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
|
|
|
|
2009-07-07 02:54:52 +08:00
|
|
|
// Note that we are loading a declaration record.
|
|
|
|
LoadingTypeOrDecl Loading(*this);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 13:58:23 +08:00
|
|
|
DeclsCursor.JumpToBit(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;
|
|
|
|
PCHDeclReader Reader(*this, Record, Idx);
|
|
|
|
|
2009-04-27 13:58:23 +08:00
|
|
|
Decl *D = 0;
|
|
|
|
switch ((pch::DeclCode)DeclsCursor.ReadRecord(Code, Record)) {
|
2009-04-27 13:27:42 +08:00
|
|
|
case pch::DECL_ATTR:
|
|
|
|
case pch::DECL_CONTEXT_LEXICAL:
|
|
|
|
case pch::DECL_CONTEXT_VISIBLE:
|
|
|
|
assert(false && "Record cannot be de-serialized with ReadDeclRecord");
|
|
|
|
break;
|
|
|
|
case pch::DECL_TRANSLATION_UNIT:
|
|
|
|
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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::DECL_ENUM:
|
2009-07-21 22:46:17 +08:00
|
|
|
D = EnumDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::DECL_RECORD:
|
2010-05-12 05:36:43 +08:00
|
|
|
D = RecordDecl::Create(*Context, TTK_Struct, 0, SourceLocation(),
|
2009-07-21 22:46:17 +08:00
|
|
|
0, SourceLocation(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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-05-08 05:43:38 +08:00
|
|
|
case pch::DECL_LINKAGE_SPEC:
|
|
|
|
D = LinkageSpecDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
(LinkageSpecDecl::LanguageIDs)0,
|
|
|
|
false);
|
|
|
|
break;
|
|
|
|
case pch::DECL_NAMESPACE:
|
|
|
|
D = NamespaceDecl::Create(*Context, 0, SourceLocation(), 0);
|
|
|
|
break;
|
|
|
|
case pch::DECL_NAMESPACE_ALIAS:
|
|
|
|
D = NamespaceAliasDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceLocation(), 0, SourceRange(), 0,
|
|
|
|
SourceLocation(), 0);
|
|
|
|
break;
|
|
|
|
case pch::DECL_USING:
|
|
|
|
D = UsingDecl::Create(*Context, 0, SourceLocation(), SourceRange(),
|
|
|
|
SourceLocation(), 0, DeclarationName(), false);
|
|
|
|
break;
|
|
|
|
case pch::DECL_USING_SHADOW:
|
|
|
|
D = UsingShadowDecl::Create(*Context, 0, SourceLocation(), 0, 0);
|
|
|
|
break;
|
|
|
|
case pch::DECL_USING_DIRECTIVE:
|
|
|
|
D = UsingDirectiveDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceLocation(), SourceRange(), 0,
|
|
|
|
SourceLocation(), 0, 0);
|
|
|
|
break;
|
|
|
|
case pch::DECL_UNRESOLVED_USING_VALUE:
|
|
|
|
D = UnresolvedUsingValueDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceRange(), 0, SourceLocation(),
|
|
|
|
DeclarationName());
|
|
|
|
break;
|
|
|
|
case pch::DECL_UNRESOLVED_USING_TYPENAME:
|
|
|
|
D = UnresolvedUsingTypenameDecl::Create(*Context, 0, SourceLocation(),
|
|
|
|
SourceLocation(), SourceRange(),
|
|
|
|
0, SourceLocation(),
|
|
|
|
DeclarationName());
|
|
|
|
break;
|
|
|
|
case pch::DECL_CXX_RECORD:
|
2010-05-12 05:36:43 +08:00
|
|
|
D = CXXRecordDecl::Create(*Context, TTK_Struct, 0,
|
2010-05-08 05:43:38 +08:00
|
|
|
SourceLocation(), 0, SourceLocation(), 0);
|
|
|
|
break;
|
|
|
|
case pch::DECL_CXX_METHOD:
|
|
|
|
D = CXXMethodDecl::Create(*Context, 0, SourceLocation(), DeclarationName(),
|
|
|
|
QualType(), 0);
|
|
|
|
break;
|
|
|
|
case pch::DECL_CXX_CONSTRUCTOR:
|
|
|
|
D = CXXConstructorDecl::Create(*Context, Decl::EmptyShell());
|
|
|
|
break;
|
|
|
|
case pch::DECL_CXX_DESTRUCTOR:
|
|
|
|
D = CXXDestructorDecl::Create(*Context, Decl::EmptyShell());
|
|
|
|
break;
|
|
|
|
case pch::DECL_CXX_CONVERSION:
|
|
|
|
D = CXXConversionDecl::Create(*Context, Decl::EmptyShell());
|
|
|
|
break;
|
2010-06-05 13:09:32 +08:00
|
|
|
case pch::DECL_ACCESS_SPEC:
|
|
|
|
D = AccessSpecDecl::Create(*Context, AS_none, 0, SourceLocation(),
|
|
|
|
SourceLocation());
|
|
|
|
break;
|
2010-05-08 05:43:38 +08:00
|
|
|
case pch::DECL_FRIEND:
|
|
|
|
assert(false && "cannot read FriendDecl");
|
|
|
|
break;
|
|
|
|
case pch::DECL_FRIEND_TEMPLATE:
|
|
|
|
assert(false && "cannot read FriendTemplateDecl");
|
|
|
|
break;
|
|
|
|
case pch::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;
|
|
|
|
case pch::DECL_CLASS_TEMPLATE_SPECIALIZATION:
|
2010-06-23 21:48:30 +08:00
|
|
|
D = ClassTemplateSpecializationDecl::CreateEmpty(*Context);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
|
|
|
case pch::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION:
|
2010-06-23 21:48:30 +08:00
|
|
|
D = ClassTemplatePartialSpecializationDecl::CreateEmpty(*Context);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
|
|
|
case pch::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;
|
|
|
|
case pch::DECL_TEMPLATE_TYPE_PARM:
|
2010-06-20 03:29:09 +08:00
|
|
|
D = TemplateTypeParmDecl::Create(*Context, 0, SourceLocation(), 0,0,0,0,0);
|
2010-05-08 05:43:38 +08:00
|
|
|
break;
|
|
|
|
case pch::DECL_NON_TYPE_TEMPLATE_PARM:
|
|
|
|
assert(false && "cannot read NonTypeTemplateParmDecl");
|
|
|
|
break;
|
|
|
|
case pch::DECL_TEMPLATE_TEMPLATE_PARM:
|
|
|
|
assert(false && "cannot read TemplateTemplateParmDecl");
|
|
|
|
break;
|
|
|
|
case pch::DECL_STATIC_ASSERT:
|
|
|
|
assert(false && "cannot read StaticAssertDecl");
|
|
|
|
break;
|
|
|
|
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::DECL_OBJC_INTERFACE:
|
2009-04-28 05:45:14 +08:00
|
|
|
D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
|
|
|
case pch::DECL_VAR:
|
2009-08-19 09:27:57 +08:00
|
|
|
D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
|
2010-04-20 06:54:31 +08:00
|
|
|
VarDecl::None, VarDecl::None);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case pch::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;
|
|
|
|
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::DECL_PARM_VAR:
|
2009-09-09 23:08:12 +08:00
|
|
|
D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
|
2010-04-20 06:54:31 +08:00
|
|
|
VarDecl::None, VarDecl::None, 0);
|
2009-04-27 13:27:42 +08:00
|
|
|
break;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
2009-04-27 14:01:06 +08:00
|
|
|
case pch::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;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(D && "Unknown declaration reading PCH 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);
|
|
|
|
DeclContextOffsets[DC] = Offsets;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(Idx == Record.size());
|
|
|
|
|
|
|
|
// If we have deserialized a declaration that has a definition the
|
|
|
|
// AST consumer might need to know about, notify the consumer
|
|
|
|
// about that definition now or queue it for later.
|
|
|
|
if (isConsumerInterestedIn(D)) {
|
|
|
|
if (Consumer) {
|
|
|
|
DeclGroupRef DG(D);
|
|
|
|
Consumer->HandleTopLevelDecl(DG);
|
|
|
|
} else {
|
|
|
|
InterestingDecls.push_back(D);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return D;
|
|
|
|
}
|