зеркало из https://github.com/microsoft/clang-1.git
update to use the new BitcodeCursor readRecord that takes a StringRef blob parameter,
and adopt "advance" in more places. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172951 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d47afb96a3
Коммит
b3ce35764a
|
@ -671,17 +671,16 @@ bool ASTReader::ReadDeclContextStorage(ModuleFile &M,
|
||||||
Cursor.JumpToBit(Offsets.first);
|
Cursor.JumpToBit(Offsets.first);
|
||||||
|
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
const char *Blob;
|
StringRef Blob;
|
||||||
unsigned BlobLen;
|
|
||||||
unsigned Code = Cursor.ReadCode();
|
unsigned Code = Cursor.ReadCode();
|
||||||
unsigned RecCode = Cursor.ReadRecord(Code, Record, Blob, BlobLen);
|
unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
|
||||||
if (RecCode != DECL_CONTEXT_LEXICAL) {
|
if (RecCode != DECL_CONTEXT_LEXICAL) {
|
||||||
Error("Expected lexical block");
|
Error("Expected lexical block");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info.LexicalDecls = reinterpret_cast<const KindDeclIDPair*>(Blob);
|
Info.LexicalDecls = reinterpret_cast<const KindDeclIDPair*>(Blob.data());
|
||||||
Info.NumLexicalDecls = BlobLen / sizeof(KindDeclIDPair);
|
Info.NumLexicalDecls = Blob.size() / sizeof(KindDeclIDPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now the lookup table.
|
// Now the lookup table.
|
||||||
|
@ -689,18 +688,17 @@ bool ASTReader::ReadDeclContextStorage(ModuleFile &M,
|
||||||
Cursor.JumpToBit(Offsets.second);
|
Cursor.JumpToBit(Offsets.second);
|
||||||
|
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
const char *Blob;
|
StringRef Blob;
|
||||||
unsigned BlobLen;
|
|
||||||
unsigned Code = Cursor.ReadCode();
|
unsigned Code = Cursor.ReadCode();
|
||||||
unsigned RecCode = Cursor.ReadRecord(Code, Record, Blob, BlobLen);
|
unsigned RecCode = Cursor.readRecord(Code, Record, &Blob);
|
||||||
if (RecCode != DECL_CONTEXT_VISIBLE) {
|
if (RecCode != DECL_CONTEXT_VISIBLE) {
|
||||||
Error("Expected visible lookup table block");
|
Error("Expected visible lookup table block");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Info.NameLookupTableData
|
Info.NameLookupTableData
|
||||||
= ASTDeclContextNameLookupTable::Create(
|
= ASTDeclContextNameLookupTable::Create(
|
||||||
(const unsigned char *)Blob + Record[0],
|
(const unsigned char *)Blob.data() + Record[0],
|
||||||
(const unsigned char *)Blob,
|
(const unsigned char *)Blob.data(),
|
||||||
ASTDeclContextNameLookupTrait(*this, M));
|
ASTDeclContextNameLookupTrait(*this, M));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,10 +809,8 @@ bool ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read a record.
|
// Read a record.
|
||||||
const char *BlobStart;
|
|
||||||
unsigned BlobLen;
|
|
||||||
Record.clear();
|
Record.clear();
|
||||||
switch (SLocEntryCursor.ReadRecord(E.ID, Record, BlobStart, BlobLen)) {
|
switch (SLocEntryCursor.readRecord(E.ID, Record)) {
|
||||||
default: // Default behavior: ignore.
|
default: // Default behavior: ignore.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -882,9 +878,8 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
const char *BlobStart;
|
StringRef Blob;
|
||||||
unsigned BlobLen;
|
switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) {
|
||||||
switch (SLocEntryCursor.ReadRecord(Entry.ID, Record, BlobStart, BlobLen)) {
|
|
||||||
default:
|
default:
|
||||||
Error("incorrectly-formatted source location entry in AST file");
|
Error("incorrectly-formatted source location entry in AST file");
|
||||||
return true;
|
return true;
|
||||||
|
@ -930,8 +925,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||||
ContentCache->ContentsEntry == ContentCache->OrigEntry) {
|
ContentCache->ContentsEntry == ContentCache->OrigEntry) {
|
||||||
unsigned Code = SLocEntryCursor.ReadCode();
|
unsigned Code = SLocEntryCursor.ReadCode();
|
||||||
Record.clear();
|
Record.clear();
|
||||||
unsigned RecCode
|
unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
|
||||||
= SLocEntryCursor.ReadRecord(Code, Record, BlobStart, BlobLen);
|
|
||||||
|
|
||||||
if (RecCode != SM_SLOC_BUFFER_BLOB) {
|
if (RecCode != SM_SLOC_BUFFER_BLOB) {
|
||||||
Error("AST record has invalid code");
|
Error("AST record has invalid code");
|
||||||
|
@ -939,8 +933,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::MemoryBuffer *Buffer
|
llvm::MemoryBuffer *Buffer
|
||||||
= llvm::MemoryBuffer::getMemBuffer(StringRef(BlobStart, BlobLen - 1),
|
= llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), File->getName());
|
||||||
File->getName());
|
|
||||||
SourceMgr.overrideFileContents(File, Buffer);
|
SourceMgr.overrideFileContents(File, Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,7 +941,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case SM_SLOC_BUFFER_ENTRY: {
|
case SM_SLOC_BUFFER_ENTRY: {
|
||||||
const char *Name = BlobStart;
|
const char *Name = Blob.data();
|
||||||
unsigned Offset = Record[0];
|
unsigned Offset = Record[0];
|
||||||
SrcMgr::CharacteristicKind
|
SrcMgr::CharacteristicKind
|
||||||
FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
|
FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
|
||||||
|
@ -959,7 +952,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||||
unsigned Code = SLocEntryCursor.ReadCode();
|
unsigned Code = SLocEntryCursor.ReadCode();
|
||||||
Record.clear();
|
Record.clear();
|
||||||
unsigned RecCode
|
unsigned RecCode
|
||||||
= SLocEntryCursor.ReadRecord(Code, Record, BlobStart, BlobLen);
|
= SLocEntryCursor.readRecord(Code, Record, &Blob);
|
||||||
|
|
||||||
if (RecCode != SM_SLOC_BUFFER_BLOB) {
|
if (RecCode != SM_SLOC_BUFFER_BLOB) {
|
||||||
Error("AST record has invalid code");
|
Error("AST record has invalid code");
|
||||||
|
@ -967,8 +960,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::MemoryBuffer *Buffer
|
llvm::MemoryBuffer *Buffer
|
||||||
= llvm::MemoryBuffer::getMemBuffer(StringRef(BlobStart, BlobLen - 1),
|
= llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name);
|
||||||
Name);
|
|
||||||
SourceMgr.createFileIDForMemBuffer(Buffer, FileCharacter, ID,
|
SourceMgr.createFileIDForMemBuffer(Buffer, FileCharacter, ID,
|
||||||
BaseOffset + Offset, IncludeLoc);
|
BaseOffset + Offset, IncludeLoc);
|
||||||
break;
|
break;
|
||||||
|
@ -1100,12 +1092,9 @@ void ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read a record.
|
// Read a record.
|
||||||
const char *BlobStart = 0;
|
|
||||||
unsigned BlobLen = 0;
|
|
||||||
Record.clear();
|
Record.clear();
|
||||||
PreprocessorRecordTypes RecType =
|
PreprocessorRecordTypes RecType =
|
||||||
(PreprocessorRecordTypes)Stream.ReadRecord(Entry.ID, Record, BlobStart,
|
(PreprocessorRecordTypes)Stream.readRecord(Entry.ID, Record);
|
||||||
BlobLen);
|
|
||||||
switch (RecType) {
|
switch (RecType) {
|
||||||
case PP_MACRO_OBJECT_LIKE:
|
case PP_MACRO_OBJECT_LIKE:
|
||||||
case PP_MACRO_FUNCTION_LIKE: {
|
case PP_MACRO_FUNCTION_LIKE: {
|
||||||
|
@ -1361,10 +1350,8 @@ void ASTReader::ReadDefinedMacros() {
|
||||||
goto NextCursor;
|
goto NextCursor;
|
||||||
|
|
||||||
case llvm::BitstreamEntry::Record:
|
case llvm::BitstreamEntry::Record:
|
||||||
const char *BlobStart;
|
|
||||||
unsigned BlobLen;
|
|
||||||
Record.clear();
|
Record.clear();
|
||||||
switch (Cursor.ReadRecord(E.ID, Record, BlobStart, BlobLen)) {
|
switch (Cursor.readRecord(E.ID, Record)) {
|
||||||
default: // Default behavior: ignore.
|
default: // Default behavior: ignore.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1470,10 +1457,8 @@ ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
|
||||||
|
|
||||||
unsigned Code = Cursor.ReadCode();
|
unsigned Code = Cursor.ReadCode();
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
const char *BlobStart = 0;
|
StringRef Blob;
|
||||||
unsigned BlobLen = 0;
|
switch ((InputFileRecordTypes)Cursor.readRecord(Code, Record, &Blob)) {
|
||||||
switch ((InputFileRecordTypes)Cursor.ReadRecord(Code, Record,
|
|
||||||
BlobStart, BlobLen)) {
|
|
||||||
case INPUT_FILE: {
|
case INPUT_FILE: {
|
||||||
unsigned StoredID = Record[0];
|
unsigned StoredID = Record[0];
|
||||||
assert(ID == StoredID && "Bogus stored ID or offset");
|
assert(ID == StoredID && "Bogus stored ID or offset");
|
||||||
|
@ -1483,7 +1468,7 @@ ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
|
||||||
bool Overridden = (bool)Record[3];
|
bool Overridden = (bool)Record[3];
|
||||||
|
|
||||||
// Get the file entry for this input file.
|
// Get the file entry for this input file.
|
||||||
StringRef OrigFilename(BlobStart, BlobLen);
|
StringRef OrigFilename = Blob;
|
||||||
std::string Filename = OrigFilename;
|
std::string Filename = OrigFilename;
|
||||||
MaybeAddSystemRootToFilename(F, Filename);
|
MaybeAddSystemRootToFilename(F, Filename);
|
||||||
const FileEntry *File
|
const FileEntry *File
|
||||||
|
@ -1661,10 +1646,8 @@ ASTReader::ReadControlBlock(ModuleFile &F,
|
||||||
|
|
||||||
// Read and process a record.
|
// Read and process a record.
|
||||||
Record.clear();
|
Record.clear();
|
||||||
const char *BlobStart = 0;
|
StringRef Blob;
|
||||||
unsigned BlobLen = 0;
|
switch ((ControlRecordTypes)Stream.readRecord(Entry.ID, Record, &Blob)) {
|
||||||
switch ((ControlRecordTypes)Stream.ReadRecord(Entry.ID, Record,
|
|
||||||
BlobStart, BlobLen)) {
|
|
||||||
case METADATA: {
|
case METADATA: {
|
||||||
if (Record[0] != VERSION_MAJOR && !DisableValidation) {
|
if (Record[0] != VERSION_MAJOR && !DisableValidation) {
|
||||||
if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
|
if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
|
||||||
|
@ -1682,7 +1665,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
|
||||||
F.RelocatablePCH = Record[4];
|
F.RelocatablePCH = Record[4];
|
||||||
|
|
||||||
const std::string &CurBranch = getClangFullRepositoryVersion();
|
const std::string &CurBranch = getClangFullRepositoryVersion();
|
||||||
StringRef ASTBranch(BlobStart, BlobLen);
|
StringRef ASTBranch = Blob;
|
||||||
if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
|
if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
|
||||||
if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
|
if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
|
||||||
Diag(diag::warn_pch_different_branch) << ASTBranch << CurBranch;
|
Diag(diag::warn_pch_different_branch) << ASTBranch << CurBranch;
|
||||||
|
@ -1779,7 +1762,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
|
||||||
|
|
||||||
case ORIGINAL_FILE:
|
case ORIGINAL_FILE:
|
||||||
F.OriginalSourceFileID = FileID::get(Record[0]);
|
F.OriginalSourceFileID = FileID::get(Record[0]);
|
||||||
F.ActualOriginalSourceFileName.assign(BlobStart, BlobLen);
|
F.ActualOriginalSourceFileName = Blob;
|
||||||
F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
|
F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
|
||||||
MaybeAddSystemRootToFilename(F, F.OriginalSourceFileName);
|
MaybeAddSystemRootToFilename(F, F.OriginalSourceFileName);
|
||||||
break;
|
break;
|
||||||
|
@ -1789,11 +1772,11 @@ ASTReader::ReadControlBlock(ModuleFile &F,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ORIGINAL_PCH_DIR:
|
case ORIGINAL_PCH_DIR:
|
||||||
F.OriginalDir.assign(BlobStart, BlobLen);
|
F.OriginalDir = Blob;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_FILE_OFFSETS:
|
case INPUT_FILE_OFFSETS:
|
||||||
F.InputFileOffsets = (const uint32_t *)BlobStart;
|
F.InputFileOffsets = (const uint32_t *)Blob.data();
|
||||||
F.InputFilesLoaded.resize(Record[0]);
|
F.InputFilesLoaded.resize(Record[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1914,10 +1897,8 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
|
|
||||||
// Read and process a record.
|
// Read and process a record.
|
||||||
Record.clear();
|
Record.clear();
|
||||||
const char *BlobStart = 0;
|
StringRef Blob;
|
||||||
unsigned BlobLen = 0;
|
switch ((ASTRecordTypes)Stream.readRecord(Entry.ID, Record, &Blob)) {
|
||||||
switch ((ASTRecordTypes)Stream.ReadRecord(Entry.ID, Record,
|
|
||||||
BlobStart, BlobLen)) {
|
|
||||||
default: // Default behavior: ignore.
|
default: // Default behavior: ignore.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1926,7 +1907,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
Error("duplicate TYPE_OFFSET record in AST file");
|
Error("duplicate TYPE_OFFSET record in AST file");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
F.TypeOffsets = (const uint32_t *)BlobStart;
|
F.TypeOffsets = (const uint32_t *)Blob.data();
|
||||||
F.LocalNumTypes = Record[0];
|
F.LocalNumTypes = Record[0];
|
||||||
unsigned LocalBaseTypeIndex = Record[1];
|
unsigned LocalBaseTypeIndex = Record[1];
|
||||||
F.BaseTypeIndex = getTotalNumTypes();
|
F.BaseTypeIndex = getTotalNumTypes();
|
||||||
|
@ -1950,7 +1931,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
Error("duplicate DECL_OFFSET record in AST file");
|
Error("duplicate DECL_OFFSET record in AST file");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
F.DeclOffsets = (const DeclOffset *)BlobStart;
|
F.DeclOffsets = (const DeclOffset *)Blob.data();
|
||||||
F.LocalNumDecls = Record[0];
|
F.LocalNumDecls = Record[0];
|
||||||
unsigned LocalBaseDeclID = Record[1];
|
unsigned LocalBaseDeclID = Record[1];
|
||||||
F.BaseDeclID = getTotalNumDecls();
|
F.BaseDeclID = getTotalNumDecls();
|
||||||
|
@ -1978,9 +1959,9 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
case TU_UPDATE_LEXICAL: {
|
case TU_UPDATE_LEXICAL: {
|
||||||
DeclContext *TU = Context.getTranslationUnitDecl();
|
DeclContext *TU = Context.getTranslationUnitDecl();
|
||||||
DeclContextInfo &Info = F.DeclContextInfos[TU];
|
DeclContextInfo &Info = F.DeclContextInfos[TU];
|
||||||
Info.LexicalDecls = reinterpret_cast<const KindDeclIDPair *>(BlobStart);
|
Info.LexicalDecls = reinterpret_cast<const KindDeclIDPair *>(Blob.data());
|
||||||
Info.NumLexicalDecls
|
Info.NumLexicalDecls
|
||||||
= static_cast<unsigned int>(BlobLen / sizeof(KindDeclIDPair));
|
= static_cast<unsigned int>(Blob.size() / sizeof(KindDeclIDPair));
|
||||||
TU->setHasExternalLexicalStorage(true);
|
TU->setHasExternalLexicalStorage(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1990,8 +1971,8 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
serialization::DeclID ID = ReadDeclID(F, Record, Idx);
|
serialization::DeclID ID = ReadDeclID(F, Record, Idx);
|
||||||
ASTDeclContextNameLookupTable *Table =
|
ASTDeclContextNameLookupTable *Table =
|
||||||
ASTDeclContextNameLookupTable::Create(
|
ASTDeclContextNameLookupTable::Create(
|
||||||
(const unsigned char *)BlobStart + Record[Idx++],
|
(const unsigned char *)Blob.data() + Record[Idx++],
|
||||||
(const unsigned char *)BlobStart,
|
(const unsigned char *)Blob.data(),
|
||||||
ASTDeclContextNameLookupTrait(*this, F));
|
ASTDeclContextNameLookupTrait(*this, F));
|
||||||
if (ID == PREDEF_DECL_TRANSLATION_UNIT_ID) { // Is it the TU?
|
if (ID == PREDEF_DECL_TRANSLATION_UNIT_ID) { // Is it the TU?
|
||||||
DeclContext *TU = Context.getTranslationUnitDecl();
|
DeclContext *TU = Context.getTranslationUnitDecl();
|
||||||
|
@ -2003,7 +1984,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case IDENTIFIER_TABLE:
|
case IDENTIFIER_TABLE:
|
||||||
F.IdentifierTableData = BlobStart;
|
F.IdentifierTableData = Blob.data();
|
||||||
if (Record[0]) {
|
if (Record[0]) {
|
||||||
F.IdentifierLookupTable
|
F.IdentifierLookupTable
|
||||||
= ASTIdentifierLookupTable::Create(
|
= ASTIdentifierLookupTable::Create(
|
||||||
|
@ -2020,7 +2001,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
Error("duplicate IDENTIFIER_OFFSET record in AST file");
|
Error("duplicate IDENTIFIER_OFFSET record in AST file");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
F.IdentifierOffsets = (const uint32_t *)BlobStart;
|
F.IdentifierOffsets = (const uint32_t *)Blob.data();
|
||||||
F.LocalNumIdentifiers = Record[0];
|
F.LocalNumIdentifiers = Record[0];
|
||||||
unsigned LocalBaseIdentifierID = Record[1];
|
unsigned LocalBaseIdentifierID = Record[1];
|
||||||
F.BaseIdentifierID = getTotalNumIdentifiers();
|
F.BaseIdentifierID = getTotalNumIdentifiers();
|
||||||
|
@ -2098,7 +2079,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SELECTOR_OFFSETS: {
|
case SELECTOR_OFFSETS: {
|
||||||
F.SelectorOffsets = (const uint32_t *)BlobStart;
|
F.SelectorOffsets = (const uint32_t *)Blob.data();
|
||||||
F.LocalNumSelectors = Record[0];
|
F.LocalNumSelectors = Record[0];
|
||||||
unsigned LocalBaseSelectorID = Record[1];
|
unsigned LocalBaseSelectorID = Record[1];
|
||||||
F.BaseSelectorID = getTotalNumSelectors();
|
F.BaseSelectorID = getTotalNumSelectors();
|
||||||
|
@ -2120,7 +2101,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case METHOD_POOL:
|
case METHOD_POOL:
|
||||||
F.SelectorLookupTableData = (const unsigned char *)BlobStart;
|
F.SelectorLookupTableData = (const unsigned char *)Blob.data();
|
||||||
if (Record[0])
|
if (Record[0])
|
||||||
F.SelectorLookupTable
|
F.SelectorLookupTable
|
||||||
= ASTSelectorLookupTable::Create(
|
= ASTSelectorLookupTable::Create(
|
||||||
|
@ -2147,12 +2128,12 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILE_SORTED_DECLS:
|
case FILE_SORTED_DECLS:
|
||||||
F.FileSortedDecls = (const DeclID *)BlobStart;
|
F.FileSortedDecls = (const DeclID *)Blob.data();
|
||||||
F.NumFileSortedDecls = Record[0];
|
F.NumFileSortedDecls = Record[0];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOURCE_LOCATION_OFFSETS: {
|
case SOURCE_LOCATION_OFFSETS: {
|
||||||
F.SLocEntryOffsets = (const uint32_t *)BlobStart;
|
F.SLocEntryOffsets = (const uint32_t *)Blob.data();
|
||||||
F.LocalNumSLocEntries = Record[0];
|
F.LocalNumSLocEntries = Record[0];
|
||||||
unsigned SLocSpaceSize = Record[1];
|
unsigned SLocSpaceSize = Record[1];
|
||||||
llvm::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
|
llvm::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
|
||||||
|
@ -2185,8 +2166,8 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
|
|
||||||
case MODULE_OFFSET_MAP: {
|
case MODULE_OFFSET_MAP: {
|
||||||
// Additional remapping information.
|
// Additional remapping information.
|
||||||
const unsigned char *Data = (const unsigned char*)BlobStart;
|
const unsigned char *Data = (const unsigned char*)Blob.data();
|
||||||
const unsigned char *DataEnd = Data + BlobLen;
|
const unsigned char *DataEnd = Data + Blob.size();
|
||||||
|
|
||||||
// Continuous range maps we may be updating in our module.
|
// Continuous range maps we may be updating in our module.
|
||||||
ContinuousRangeMap<uint32_t, int, 2>::Builder SLocRemap(F.SLocRemap);
|
ContinuousRangeMap<uint32_t, int, 2>::Builder SLocRemap(F.SLocRemap);
|
||||||
|
@ -2322,9 +2303,9 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PPD_ENTITIES_OFFSETS: {
|
case PPD_ENTITIES_OFFSETS: {
|
||||||
F.PreprocessedEntityOffsets = (const PPEntityOffset *)BlobStart;
|
F.PreprocessedEntityOffsets = (const PPEntityOffset *)Blob.data();
|
||||||
assert(BlobLen % sizeof(PPEntityOffset) == 0);
|
assert(Blob.size() % sizeof(PPEntityOffset) == 0);
|
||||||
F.NumPreprocessedEntities = BlobLen / sizeof(PPEntityOffset);
|
F.NumPreprocessedEntities = Blob.size() / sizeof(PPEntityOffset);
|
||||||
|
|
||||||
unsigned LocalBasePreprocessedEntityID = Record[0];
|
unsigned LocalBasePreprocessedEntityID = Record[0];
|
||||||
|
|
||||||
|
@ -2382,7 +2363,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
F.LocalNumObjCCategoriesInMap = Record[0];
|
F.LocalNumObjCCategoriesInMap = Record[0];
|
||||||
F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)BlobStart;
|
F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)Blob.data();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2397,7 +2378,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
F.LocalNumCXXBaseSpecifiers = Record[0];
|
F.LocalNumCXXBaseSpecifiers = Record[0];
|
||||||
F.CXXBaseSpecifiersOffsets = (const uint32_t *)BlobStart;
|
F.CXXBaseSpecifiersOffsets = (const uint32_t *)Blob.data();
|
||||||
NumCXXBaseSpecifiersLoaded += F.LocalNumCXXBaseSpecifiers;
|
NumCXXBaseSpecifiersLoaded += F.LocalNumCXXBaseSpecifiers;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2419,9 +2400,9 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HEADER_SEARCH_TABLE: {
|
case HEADER_SEARCH_TABLE: {
|
||||||
F.HeaderFileInfoTableData = BlobStart;
|
F.HeaderFileInfoTableData = Blob.data();
|
||||||
F.LocalNumHeaderFileInfos = Record[1];
|
F.LocalNumHeaderFileInfos = Record[1];
|
||||||
F.HeaderFileFrameworkStrings = BlobStart + Record[2];
|
F.HeaderFileFrameworkStrings = Blob.data() + Record[2];
|
||||||
if (Record[0]) {
|
if (Record[0]) {
|
||||||
F.HeaderFileInfoTable
|
F.HeaderFileInfoTable
|
||||||
= HeaderFileInfoLookupTable::Create(
|
= HeaderFileInfoLookupTable::Create(
|
||||||
|
@ -2429,7 +2410,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
(const unsigned char *)F.HeaderFileInfoTableData,
|
(const unsigned char *)F.HeaderFileInfoTableData,
|
||||||
HeaderFileInfoTrait(*this, F,
|
HeaderFileInfoTrait(*this, F,
|
||||||
&PP.getHeaderSearchInfo(),
|
&PP.getHeaderSearchInfo(),
|
||||||
BlobStart + Record[2]));
|
Blob.data() + Record[2]));
|
||||||
|
|
||||||
PP.getHeaderSearchInfo().SetExternalSource(this);
|
PP.getHeaderSearchInfo().SetExternalSource(this);
|
||||||
if (!PP.getHeaderSearchInfo().getExternalLookup())
|
if (!PP.getHeaderSearchInfo().getExternalLookup())
|
||||||
|
@ -2483,7 +2464,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
F.LocalNumRedeclarationsInMap = Record[0];
|
F.LocalNumRedeclarationsInMap = Record[0];
|
||||||
F.RedeclarationsMap = (const LocalRedeclarationsInfo *)BlobStart;
|
F.RedeclarationsMap = (const LocalRedeclarationsInfo *)Blob.data();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2502,7 +2483,7 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
|
||||||
Error("duplicate MACRO_OFFSET record in AST file");
|
Error("duplicate MACRO_OFFSET record in AST file");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
F.MacroOffsets = (const uint32_t *)BlobStart;
|
F.MacroOffsets = (const uint32_t *)Blob.data();
|
||||||
F.LocalNumMacros = Record[0];
|
F.LocalNumMacros = Record[0];
|
||||||
unsigned LocalBaseMacroID = Record[1];
|
unsigned LocalBaseMacroID = Record[1];
|
||||||
F.BaseMacroID = getTotalNumMacros();
|
F.BaseMacroID = getTotalNumMacros();
|
||||||
|
@ -3123,11 +3104,9 @@ std::string ASTReader::getOriginalSourceFile(const std::string &ASTFileName,
|
||||||
}
|
}
|
||||||
|
|
||||||
Record.clear();
|
Record.clear();
|
||||||
const char *BlobStart = 0;
|
StringRef Blob;
|
||||||
unsigned BlobLen = 0;
|
if (Stream.readRecord(Entry.ID, Record, &Blob) == ORIGINAL_FILE)
|
||||||
if (Stream.ReadRecord(Entry.ID, Record, BlobStart, BlobLen)
|
return Blob.str();
|
||||||
== ORIGINAL_FILE)
|
|
||||||
return std::string(BlobStart, BlobLen);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3208,17 +3187,15 @@ bool ASTReader::readASTFileControlBlock(StringRef Filename,
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Record.clear();
|
Record.clear();
|
||||||
const char *BlobStart = 0;
|
StringRef Blob;
|
||||||
unsigned BlobLen = 0;
|
unsigned RecCode = Stream.readRecord(Entry.ID, Record, &Blob);
|
||||||
unsigned RecCode = Stream.ReadRecord(Entry.ID, Record, BlobStart, BlobLen);
|
|
||||||
switch ((ControlRecordTypes)RecCode) {
|
switch ((ControlRecordTypes)RecCode) {
|
||||||
case METADATA: {
|
case METADATA: {
|
||||||
if (Record[0] != VERSION_MAJOR)
|
if (Record[0] != VERSION_MAJOR)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const std::string &CurBranch = getClangFullRepositoryVersion();
|
const std::string &CurBranch = getClangFullRepositoryVersion();
|
||||||
StringRef ASTBranch(BlobStart, BlobLen);
|
if (StringRef(CurBranch) != Blob)
|
||||||
if (StringRef(CurBranch) != ASTBranch)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -3300,10 +3277,9 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read a record.
|
// Read a record.
|
||||||
const char *BlobStart;
|
StringRef Blob;
|
||||||
unsigned BlobLen;
|
|
||||||
Record.clear();
|
Record.clear();
|
||||||
switch (F.Stream.ReadRecord(Entry.ID, Record, BlobStart, BlobLen)) {
|
switch (F.Stream.readRecord(Entry.ID, Record, &Blob)) {
|
||||||
default: // Default behavior: ignore.
|
default: // Default behavior: ignore.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -3318,7 +3294,7 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef Name(BlobStart, BlobLen);
|
StringRef Name = Blob;
|
||||||
SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[0]);
|
SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[0]);
|
||||||
SubmoduleID Parent = getGlobalSubmoduleID(F, Record[1]);
|
SubmoduleID Parent = getGlobalSubmoduleID(F, Record[1]);
|
||||||
bool IsFramework = Record[2];
|
bool IsFramework = Record[2];
|
||||||
|
@ -3369,8 +3345,7 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
if (!CurrentModule)
|
if (!CurrentModule)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
StringRef FileName(BlobStart, BlobLen);
|
if (const FileEntry *Umbrella = PP.getFileManager().getFile(Blob)) {
|
||||||
if (const FileEntry *Umbrella = PP.getFileManager().getFile(FileName)) {
|
|
||||||
if (!CurrentModule->getUmbrellaHeader())
|
if (!CurrentModule->getUmbrellaHeader())
|
||||||
ModMap.setUmbrellaHeader(CurrentModule, Umbrella);
|
ModMap.setUmbrellaHeader(CurrentModule, Umbrella);
|
||||||
else if (CurrentModule->getUmbrellaHeader() != Umbrella) {
|
else if (CurrentModule->getUmbrellaHeader() != Umbrella) {
|
||||||
|
@ -3391,8 +3366,7 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// FIXME: Be more lazy about this!
|
// FIXME: Be more lazy about this!
|
||||||
StringRef FileName(BlobStart, BlobLen);
|
if (const FileEntry *File = PP.getFileManager().getFile(Blob)) {
|
||||||
if (const FileEntry *File = PP.getFileManager().getFile(FileName)) {
|
|
||||||
if (std::find(CurrentModule->Headers.begin(),
|
if (std::find(CurrentModule->Headers.begin(),
|
||||||
CurrentModule->Headers.end(),
|
CurrentModule->Headers.end(),
|
||||||
File) == CurrentModule->Headers.end())
|
File) == CurrentModule->Headers.end())
|
||||||
|
@ -3411,8 +3385,7 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// FIXME: Be more lazy about this!
|
// FIXME: Be more lazy about this!
|
||||||
StringRef FileName(BlobStart, BlobLen);
|
if (const FileEntry *File = PP.getFileManager().getFile(Blob)) {
|
||||||
if (const FileEntry *File = PP.getFileManager().getFile(FileName)) {
|
|
||||||
if (std::find(CurrentModule->Headers.begin(),
|
if (std::find(CurrentModule->Headers.begin(),
|
||||||
CurrentModule->Headers.end(),
|
CurrentModule->Headers.end(),
|
||||||
File) == CurrentModule->Headers.end())
|
File) == CurrentModule->Headers.end())
|
||||||
|
@ -3431,8 +3404,7 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// FIXME: Be more lazy about this!
|
// FIXME: Be more lazy about this!
|
||||||
StringRef FileName(BlobStart, BlobLen);
|
if (const FileEntry *File = PP.getFileManager().getFile(Blob))
|
||||||
if (const FileEntry *File = PP.getFileManager().getFile(FileName))
|
|
||||||
CurrentModule->TopHeaders.insert(File);
|
CurrentModule->TopHeaders.insert(File);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3446,9 +3418,8 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
if (!CurrentModule)
|
if (!CurrentModule)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
StringRef DirName(BlobStart, BlobLen);
|
|
||||||
if (const DirectoryEntry *Umbrella
|
if (const DirectoryEntry *Umbrella
|
||||||
= PP.getFileManager().getDirectory(DirName)) {
|
= PP.getFileManager().getDirectory(Blob)) {
|
||||||
if (!CurrentModule->getUmbrellaDir())
|
if (!CurrentModule->getUmbrellaDir())
|
||||||
ModMap.setUmbrellaDir(CurrentModule, Umbrella);
|
ModMap.setUmbrellaDir(CurrentModule, Umbrella);
|
||||||
else if (CurrentModule->getUmbrellaDir() != Umbrella) {
|
else if (CurrentModule->getUmbrellaDir() != Umbrella) {
|
||||||
|
@ -3539,8 +3510,7 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
if (!CurrentModule)
|
if (!CurrentModule)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CurrentModule->addRequirement(StringRef(BlobStart, BlobLen),
|
CurrentModule->addRequirement(Blob, Context.getLangOpts(),
|
||||||
Context.getLangOpts(),
|
|
||||||
Context.getTargetInfo());
|
Context.getTargetInfo());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3555,8 +3525,7 @@ bool ASTReader::ReadSubmoduleBlock(ModuleFile &F) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CurrentModule->LinkLibraries.push_back(
|
CurrentModule->LinkLibraries.push_back(
|
||||||
Module::LinkLibrary(StringRef(BlobStart, BlobLen),
|
Module::LinkLibrary(Blob, Record[0]));
|
||||||
Record[0]));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3763,12 +3732,11 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
||||||
SourceRange Range(ReadSourceLocation(M, PPOffs.Begin),
|
SourceRange Range(ReadSourceLocation(M, PPOffs.Begin),
|
||||||
ReadSourceLocation(M, PPOffs.End));
|
ReadSourceLocation(M, PPOffs.End));
|
||||||
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
|
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
|
||||||
const char *BlobStart = 0;
|
StringRef Blob;
|
||||||
unsigned BlobLen = 0;
|
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
PreprocessorDetailRecordTypes RecType =
|
PreprocessorDetailRecordTypes RecType =
|
||||||
(PreprocessorDetailRecordTypes)M.PreprocessorDetailCursor.ReadRecord(
|
(PreprocessorDetailRecordTypes)M.PreprocessorDetailCursor.readRecord(
|
||||||
Entry.ID, Record, BlobStart, BlobLen);
|
Entry.ID, Record, &Blob);
|
||||||
switch (RecType) {
|
switch (RecType) {
|
||||||
case PPD_MACRO_EXPANSION: {
|
case PPD_MACRO_EXPANSION: {
|
||||||
bool isBuiltin = Record[0];
|
bool isBuiltin = Record[0];
|
||||||
|
@ -3805,8 +3773,8 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case PPD_INCLUSION_DIRECTIVE: {
|
case PPD_INCLUSION_DIRECTIVE: {
|
||||||
const char *FullFileNameStart = BlobStart + Record[0];
|
const char *FullFileNameStart = Blob.data() + Record[0];
|
||||||
StringRef FullFileName(FullFileNameStart, BlobLen - Record[0]);
|
StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
|
||||||
const FileEntry *File = 0;
|
const FileEntry *File = 0;
|
||||||
if (!FullFileName.empty())
|
if (!FullFileName.empty())
|
||||||
File = PP.getFileManager().getFile(FullFileName);
|
File = PP.getFileManager().getFile(FullFileName);
|
||||||
|
@ -3816,7 +3784,7 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
||||||
= static_cast<InclusionDirective::InclusionKind>(Record[2]);
|
= static_cast<InclusionDirective::InclusionKind>(Record[2]);
|
||||||
InclusionDirective *ID
|
InclusionDirective *ID
|
||||||
= new (PPRec) InclusionDirective(PPRec, Kind,
|
= new (PPRec) InclusionDirective(PPRec, Kind,
|
||||||
StringRef(BlobStart, Record[0]),
|
StringRef(Blob.data(), Record[0]),
|
||||||
Record[1], Record[3],
|
Record[1], Record[3],
|
||||||
File,
|
File,
|
||||||
Range);
|
Range);
|
||||||
|
@ -4117,7 +4085,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
|
||||||
DeclsCursor.JumpToBit(Loc.Offset);
|
DeclsCursor.JumpToBit(Loc.Offset);
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
unsigned Code = DeclsCursor.ReadCode();
|
unsigned Code = DeclsCursor.ReadCode();
|
||||||
switch ((TypeCode)DeclsCursor.ReadRecord(Code, Record)) {
|
switch ((TypeCode)DeclsCursor.readRecord(Code, Record)) {
|
||||||
case TYPE_EXT_QUAL: {
|
case TYPE_EXT_QUAL: {
|
||||||
if (Record.size() != 2) {
|
if (Record.size() != 2) {
|
||||||
Error("Incorrect encoding of extended qualifier type");
|
Error("Incorrect encoding of extended qualifier type");
|
||||||
|
@ -4968,7 +4936,7 @@ CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
|
||||||
ReadingKindTracker ReadingKind(Read_Decl, *this);
|
ReadingKindTracker ReadingKind(Read_Decl, *this);
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
unsigned Code = Cursor.ReadCode();
|
unsigned Code = Cursor.ReadCode();
|
||||||
unsigned RecCode = Cursor.ReadRecord(Code, Record);
|
unsigned RecCode = Cursor.readRecord(Code, Record);
|
||||||
if (RecCode != DECL_CXX_BASE_SPECIFIERS) {
|
if (RecCode != DECL_CXX_BASE_SPECIFIERS) {
|
||||||
Error("Malformed AST file: missing C++ base specifiers");
|
Error("Malformed AST file: missing C++ base specifiers");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -6762,7 +6730,7 @@ void ASTReader::ReadComments() {
|
||||||
|
|
||||||
// Read a record.
|
// Read a record.
|
||||||
Record.clear();
|
Record.clear();
|
||||||
switch ((CommentRecordTypes)Cursor.ReadRecord(Entry.ID, Record)) {
|
switch ((CommentRecordTypes)Cursor.readRecord(Entry.ID, Record)) {
|
||||||
case COMMENTS_RAW_COMMENT: {
|
case COMMENTS_RAW_COMMENT: {
|
||||||
unsigned Idx = 0;
|
unsigned Idx = 0;
|
||||||
SourceRange SR = ReadSourceRange(F, Record, Idx);
|
SourceRange SR = ReadSourceRange(F, Record, Idx);
|
||||||
|
|
|
@ -1937,7 +1937,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
|
||||||
ASTDeclReader Reader(*this, *Loc.F, ID, RawLocation, Record,Idx);
|
ASTDeclReader Reader(*this, *Loc.F, ID, RawLocation, Record,Idx);
|
||||||
|
|
||||||
Decl *D = 0;
|
Decl *D = 0;
|
||||||
switch ((DeclCode)DeclsCursor.ReadRecord(Code, Record)) {
|
switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) {
|
||||||
case DECL_CONTEXT_LEXICAL:
|
case DECL_CONTEXT_LEXICAL:
|
||||||
case DECL_CONTEXT_VISIBLE:
|
case DECL_CONTEXT_VISIBLE:
|
||||||
llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord");
|
llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord");
|
||||||
|
@ -2189,7 +2189,7 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
|
||||||
Cursor.JumpToBit(Offset);
|
Cursor.JumpToBit(Offset);
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
unsigned Code = Cursor.ReadCode();
|
unsigned Code = Cursor.ReadCode();
|
||||||
unsigned RecCode = Cursor.ReadRecord(Code, Record);
|
unsigned RecCode = Cursor.readRecord(Code, Record);
|
||||||
(void)RecCode;
|
(void)RecCode;
|
||||||
assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!");
|
assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!");
|
||||||
|
|
||||||
|
|
|
@ -1595,36 +1595,27 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
|
||||||
Stmt::EmptyShell Empty;
|
Stmt::EmptyShell Empty;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
unsigned Code = Cursor.ReadCode();
|
llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
|
||||||
if (Code == llvm::bitc::END_BLOCK) {
|
|
||||||
if (Cursor.ReadBlockEnd()) {
|
switch (Entry.Kind) {
|
||||||
Error("error at end of block in AST file");
|
case llvm::BitstreamEntry::SubBlock: // Handled for us already.
|
||||||
return 0;
|
case llvm::BitstreamEntry::Error:
|
||||||
}
|
Error("malformed block record in AST file");
|
||||||
|
return 0;
|
||||||
|
case llvm::BitstreamEntry::EndBlock:
|
||||||
|
goto Done;
|
||||||
|
case llvm::BitstreamEntry::Record:
|
||||||
|
// The interesting case.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Code == llvm::bitc::ENTER_SUBBLOCK) {
|
|
||||||
// No known subblocks, always skip them.
|
|
||||||
Cursor.ReadSubBlockID();
|
|
||||||
if (Cursor.SkipBlock()) {
|
|
||||||
Error("malformed block record in AST file");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Code == llvm::bitc::DEFINE_ABBREV) {
|
|
||||||
Cursor.ReadAbbrevRecord();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Stmt *S = 0;
|
Stmt *S = 0;
|
||||||
Idx = 0;
|
Idx = 0;
|
||||||
Record.clear();
|
Record.clear();
|
||||||
bool Finished = false;
|
bool Finished = false;
|
||||||
bool IsStmtReference = false;
|
bool IsStmtReference = false;
|
||||||
switch ((StmtCode)Cursor.ReadRecord(Code, Record)) {
|
switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
|
||||||
case STMT_STOP:
|
case STMT_STOP:
|
||||||
Finished = true;
|
Finished = true;
|
||||||
break;
|
break;
|
||||||
|
@ -2249,11 +2240,8 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
|
||||||
assert(Idx == Record.size() && "Invalid deserialization of statement");
|
assert(Idx == Record.size() && "Invalid deserialization of statement");
|
||||||
StmtStack.push_back(S);
|
StmtStack.push_back(S);
|
||||||
}
|
}
|
||||||
|
Done:
|
||||||
#ifndef NDEBUG
|
|
||||||
assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
|
assert(StmtStack.size() > PrevNumStmts && "Read too many sub stmts!");
|
||||||
assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
|
assert(StmtStack.size() == PrevNumStmts + 1 && "Extra expressions on stack!");
|
||||||
#endif
|
|
||||||
|
|
||||||
return StmtStack.pop_back_val();
|
return StmtStack.pop_back_val();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,6 @@ public:
|
||||||
CXLoadedDiagnosticSetImpl() : CXDiagnosticSetImpl(true), FakeFiles(FO) {}
|
CXLoadedDiagnosticSetImpl() : CXDiagnosticSetImpl(true), FakeFiles(FO) {}
|
||||||
virtual ~CXLoadedDiagnosticSetImpl() {}
|
virtual ~CXLoadedDiagnosticSetImpl() {}
|
||||||
|
|
||||||
llvm::StringRef makeString(const char *blob, unsigned blobLen);
|
|
||||||
|
|
||||||
llvm::BumpPtrAllocator Alloc;
|
llvm::BumpPtrAllocator Alloc;
|
||||||
Strings Categories;
|
Strings Categories;
|
||||||
Strings WarningFlags;
|
Strings WarningFlags;
|
||||||
|
@ -48,19 +46,18 @@ public:
|
||||||
FileSystemOptions FO;
|
FileSystemOptions FO;
|
||||||
FileManager FakeFiles;
|
FileManager FakeFiles;
|
||||||
llvm::DenseMap<unsigned, const FileEntry *> Files;
|
llvm::DenseMap<unsigned, const FileEntry *> Files;
|
||||||
|
|
||||||
|
llvm::StringRef makeString(StringRef Blob) {
|
||||||
|
char *mem = Alloc.Allocate<char>(Blob.size() + 1);
|
||||||
|
memcpy(mem, Blob.data(), Blob.size());
|
||||||
|
// Add a null terminator for those clients accessing the buffer
|
||||||
|
// like a c-string.
|
||||||
|
mem[Blob.size()] = '\0';
|
||||||
|
return llvm::StringRef(mem, Blob.size());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::StringRef CXLoadedDiagnosticSetImpl::makeString(const char *blob,
|
|
||||||
unsigned bloblen) {
|
|
||||||
char *mem = Alloc.Allocate<char>(bloblen + 1);
|
|
||||||
memcpy(mem, blob, bloblen);
|
|
||||||
// Add a null terminator for those clients accessing the buffer
|
|
||||||
// like a c-string.
|
|
||||||
mem[bloblen] = '\0';
|
|
||||||
return llvm::StringRef(mem, bloblen);
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -220,16 +217,14 @@ class DiagLoader {
|
||||||
LoadResult readString(CXLoadedDiagnosticSetImpl &TopDiags,
|
LoadResult readString(CXLoadedDiagnosticSetImpl &TopDiags,
|
||||||
Strings &strings, llvm::StringRef errorContext,
|
Strings &strings, llvm::StringRef errorContext,
|
||||||
RecordData &Record,
|
RecordData &Record,
|
||||||
const char *BlobStart,
|
StringRef Blob,
|
||||||
unsigned BlobLen,
|
|
||||||
bool allowEmptyString = false);
|
bool allowEmptyString = false);
|
||||||
|
|
||||||
LoadResult readString(CXLoadedDiagnosticSetImpl &TopDiags,
|
LoadResult readString(CXLoadedDiagnosticSetImpl &TopDiags,
|
||||||
llvm::StringRef &RetStr,
|
llvm::StringRef &RetStr,
|
||||||
llvm::StringRef errorContext,
|
llvm::StringRef errorContext,
|
||||||
RecordData &Record,
|
RecordData &Record,
|
||||||
const char *BlobStart,
|
StringRef Blob,
|
||||||
unsigned BlobLen,
|
|
||||||
bool allowEmptyString = false);
|
bool allowEmptyString = false);
|
||||||
|
|
||||||
LoadResult readRange(CXLoadedDiagnosticSetImpl &TopDiags,
|
LoadResult readRange(CXLoadedDiagnosticSetImpl &TopDiags,
|
||||||
|
@ -422,9 +417,7 @@ LoadResult DiagLoader::readMetaBlock(llvm::BitstreamCursor &Stream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordData Record;
|
RecordData Record;
|
||||||
const char *Blob;
|
unsigned recordID = Stream.readRecord(blockOrCode, Record);
|
||||||
unsigned BlobLen;
|
|
||||||
unsigned recordID = Stream.ReadRecord(blockOrCode, Record, &Blob, &BlobLen);
|
|
||||||
|
|
||||||
if (recordID == serialized_diags::RECORD_VERSION) {
|
if (recordID == serialized_diags::RECORD_VERSION) {
|
||||||
if (Record.size() < 1) {
|
if (Record.size() < 1) {
|
||||||
|
@ -445,29 +438,28 @@ LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
|
||||||
llvm::StringRef &RetStr,
|
llvm::StringRef &RetStr,
|
||||||
llvm::StringRef errorContext,
|
llvm::StringRef errorContext,
|
||||||
RecordData &Record,
|
RecordData &Record,
|
||||||
const char *BlobStart,
|
StringRef Blob,
|
||||||
unsigned BlobLen,
|
|
||||||
bool allowEmptyString) {
|
bool allowEmptyString) {
|
||||||
|
|
||||||
// Basic buffer overflow check.
|
// Basic buffer overflow check.
|
||||||
if (BlobLen > 65536) {
|
if (Blob.size() > 65536) {
|
||||||
reportInvalidFile(std::string("Out-of-bounds string in ") +
|
reportInvalidFile(std::string("Out-of-bounds string in ") +
|
||||||
std::string(errorContext));
|
std::string(errorContext));
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowEmptyString && Record.size() >= 1 && BlobLen == 0) {
|
if (allowEmptyString && Record.size() >= 1 && Blob.size() == 0) {
|
||||||
RetStr = "";
|
RetStr = "";
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Record.size() < 1 || BlobLen == 0) {
|
if (Record.size() < 1 || Blob.size() == 0) {
|
||||||
reportInvalidFile(std::string("Corrupted ") + std::string(errorContext)
|
reportInvalidFile(std::string("Corrupted ") + std::string(errorContext)
|
||||||
+ std::string(" entry"));
|
+ std::string(" entry"));
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
RetStr = TopDiags.makeString(BlobStart, BlobLen);
|
RetStr = TopDiags.makeString(Blob);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,11 +467,10 @@ LoadResult DiagLoader::readString(CXLoadedDiagnosticSetImpl &TopDiags,
|
||||||
Strings &strings,
|
Strings &strings,
|
||||||
llvm::StringRef errorContext,
|
llvm::StringRef errorContext,
|
||||||
RecordData &Record,
|
RecordData &Record,
|
||||||
const char *BlobStart,
|
StringRef Blob,
|
||||||
unsigned BlobLen,
|
|
||||||
bool allowEmptyString) {
|
bool allowEmptyString) {
|
||||||
llvm::StringRef RetStr;
|
llvm::StringRef RetStr;
|
||||||
if (readString(TopDiags, RetStr, errorContext, Record, BlobStart, BlobLen,
|
if (readString(TopDiags, RetStr, errorContext, Record, Blob,
|
||||||
allowEmptyString))
|
allowEmptyString))
|
||||||
return Failure;
|
return Failure;
|
||||||
strings[Record[0]] = RetStr;
|
strings[Record[0]] = RetStr;
|
||||||
|
@ -579,10 +570,8 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream,
|
||||||
|
|
||||||
// Read the record.
|
// Read the record.
|
||||||
Record.clear();
|
Record.clear();
|
||||||
const char *BlobStart = 0;
|
StringRef Blob;
|
||||||
unsigned BlobLen = 0;
|
unsigned recID = Stream.readRecord(blockOrCode, Record, &Blob);
|
||||||
unsigned recID = Stream.ReadRecord(blockOrCode, Record,
|
|
||||||
BlobStart, BlobLen);
|
|
||||||
|
|
||||||
if (recID < serialized_diags::RECORD_FIRST ||
|
if (recID < serialized_diags::RECORD_FIRST ||
|
||||||
recID > serialized_diags::RECORD_LAST)
|
recID > serialized_diags::RECORD_LAST)
|
||||||
|
@ -593,20 +582,19 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream,
|
||||||
continue;
|
continue;
|
||||||
case serialized_diags::RECORD_CATEGORY:
|
case serialized_diags::RECORD_CATEGORY:
|
||||||
if (readString(TopDiags, TopDiags.Categories, "category", Record,
|
if (readString(TopDiags, TopDiags.Categories, "category", Record,
|
||||||
BlobStart, BlobLen,
|
Blob, /* allowEmptyString */ true))
|
||||||
/* allowEmptyString */ true))
|
|
||||||
return Failure;
|
return Failure;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case serialized_diags::RECORD_DIAG_FLAG:
|
case serialized_diags::RECORD_DIAG_FLAG:
|
||||||
if (readString(TopDiags, TopDiags.WarningFlags, "warning flag", Record,
|
if (readString(TopDiags, TopDiags.WarningFlags, "warning flag", Record,
|
||||||
BlobStart, BlobLen))
|
Blob))
|
||||||
return Failure;
|
return Failure;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case serialized_diags::RECORD_FILENAME: {
|
case serialized_diags::RECORD_FILENAME: {
|
||||||
if (readString(TopDiags, TopDiags.FileNames, "filename", Record,
|
if (readString(TopDiags, TopDiags.FileNames, "filename", Record,
|
||||||
BlobStart, BlobLen))
|
Blob))
|
||||||
return Failure;
|
return Failure;
|
||||||
|
|
||||||
if (Record.size() < 3) {
|
if (Record.size() < 3) {
|
||||||
|
@ -636,7 +624,7 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream,
|
||||||
if (readRange(TopDiags, Record, 0, SR))
|
if (readRange(TopDiags, Record, 0, SR))
|
||||||
return Failure;
|
return Failure;
|
||||||
llvm::StringRef RetStr;
|
llvm::StringRef RetStr;
|
||||||
if (readString(TopDiags, RetStr, "FIXIT", Record, BlobStart, BlobLen,
|
if (readString(TopDiags, RetStr, "FIXIT", Record, Blob,
|
||||||
/* allowEmptyString */ true))
|
/* allowEmptyString */ true))
|
||||||
return Failure;
|
return Failure;
|
||||||
D->FixIts.push_back(std::make_pair(SR, createCXString(RetStr, false)));
|
D->FixIts.push_back(std::make_pair(SR, createCXString(RetStr, false)));
|
||||||
|
@ -652,7 +640,7 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream,
|
||||||
unsigned diagFlag = Record[offset++];
|
unsigned diagFlag = Record[offset++];
|
||||||
D->DiagOption = diagFlag ? TopDiags.WarningFlags[diagFlag] : "";
|
D->DiagOption = diagFlag ? TopDiags.WarningFlags[diagFlag] : "";
|
||||||
D->CategoryText = D->category ? TopDiags.Categories[D->category] : "";
|
D->CategoryText = D->category ? TopDiags.Categories[D->category] : "";
|
||||||
D->Spelling = TopDiags.makeString(BlobStart, BlobLen);
|
D->Spelling = TopDiags.makeString(Blob);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче