Fix a major bug in PCHReader::ReadSelectorBlock().

Also simplify some syntax in PCHWriter::WritePreprocessor(), suggested by Chris.

llvm-svn: 70039
This commit is contained in:
Steve Naroff 2009-04-25 12:07:12 +00:00
parent c8afb09a3b
commit 4f2a71bcdb
2 changed files with 8 additions and 7 deletions

View File

@ -1750,14 +1750,15 @@ bool PCHReader::ReadSelectorBlock() {
for (unsigned SelIdx = 0; SelIdx < NumSels; SelIdx++) {
unsigned NumArgs = Record[Idx++];
KeyIdents.clear();
if (NumArgs <= 1) {
if (NumArgs == 0) {
// If the number of arguments is 0, the we must have an Identifier.
IdentifierInfo *II = DecodeIdentifierInfo(Record[Idx++]);
assert(II && "DecodeIdentifierInfo returned 0");
KeyIdents.push_back(II);
} else {
// For keyword selectors, the Identifier is optional (::: is legal!).
for (unsigned ArgIdx = 0; ArgIdx < NumArgs; ++ArgIdx) {
IdentifierInfo *II = DecodeIdentifierInfo(Record[Idx++]);
assert(II && "DecodeIdentifierInfo returned 0");
KeyIdents.push_back(II);
}
}

View File

@ -1554,11 +1554,11 @@ void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
for (HeaderSearch::header_file_iterator I = HS.header_file_begin(),
E = HS.header_file_end();
I != E; ++I) {
Record.push_back((*I).isImport);
Record.push_back((*I).DirInfo);
Record.push_back((*I).NumIncludes);
if ((*I).ControllingMacro)
AddIdentifierRef((*I).ControllingMacro, Record);
Record.push_back(I->isImport);
Record.push_back(I->DirInfo);
Record.push_back(I->NumIncludes);
if (I->ControllingMacro)
AddIdentifierRef(I->ControllingMacro, Record);
else
Record.push_back(0);
Stream.EmitRecord(pch::PP_HEADER_FILE_INFO, Record);