forked from OSchip/llvm-project
parent
e23371e71d
commit
373a83abdc
|
@ -206,22 +206,6 @@ void PCHDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) {
|
|||
|
||||
void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
||||
VisitDeclaratorDecl(FD);
|
||||
if (Record[Idx++])
|
||||
FD->setLazyBody(Reader.getDeclsCursor().GetCurrentBitNo());
|
||||
FD->setPreviousDeclaration(
|
||||
cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]);
|
||||
FD->setStorageClassAsWritten((FunctionDecl::StorageClass)Record[Idx++]);
|
||||
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->setCopyAssignment(Record[Idx++]);
|
||||
FD->setHasImplicitReturnZero(Record[Idx++]);
|
||||
FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
|
||||
switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
|
||||
default: assert(false && "Unhandled TemplatedKind!");
|
||||
|
@ -250,22 +234,22 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
|||
Reader.ReadTemplateArgumentList(TemplArgs, Record, Idx);
|
||||
|
||||
// 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) {
|
||||
if (Record[Idx++]) { // TemplateArgumentsAsWritten != 0
|
||||
unsigned NumTemplateArgLocs = Record[Idx++];
|
||||
TemplArgLocs.reserve(NumTemplateArgLocs);
|
||||
for (unsigned i=0; i != NumTemplateArgLocs; ++i)
|
||||
TemplArgLocs.push_back(Reader.ReadTemplateArgumentLoc(Record, Idx));
|
||||
|
||||
LAngleLoc = Reader.ReadSourceLocation(Record, Idx);
|
||||
RAngleLoc = Reader.ReadSourceLocation(Record, Idx);
|
||||
}
|
||||
|
||||
FD->setFunctionTemplateSpecialization(Template, TemplArgs.size(),
|
||||
TemplArgs.data(), TSK,
|
||||
NumTemplateArgLocs,
|
||||
NumTemplateArgLocs ? TemplArgLocs.data() : 0,
|
||||
TemplArgLocs.size(),
|
||||
TemplArgLocs.data(),
|
||||
LAngleLoc, RAngleLoc);
|
||||
break;
|
||||
}
|
||||
|
@ -287,7 +271,24 @@ void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Record[Idx++])
|
||||
FD->setLazyBody(Reader.getDeclsCursor().GetCurrentBitNo());
|
||||
FD->setPreviousDeclaration(
|
||||
cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]);
|
||||
FD->setStorageClassAsWritten((FunctionDecl::StorageClass)Record[Idx++]);
|
||||
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->setCopyAssignment(Record[Idx++]);
|
||||
FD->setHasImplicitReturnZero(Record[Idx++]);
|
||||
FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
|
||||
// Read in the parameters.
|
||||
unsigned NumParams = Record[Idx++];
|
||||
llvm::SmallVector<ParmVarDecl *, 16> Params;
|
||||
|
|
|
@ -199,24 +199,6 @@ void PCHDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {
|
|||
void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
|
||||
VisitDeclaratorDecl(D);
|
||||
|
||||
Record.push_back(D->isThisDeclarationADefinition());
|
||||
if (D->isThisDeclarationADefinition())
|
||||
Writer.AddStmt(D->getBody());
|
||||
|
||||
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
|
||||
Record.push_back(D->getStorageClass()); // FIXME: stable encoding
|
||||
Record.push_back(D->getStorageClassAsWritten());
|
||||
Record.push_back(D->isInlineSpecified());
|
||||
Record.push_back(D->isVirtualAsWritten());
|
||||
Record.push_back(D->isPure());
|
||||
Record.push_back(D->hasInheritedPrototype());
|
||||
Record.push_back(D->hasWrittenPrototype());
|
||||
Record.push_back(D->isDeleted());
|
||||
Record.push_back(D->isTrivial());
|
||||
Record.push_back(D->isCopyAssignment());
|
||||
Record.push_back(D->hasImplicitReturnZero());
|
||||
Writer.AddSourceLocation(D->getLocEnd(), Record);
|
||||
|
||||
Record.push_back(D->getTemplatedKind());
|
||||
switch (D->getTemplatedKind()) {
|
||||
default: assert(false && "Unhandled TemplatedKind!");
|
||||
|
@ -243,6 +225,7 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
|
|||
Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record);
|
||||
|
||||
// Template args as written.
|
||||
Record.push_back(FTSInfo->TemplateArgumentsAsWritten != 0);
|
||||
if (FTSInfo->TemplateArgumentsAsWritten) {
|
||||
Record.push_back(FTSInfo->TemplateArgumentsAsWritten->size());
|
||||
for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->size(); i!=e; ++i)
|
||||
|
@ -252,8 +235,6 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
|
|||
Record);
|
||||
Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->getRAngleLoc(),
|
||||
Record);
|
||||
} else {
|
||||
Record.push_back(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -274,6 +255,26 @@ void PCHDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
|
|||
}
|
||||
}
|
||||
|
||||
// Make sure no Exprs are emitted after the body, because when reading the
|
||||
// function, the body doesn't get read so the cursor doesn't advance.
|
||||
Record.push_back(D->isThisDeclarationADefinition());
|
||||
if (D->isThisDeclarationADefinition())
|
||||
Writer.AddStmt(D->getBody());
|
||||
|
||||
Writer.AddDeclRef(D->getPreviousDeclaration(), Record);
|
||||
Record.push_back(D->getStorageClass()); // FIXME: stable encoding
|
||||
Record.push_back(D->getStorageClassAsWritten());
|
||||
Record.push_back(D->isInlineSpecified());
|
||||
Record.push_back(D->isVirtualAsWritten());
|
||||
Record.push_back(D->isPure());
|
||||
Record.push_back(D->hasInheritedPrototype());
|
||||
Record.push_back(D->hasWrittenPrototype());
|
||||
Record.push_back(D->isDeleted());
|
||||
Record.push_back(D->isTrivial());
|
||||
Record.push_back(D->isCopyAssignment());
|
||||
Record.push_back(D->hasImplicitReturnZero());
|
||||
Writer.AddSourceLocation(D->getLocEnd(), Record);
|
||||
|
||||
Record.push_back(D->param_size());
|
||||
for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end();
|
||||
P != PEnd; ++P)
|
||||
|
|
Loading…
Reference in New Issue