From 8f958f14eadb9ae2019bcca6ecd6ad7520cde5ea Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 20 Sep 2011 23:27:41 +0000 Subject: [PATCH] [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 --- lib/Serialization/ASTReader.cpp | 34 +++++++++++++++------------------ lib/Serialization/ASTWriter.cpp | 8 -------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 213db4b6c2..6e8d1cb22f 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -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(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(Record[4]); + = static_cast(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; } } diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index d491bdd5fc..3286a17779 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -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(*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(*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(ID->getKind()));