зеркало из https://github.com/microsoft/clang-1.git
[PCH] Don't store the source range for each preprocessed entity since
we already have the range in the PPEntityOffsets array. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140209 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
290ad8c8eb
Коммит
8f958f14ea
|
@ -2784,10 +2784,10 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
|||
"Corrupted global preprocessed entity map");
|
||||
Module &M = *I->second;
|
||||
unsigned LocalIndex = Index - M.BasePreprocessedEntityID;
|
||||
const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
|
||||
|
||||
SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor);
|
||||
M.PreprocessorDetailCursor.JumpToBit(
|
||||
M.PreprocessedEntityOffsets[LocalIndex].BitOffset);
|
||||
M.PreprocessorDetailCursor.JumpToBit(PPOffs.BitOffset);
|
||||
|
||||
unsigned Code = M.PreprocessorDetailCursor.ReadCode();
|
||||
switch (Code) {
|
||||
|
@ -2812,6 +2812,8 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
|||
}
|
||||
|
||||
// Read the record.
|
||||
SourceRange Range(ReadSourceLocation(M, PPOffs.Begin),
|
||||
ReadSourceLocation(M, PPOffs.End));
|
||||
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
|
||||
const char *BlobStart = 0;
|
||||
unsigned BlobLen = 0;
|
||||
|
@ -2821,16 +2823,14 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
|||
Code, Record, BlobStart, BlobLen);
|
||||
switch (RecType) {
|
||||
case PPD_MACRO_EXPANSION: {
|
||||
SourceRange Range(ReadSourceLocation(M, Record[0]),
|
||||
ReadSourceLocation(M, Record[1]));
|
||||
bool isBuiltin = Record[2];
|
||||
bool isBuiltin = Record[0];
|
||||
IdentifierInfo *Name = 0;
|
||||
MacroDefinition *Def = 0;
|
||||
if (isBuiltin)
|
||||
Name = getLocalIdentifier(M, Record[3]);
|
||||
Name = getLocalIdentifier(M, Record[1]);
|
||||
else {
|
||||
PreprocessedEntityID
|
||||
GlobalID = getGlobalPreprocessedEntityID(M, Record[3]);
|
||||
GlobalID = getGlobalPreprocessedEntityID(M, Record[1]);
|
||||
Def =cast<MacroDefinition>(PPRec.getLoadedPreprocessedEntity(GlobalID-1));
|
||||
}
|
||||
|
||||
|
@ -2846,12 +2846,9 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
|||
case PPD_MACRO_DEFINITION: {
|
||||
// Decode the identifier info and then check again; if the macro is
|
||||
// still defined and associated with the identifier,
|
||||
IdentifierInfo *II = getLocalIdentifier(M, Record[2]);
|
||||
IdentifierInfo *II = getLocalIdentifier(M, Record[0]);
|
||||
MacroDefinition *MD
|
||||
= new (PPRec) MacroDefinition(II,
|
||||
SourceRange(
|
||||
ReadSourceLocation(M, Record[0]),
|
||||
ReadSourceLocation(M, Record[1])));
|
||||
= new (PPRec) MacroDefinition(II, Range);
|
||||
|
||||
if (DeserializationListener)
|
||||
DeserializationListener->MacroDefinitionRead(PPID, MD);
|
||||
|
@ -2860,21 +2857,20 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
|
|||
}
|
||||
|
||||
case PPD_INCLUSION_DIRECTIVE: {
|
||||
const char *FullFileNameStart = BlobStart + Record[2];
|
||||
const char *FullFileNameStart = BlobStart + Record[0];
|
||||
const FileEntry *File
|
||||
= PP.getFileManager().getFile(StringRef(FullFileNameStart,
|
||||
BlobLen - Record[2]));
|
||||
BlobLen - Record[0]));
|
||||
|
||||
// FIXME: Stable encoding
|
||||
InclusionDirective::InclusionKind Kind
|
||||
= static_cast<InclusionDirective::InclusionKind>(Record[4]);
|
||||
= static_cast<InclusionDirective::InclusionKind>(Record[2]);
|
||||
InclusionDirective *ID
|
||||
= new (PPRec) InclusionDirective(PPRec, Kind,
|
||||
StringRef(BlobStart, Record[2]),
|
||||
Record[3],
|
||||
StringRef(BlobStart, Record[0]),
|
||||
Record[1],
|
||||
File,
|
||||
SourceRange(ReadSourceLocation(M, Record[0]),
|
||||
ReadSourceLocation(M, Record[1])));
|
||||
Range);
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1727,8 +1727,6 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
|
|||
{
|
||||
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
|
||||
Abbrev->Add(BitCodeAbbrevOp(PPD_INCLUSION_DIRECTIVE));
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // start location
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // end location
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // filename length
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // in quotes
|
||||
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // kind
|
||||
|
@ -1754,16 +1752,12 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
|
|||
// Record this macro definition's ID.
|
||||
MacroDefinitions[MD] = NextPreprocessorEntityID;
|
||||
|
||||
AddSourceLocation(MD->getSourceRange().getBegin(), Record);
|
||||
AddSourceLocation(MD->getSourceRange().getEnd(), Record);
|
||||
AddIdentifierRef(MD->getName(), Record);
|
||||
Stream.EmitRecord(PPD_MACRO_DEFINITION, Record);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (MacroExpansion *ME = dyn_cast<MacroExpansion>(*E)) {
|
||||
AddSourceLocation(ME->getSourceRange().getBegin(), Record);
|
||||
AddSourceLocation(ME->getSourceRange().getEnd(), Record);
|
||||
Record.push_back(ME->isBuiltinMacro());
|
||||
if (ME->isBuiltinMacro())
|
||||
AddIdentifierRef(ME->getName(), Record);
|
||||
|
@ -1775,8 +1769,6 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
|
|||
|
||||
if (InclusionDirective *ID = dyn_cast<InclusionDirective>(*E)) {
|
||||
Record.push_back(PPD_INCLUSION_DIRECTIVE);
|
||||
AddSourceLocation(ID->getSourceRange().getBegin(), Record);
|
||||
AddSourceLocation(ID->getSourceRange().getEnd(), Record);
|
||||
Record.push_back(ID->getFileName().size());
|
||||
Record.push_back(ID->wasInQuotes());
|
||||
Record.push_back(static_cast<unsigned>(ID->getKind()));
|
||||
|
|
Загрузка…
Ссылка в новой задаче