Collapse the original file name and original file ID records into a

single record. 

llvm-svn: 166206
This commit is contained in:
Douglas Gregor 2012-10-18 18:36:53 +00:00
parent f8a1396882
commit fad10d8568
3 changed files with 14 additions and 27 deletions

View File

@ -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.

View File

@ -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);
}

View File

@ -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);
Stream.EmitRecordWithBlob(FileAbbrevCode, Record, MainFileNameStr);
Record.clear();
Record.push_back(ORIGINAL_FILE);
Record.push_back(SM.getMainFileID().getOpaqueValue());
Stream.EmitRecord(ORIGINAL_FILE_ID, Record);
Stream.EmitRecordWithBlob(FileAbbrevCode, Record, MainFileNameStr);
Record.clear();
}
// Original PCH directory