[cfe-commits] r166206 - in /cfe/trunk: include/clang/Serialization/ASTBitCodes.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp
Douglas Gregor
dgregor at apple.com
Thu Oct 18 11:36:53 PDT 2012
Author: dgregor
Date: Thu Oct 18 13:36:53 2012
New Revision: 166206
URL: http://llvm.org/viewvc/llvm-project?rev=166206&view=rev
Log:
Collapse the original file name and original file ID records into a
single record.
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=166206&r1=166205&r2=166206&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Thu Oct 18 13:36:53 2012
@@ -246,15 +246,12 @@
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.
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=166206&r1=166205&r2=166206&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Oct 18 13:36:53 2012
@@ -1860,24 +1860,17 @@
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 @@
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);
}
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=166206&r1=166205&r2=166206&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Oct 18 13:36:53 2012
@@ -773,8 +773,7 @@
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 @@
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 @@
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
More information about the cfe-commits
mailing list