From: Douglas Gregor Date: Thu, 18 Oct 2012 18:36:53 +0000 (+0000) Subject: Collapse the original file name and original file ID records into a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39c497b6d5e99acecbe03ee173249ee21933e855;p=clang Collapse the original file name and original file ID records into a single record. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166206 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index bed807ae0e..a22cac523b 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -246,15 +246,12 @@ namespace clang { TARGET_OPTIONS = 4, /// \brief Record code for the original file that was used to - /// generate the AST file. - ORIGINAL_FILE_NAME = 5, - - /// \brief Record code for the file ID of the original file used to - /// generate the AST file. - ORIGINAL_FILE_ID = 6, + /// generate the AST file, including both its file ID and its + /// name. + ORIGINAL_FILE = 5, /// \brief The directory that the PCH was originally created in. - ORIGINAL_PCH_DIR = 7 + ORIGINAL_PCH_DIR = 6 }; /// \brief Record types that occur within the AST block itself. diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 019e7c1fbd..20fa2794cc 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1860,24 +1860,17 @@ ASTReader::ASTReadResult ASTReader::ReadControlBlock(ModuleFile &F, break; } - case ORIGINAL_FILE_NAME: + case ORIGINAL_FILE: // Only record from the primary AST file. if (&F == *ModuleMgr.begin()) { - // The primary AST will be the last to get here, so it will be the one - // that's used. + OriginalFileID = FileID::get(Record[0]); + ActualOriginalFileName.assign(BlobStart, BlobLen); OriginalFileName = ActualOriginalFileName; MaybeAddSystemRootToFilename(OriginalFileName); } break; - case ORIGINAL_FILE_ID: - // Only record from the primary AST file. - if (&F == *ModuleMgr.begin()) { - OriginalFileID = FileID::get(Record[0]); - } - break; - case ORIGINAL_PCH_DIR: // Only record from the primary AST file. if (&F == *ModuleMgr.begin()) { @@ -3323,8 +3316,7 @@ std::string ASTReader::getOriginalSourceFile(const std::string &ASTFileName, Record.clear(); const char *BlobStart = 0; unsigned BlobLen = 0; - if (Stream.ReadRecord(Code, Record, &BlobStart, &BlobLen) - == ORIGINAL_FILE_NAME) + if (Stream.ReadRecord(Code, Record, &BlobStart, &BlobLen) == ORIGINAL_FILE) return std::string(BlobStart, BlobLen); } diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 3814ef1e76..ea3db882d7 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -773,8 +773,7 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(IMPORTS); RECORD(LANGUAGE_OPTIONS); RECORD(TARGET_OPTIONS); - RECORD(ORIGINAL_FILE_NAME); - RECORD(ORIGINAL_FILE_ID); + RECORD(ORIGINAL_FILE); RECORD(ORIGINAL_PCH_DIR); // AST Top-Level Block. @@ -1070,7 +1069,8 @@ void ASTWriter::WriteControlBlock(ASTContext &Context, StringRef isysroot, SourceManager &SM = Context.getSourceManager(); if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) { BitCodeAbbrev *FileAbbrev = new BitCodeAbbrev(); - FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE_NAME)); + FileAbbrev->Add(BitCodeAbbrevOp(ORIGINAL_FILE)); + FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // File ID FileAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name unsigned FileAbbrevCode = Stream.EmitAbbrev(FileAbbrev); @@ -1082,12 +1082,10 @@ void ASTWriter::WriteControlBlock(ASTContext &Context, StringRef isysroot, MainFileNameStr = adjustFilenameForRelocatablePCH(MainFileNameStr, isysroot); RecordData Record; - Record.push_back(ORIGINAL_FILE_NAME); + Record.push_back(ORIGINAL_FILE); + Record.push_back(SM.getMainFileID().getOpaqueValue()); Stream.EmitRecordWithBlob(FileAbbrevCode, Record, MainFileNameStr); - Record.clear(); - Record.push_back(SM.getMainFileID().getOpaqueValue()); - Stream.EmitRecord(ORIGINAL_FILE_ID, Record); } // Original PCH directory