r247183 - Revert "EmitRecordWith* API change: takes an ArrayRef instead of a SmallVector (NFC)"
Mehdi Amini via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 13:35:37 PDT 2015
Author: mehdi_amini
Date: Wed Sep 9 15:35:37 2015
New Revision: 247183
URL: http://llvm.org/viewvc/llvm-project?rev=247183&view=rev
Log:
Revert "EmitRecordWith* API change: takes an ArrayRef instead of a SmallVector (NFC)"
This reverts commit r247179.
From: Mehdi Amini <mehdi.amini at apple.com>
Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=247183&r1=247182&r2=247183&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Sep 9 15:35:37 2015
@@ -84,7 +84,6 @@ class ASTWriter : public ASTDeserializat
public:
typedef SmallVector<uint64_t, 64> RecordData;
typedef SmallVectorImpl<uint64_t> RecordDataImpl;
- typedef ArrayRef<uint64_t> RecordDataRef;
friend class ASTDeclWriter;
friend class ASTStmtWriter;
@@ -757,7 +756,7 @@ public:
void AddPath(StringRef Path, RecordDataImpl &Record);
/// \brief Emit the current record with the given path as a blob.
- void EmitRecordWithPath(unsigned Abbrev, const RecordDataRef &Record,
+ void EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
StringRef Path);
/// \brief Add a version tuple to the given record
Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=247183&r1=247182&r2=247183&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Wed Sep 9 15:35:37 2015
@@ -51,7 +51,6 @@ public:
typedef SmallVector<uint64_t, 64> RecordData;
typedef SmallVectorImpl<uint64_t> RecordDataImpl;
-typedef ArrayRef<uint64_t> RecordDataRef;
class SDiagsWriter;
@@ -394,9 +393,13 @@ unsigned SDiagsWriter::getEmitFile(const
// Lazily generate the record for the file.
entry = State->Files.size();
+ RecordData Record;
+ Record.push_back(RECORD_FILENAME);
+ Record.push_back(entry);
+ Record.push_back(0); // For legacy.
+ Record.push_back(0); // For legacy.
StringRef Name(FileName);
- RecordDataRef Record = {RECORD_FILENAME, entry, 0 /* For legacy */,
- 0 /* For legacy */, Name.size()};
+ Record.push_back(Name.size());
State->Stream.EmitRecordWithBlob(State->Abbrevs.get(RECORD_FILENAME), Record,
Name);
@@ -409,7 +412,7 @@ void SDiagsWriter::EmitCharSourceRange(C
State->Record.push_back(RECORD_SOURCE_RANGE);
AddCharSourceRangeToRecord(R, State->Record, SM);
State->Stream.EmitRecordWithAbbrev(State->Abbrevs.get(RECORD_SOURCE_RANGE),
- makeArrayRef(State->Record));
+ State->Record);
}
/// \brief Emits the preamble of the diagnostics file.
@@ -528,11 +531,14 @@ void SDiagsWriter::EmitBlockInfoBlock()
void SDiagsWriter::EmitMetaBlock() {
llvm::BitstreamWriter &Stream = State->Stream;
+ RecordData &Record = State->Record;
AbbreviationMap &Abbrevs = State->Abbrevs;
Stream.EnterSubblock(BLOCK_META, 3);
- RecordDataRef Record = {RECORD_VERSION, VersionNumber};
- Stream.EmitRecordWithAbbrev(Abbrevs.get(RECORD_VERSION), Record);
+ Record.clear();
+ Record.push_back(RECORD_VERSION);
+ Record.push_back(VersionNumber);
+ Stream.EmitRecordWithAbbrev(Abbrevs.get(RECORD_VERSION), Record);
Stream.ExitBlock();
}
@@ -542,8 +548,11 @@ unsigned SDiagsWriter::getEmitCategory(u
// We use a local version of 'Record' so that we can be generating
// another record when we lazily generate one for the category entry.
+ RecordData Record;
+ Record.push_back(RECORD_CATEGORY);
+ Record.push_back(category);
StringRef catName = DiagnosticIDs::getCategoryNameFromID(category);
- RecordDataRef Record = {RECORD_CATEGORY, category, catName.size()};
+ Record.push_back(catName.size());
State->Stream.EmitRecordWithBlob(State->Abbrevs.get(RECORD_CATEGORY), Record,
catName);
@@ -572,7 +581,10 @@ unsigned SDiagsWriter::getEmitDiagnostic
entry.second = FlagName;
// Lazily emit the string in a separate record.
- RecordDataRef Record = {RECORD_DIAG_FLAG, entry.first, FlagName.size()};
+ RecordData Record;
+ Record.push_back(RECORD_DIAG_FLAG);
+ Record.push_back(entry.first);
+ Record.push_back(FlagName.size());
State->Stream.EmitRecordWithBlob(State->Abbrevs.get(RECORD_DIAG_FLAG),
Record, FlagName);
}
@@ -670,8 +682,7 @@ void SDiagsWriter::EmitDiagnosticMessage
}
Record.push_back(Message.size());
- Stream.EmitRecordWithBlob(Abbrevs.get(RECORD_DIAG), makeArrayRef(Record),
- Message);
+ Stream.EmitRecordWithBlob(Abbrevs.get(RECORD_DIAG), Record, Message);
}
void
@@ -730,7 +741,7 @@ void SDiagsWriter::EmitCodeContext(Small
Record.push_back(RECORD_FIXIT);
AddCharSourceRangeToRecord(Fix.RemoveRange, Record, SM);
Record.push_back(Fix.CodeToInsert.size());
- Stream.EmitRecordWithBlob(Abbrevs.get(RECORD_FIXIT), makeArrayRef(Record),
+ Stream.EmitRecordWithBlob(Abbrevs.get(RECORD_FIXIT), Record,
Fix.CodeToInsert);
}
}
@@ -833,9 +844,17 @@ std::error_code SDiagsMerger::visitEndOf
std::error_code
SDiagsMerger::visitSourceRangeRecord(const serialized_diags::Location &Start,
const serialized_diags::Location &End) {
- RecordDataRef Record = {
- RECORD_SOURCE_RANGE, FileLookup[Start.FileID], Start.Line, Start.Col,
- Start.Offset, FileLookup[End.FileID], End.Line, End.Col, End.Offset};
+ RecordData Record;
+ Record.push_back(RECORD_SOURCE_RANGE);
+ Record.push_back(FileLookup[Start.FileID]);
+ Record.push_back(Start.Line);
+ Record.push_back(Start.Col);
+ Record.push_back(Start.Offset);
+ Record.push_back(FileLookup[End.FileID]);
+ Record.push_back(End.Line);
+ Record.push_back(End.Col);
+ Record.push_back(End.Offset);
+
Writer.State->Stream.EmitRecordWithAbbrev(
Writer.State->Abbrevs.get(RECORD_SOURCE_RANGE), Record);
return std::error_code();
@@ -844,13 +863,19 @@ SDiagsMerger::visitSourceRangeRecord(con
std::error_code SDiagsMerger::visitDiagnosticRecord(
unsigned Severity, const serialized_diags::Location &Location,
unsigned Category, unsigned Flag, StringRef Message) {
- RecordDataRef Record = {RECORD_DIAG, Severity, FileLookup[Location.FileID],
- Location.Line, Location.Col, Location.Offset,
- CategoryLookup[Category],
- Flag ? DiagFlagLookup[Flag] : 0, Message.size()};
+ RecordData MergedRecord;
+ MergedRecord.push_back(RECORD_DIAG);
+ MergedRecord.push_back(Severity);
+ MergedRecord.push_back(FileLookup[Location.FileID]);
+ MergedRecord.push_back(Location.Line);
+ MergedRecord.push_back(Location.Col);
+ MergedRecord.push_back(Location.Offset);
+ MergedRecord.push_back(CategoryLookup[Category]);
+ MergedRecord.push_back(Flag ? DiagFlagLookup[Flag] : 0);
+ MergedRecord.push_back(Message.size());
Writer.State->Stream.EmitRecordWithBlob(
- Writer.State->Abbrevs.get(RECORD_DIAG), Record, Message);
+ Writer.State->Abbrevs.get(RECORD_DIAG), MergedRecord, Message);
return std::error_code();
}
@@ -858,9 +883,17 @@ std::error_code
SDiagsMerger::visitFixitRecord(const serialized_diags::Location &Start,
const serialized_diags::Location &End,
StringRef Text) {
- RecordDataRef Record = {RECORD_FIXIT, FileLookup[Start.FileID], Start.Line,
- Start.Col, Start.Offset, FileLookup[End.FileID],
- End.Line, End.Col, End.Offset, Text.size()};
+ RecordData Record;
+ Record.push_back(RECORD_FIXIT);
+ Record.push_back(FileLookup[Start.FileID]);
+ Record.push_back(Start.Line);
+ Record.push_back(Start.Col);
+ Record.push_back(Start.Offset);
+ Record.push_back(FileLookup[End.FileID]);
+ Record.push_back(End.Line);
+ Record.push_back(End.Col);
+ Record.push_back(End.Offset);
+ Record.push_back(Text.size());
Writer.State->Stream.EmitRecordWithBlob(
Writer.State->Abbrevs.get(RECORD_FIXIT), Record, Text);
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=247183&r1=247182&r2=247183&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Sep 9 15:35:37 2015
@@ -1171,7 +1171,8 @@ void ASTWriter::WriteControlBlock(Prepro
const std::string &OutputFile) {
using namespace llvm;
Stream.EnterSubblock(CONTROL_BLOCK_ID, 5);
-
+ RecordData Record;
+
// Metadata
BitCodeAbbrev *MetadataAbbrev = new BitCodeAbbrev();
MetadataAbbrev->Add(BitCodeAbbrevOp(METADATA));
@@ -1184,23 +1185,27 @@ void ASTWriter::WriteControlBlock(Prepro
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Errors
MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // SVN branch/tag
unsigned MetadataAbbrevCode = Stream.EmitAbbrev(MetadataAbbrev);
+ Record.push_back(METADATA);
+ Record.push_back(VERSION_MAJOR);
+ Record.push_back(VERSION_MINOR);
+ Record.push_back(CLANG_VERSION_MAJOR);
+ Record.push_back(CLANG_VERSION_MINOR);
assert((!WritingModule || isysroot.empty()) &&
"writing module as a relocatable PCH?");
- {
- RecordDataRef Record = {METADATA, VERSION_MAJOR, VERSION_MINOR,
- CLANG_VERSION_MAJOR, CLANG_VERSION_MINOR,
- !isysroot.empty(), IncludeTimestamps,
- ASTHasCompilerErrors};
- Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
- getClangFullRepositoryVersion());
- }
+ Record.push_back(!isysroot.empty());
+ Record.push_back(IncludeTimestamps);
+ Record.push_back(ASTHasCompilerErrors);
+ Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,
+ getClangFullRepositoryVersion());
+
if (WritingModule) {
// For implicit modules we output a signature that we can use to ensure
// duplicate module builds don't collide in the cache as their output order
// is non-deterministic.
// FIXME: Remove this when output is deterministic.
if (Context.getLangOpts().ImplicitModules) {
- RecordData Record = {getSignature()};
+ Record.clear();
+ Record.push_back(getSignature());
Stream.EmitRecord(SIGNATURE, Record);
}
@@ -1209,7 +1214,8 @@ void ASTWriter::WriteControlBlock(Prepro
Abbrev->Add(BitCodeAbbrevOp(MODULE_NAME));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name
unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
- RecordDataRef Record = {MODULE_NAME};
+ RecordData Record;
+ Record.push_back(MODULE_NAME);
Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);
}
@@ -1230,7 +1236,8 @@ void ASTWriter::WriteControlBlock(Prepro
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Directory
unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
- RecordDataRef Record = {MODULE_DIRECTORY};
+ RecordData Record;
+ Record.push_back(MODULE_DIRECTORY);
Stream.EmitRecordWithBlob(AbbrevCode, Record, BaseDir);
}
@@ -1243,7 +1250,7 @@ void ASTWriter::WriteControlBlock(Prepro
// Module map file
if (WritingModule) {
- RecordData Record;
+ Record.clear();
auto &Map = PP.getHeaderSearchInfo().getModuleMap();
@@ -1266,7 +1273,7 @@ void ASTWriter::WriteControlBlock(Prepro
// Imports
if (Chain) {
serialization::ModuleManager &Mgr = Chain->getModuleManager();
- RecordData Record;
+ Record.clear();
for (auto *M : Mgr) {
// Skip modules that weren't directly imported.
@@ -1287,7 +1294,7 @@ void ASTWriter::WriteControlBlock(Prepro
Stream.EnterSubblock(OPTIONS_BLOCK_ID, 4);
// Language options.
- RecordData Record;
+ Record.clear();
const LangOptions &LangOpts = Context.getLangOpts();
#define LANGOPT(Name, Bits, Default, Description) \
Record.push_back(LangOpts.Name);
@@ -1459,7 +1466,8 @@ void ASTWriter::WriteControlBlock(Prepro
SM.getFileManager().makeAbsolutePath(OutputPath);
StringRef origDir = llvm::sys::path::parent_path(OutputPath);
- RecordDataRef Record = {ORIGINAL_PCH_DIR};
+ RecordData Record;
+ Record.push_back(ORIGINAL_PCH_DIR);
Stream.EmitRecordWithBlob(AbbrevCode, Record, origDir);
}
@@ -1483,7 +1491,8 @@ void ASTWriter::WriteInputFiles(SourceMa
bool Modules) {
using namespace llvm;
Stream.EnterSubblock(INPUT_FILES_BLOCK_ID, 4);
-
+ RecordData Record;
+
// Create input-file abbreviation.
BitCodeAbbrev *IFAbbrev = new BitCodeAbbrev();
IFAbbrev->Add(BitCodeAbbrevOp(INPUT_FILE));
@@ -1538,11 +1547,16 @@ void ASTWriter::WriteInputFiles(SourceMa
if (!Entry.IsSystemFile)
++UserFilesNum;
+ Record.clear();
+ Record.push_back(INPUT_FILE);
+ Record.push_back(InputFileOffsets.size());
+
// Emit size/modification time for this file.
- // And whether this file was overridden.
- RecordDataRef Record = {
- INPUT_FILE, InputFileOffsets.size(), (uint64_t)Entry.File->getSize(),
- (uint64_t)getTimestampForOutput(Entry.File), Entry.BufferOverridden};
+ Record.push_back(Entry.File->getSize());
+ Record.push_back(getTimestampForOutput(Entry.File));
+
+ // Whether this file was overridden.
+ Record.push_back(Entry.BufferOverridden);
EmitRecordWithPath(IFAbbrevCode, Record, Entry.File->getName());
}
@@ -1559,8 +1573,10 @@ void ASTWriter::WriteInputFiles(SourceMa
unsigned OffsetsAbbrevCode = Stream.EmitAbbrev(OffsetsAbbrev);
// Write input file offsets.
- RecordDataRef Record = {INPUT_FILE_OFFSETS, InputFileOffsets.size(),
- UserFilesNum};
+ Record.clear();
+ Record.push_back(INPUT_FILE_OFFSETS);
+ Record.push_back(InputFileOffsets.size());
+ Record.push_back(UserFilesNum);
Stream.EmitRecordWithBlob(OffsetsAbbrevCode, Record, bytes(InputFileOffsets));
}
@@ -1802,8 +1818,11 @@ void ASTWriter::WriteHeaderSearch(const
unsigned TableAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the header search table
- RecordDataRef Record = {HEADER_SEARCH_TABLE, BucketOffset,
- NumHeaderSearchEntries, TableData.size()};
+ RecordData Record;
+ Record.push_back(HEADER_SEARCH_TABLE);
+ Record.push_back(BucketOffset);
+ Record.push_back(NumHeaderSearchEntries);
+ Record.push_back(TableData.size());
TableData.append(GeneratorTrait.strings_begin(),GeneratorTrait.strings_end());
Stream.EmitRecordWithBlob(TableAbbrev, Record, TableData);
@@ -1888,11 +1907,12 @@ void ASTWriter::WriteSourceManagerBlock(
Record.push_back(0);
Record.push_back(0);
}
-
- Stream.EmitRecordWithAbbrev(SLocFileAbbrv, makeArrayRef(Record));
-
+
+ Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
+
if (Content->BufferOverridden) {
- RecordDataRef Record = {SM_SLOC_BUFFER_BLOB};
+ Record.clear();
+ Record.push_back(SM_SLOC_BUFFER_BLOB);
const llvm::MemoryBuffer *Buffer
= Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager());
Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
@@ -1909,9 +1929,10 @@ void ASTWriter::WriteSourceManagerBlock(
const llvm::MemoryBuffer *Buffer
= Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager());
const char *Name = Buffer->getBufferIdentifier();
- Stream.EmitRecordWithBlob(SLocBufferAbbrv, makeArrayRef(Record),
+ Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
StringRef(Name, strlen(Name) + 1));
- RecordDataRef Record = {SM_SLOC_BUFFER_BLOB};
+ Record.clear();
+ Record.push_back(SM_SLOC_BUFFER_BLOB);
Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
StringRef(Buffer->getBufferStart(),
Buffer->getBufferSize() + 1));
@@ -1933,7 +1954,7 @@ void ASTWriter::WriteSourceManagerBlock(
if (I + 1 != N)
NextOffset = SourceMgr.getLocalSLocEntry(I + 1).getOffset();
Record.push_back(NextOffset - SLoc->getOffset() - 1);
- Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, makeArrayRef(Record));
+ Stream.EmitRecordWithAbbrev(SLocExpansionAbbrv, Record);
}
}
@@ -1951,13 +1972,13 @@ void ASTWriter::WriteSourceManagerBlock(
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // total size
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(Abbrev);
- {
- RecordDataRef Record = {SOURCE_LOCATION_OFFSETS, SLocEntryOffsets.size(),
- SourceMgr.getNextLocalOffset() -
- 1 /* skip dummy */};
- Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
- bytes(SLocEntryOffsets));
- }
+
+ Record.clear();
+ Record.push_back(SOURCE_LOCATION_OFFSETS);
+ Record.push_back(SLocEntryOffsets.size());
+ Record.push_back(SourceMgr.getNextLocalOffset() - 1); // skip dummy
+ Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record, bytes(SLocEntryOffsets));
+
// Write the source location entry preloads array, telling the AST
// reader which source locations entries it should load eagerly.
Stream.EmitRecord(SOURCE_LOCATION_PRELOADS, PreloadSLocs);
@@ -2211,11 +2232,12 @@ void ASTWriter::WritePreprocessor(const
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned MacroOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
- {
- RecordDataRef Record = {MACRO_OFFSET, MacroOffsets.size(),
- FirstMacroID - NUM_PREDEF_MACRO_IDS};
- Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record, bytes(MacroOffsets));
- }
+ Record.clear();
+ Record.push_back(MACRO_OFFSET);
+ Record.push_back(MacroOffsets.size());
+ Record.push_back(FirstMacroID - NUM_PREDEF_MACRO_IDS);
+ Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record,
+ bytes(MacroOffsets));
}
void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
@@ -2289,7 +2311,7 @@ void ASTWriter::WritePreprocessorDetail(
// we create a PCH even with compiler errors.
if (ID->getFile())
Buffer += ID->getFile()->getName();
- Stream.EmitRecordWithBlob(InclusionAbbrev, makeArrayRef(Record), Buffer);
+ Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
continue;
}
@@ -2309,8 +2331,9 @@ void ASTWriter::WritePreprocessorDetail(
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned PPEOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
- RecordDataRef Record = {PPD_ENTITIES_OFFSETS, FirstPreprocessorEntityID -
- NUM_PREDEF_PP_ENTITY_IDS};
+ Record.clear();
+ Record.push_back(PPD_ENTITIES_OFFSETS);
+ Record.push_back(FirstPreprocessorEntityID - NUM_PREDEF_PP_ENTITY_IDS);
Stream.EmitRecordWithBlob(PPEOffsetAbbrev, Record,
bytes(PreprocessedEntityOffsets));
}
@@ -2449,37 +2472,45 @@ void ASTWriter::WriteSubmodules(Module *
Module *Mod = Q.front();
Q.pop();
unsigned ID = getSubmoduleID(Mod);
-
- uint64_t ParentID = 0;
+
+ // Emit the definition of the block.
+ Record.clear();
+ Record.push_back(SUBMODULE_DEFINITION);
+ Record.push_back(ID);
if (Mod->Parent) {
assert(SubmoduleIDs[Mod->Parent] && "Submodule parent not written?");
- ParentID = SubmoduleIDs[Mod->Parent];
- }
-
- // Emit the definition of the block.
- {
- RecordDataRef Record = {
- SUBMODULE_DEFINITION, ID, ParentID, Mod->IsFramework, Mod->IsExplicit,
- Mod->IsSystem, Mod->IsExternC, Mod->InferSubmodules,
- Mod->InferExplicitSubmodules, Mod->InferExportWildcard,
- Mod->ConfigMacrosExhaustive};
- Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
+ Record.push_back(SubmoduleIDs[Mod->Parent]);
+ } else {
+ Record.push_back(0);
}
-
+ Record.push_back(Mod->IsFramework);
+ Record.push_back(Mod->IsExplicit);
+ Record.push_back(Mod->IsSystem);
+ Record.push_back(Mod->IsExternC);
+ Record.push_back(Mod->InferSubmodules);
+ Record.push_back(Mod->InferExplicitSubmodules);
+ Record.push_back(Mod->InferExportWildcard);
+ Record.push_back(Mod->ConfigMacrosExhaustive);
+ Stream.EmitRecordWithBlob(DefinitionAbbrev, Record, Mod->Name);
+
// Emit the requirements.
for (const auto &R : Mod->Requirements) {
- RecordDataRef Record = {SUBMODULE_REQUIRES, R.second};
+ Record.clear();
+ Record.push_back(SUBMODULE_REQUIRES);
+ Record.push_back(R.second);
Stream.EmitRecordWithBlob(RequiresAbbrev, Record, R.first);
}
// Emit the umbrella header, if there is one.
if (auto UmbrellaHeader = Mod->getUmbrellaHeader()) {
- RecordDataRef Record = {SUBMODULE_UMBRELLA_HEADER};
+ Record.clear();
+ Record.push_back(SUBMODULE_UMBRELLA_HEADER);
Stream.EmitRecordWithBlob(UmbrellaAbbrev, Record,
UmbrellaHeader.NameAsWritten);
} else if (auto UmbrellaDir = Mod->getUmbrellaDir()) {
- RecordDataRef Record = {SUBMODULE_UMBRELLA_DIR};
- Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
+ Record.clear();
+ Record.push_back(SUBMODULE_UMBRELLA_DIR);
+ Stream.EmitRecordWithBlob(UmbrellaDirAbbrev, Record,
UmbrellaDir.NameAsWritten);
}
@@ -2497,7 +2528,8 @@ void ASTWriter::WriteSubmodules(Module *
{SUBMODULE_EXCLUDED_HEADER, ExcludedHeaderAbbrev, Module::HK_Excluded}
};
for (auto &HL : HeaderLists) {
- RecordDataRef Record = {HL.RecordKind};
+ Record.clear();
+ Record.push_back(HL.RecordKind);
for (auto &H : Mod->Headers[HL.HeaderKind])
Stream.EmitRecordWithBlob(HL.Abbrev, Record, H.NameAsWritten);
}
@@ -2505,14 +2537,15 @@ void ASTWriter::WriteSubmodules(Module *
// Emit the top headers.
{
auto TopHeaders = Mod->getTopHeaders(PP->getFileManager());
- RecordDataRef Record = {SUBMODULE_TOPHEADER};
+ Record.clear();
+ Record.push_back(SUBMODULE_TOPHEADER);
for (auto *H : TopHeaders)
Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, H->getName());
}
// Emit the imports.
if (!Mod->Imports.empty()) {
- RecordData Record;
+ Record.clear();
for (auto *I : Mod->Imports)
Record.push_back(getSubmoduleID(I));
Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
@@ -2520,7 +2553,7 @@ void ASTWriter::WriteSubmodules(Module *
// Emit the exports.
if (!Mod->Exports.empty()) {
- RecordData Record;
+ Record.clear();
for (const auto &E : Mod->Exports) {
// FIXME: This may fail; we don't require that all exported modules
// are local or imported.
@@ -2536,21 +2569,26 @@ void ASTWriter::WriteSubmodules(Module *
// Emit the link libraries.
for (const auto &LL : Mod->LinkLibraries) {
- RecordDataRef Record = {SUBMODULE_LINK_LIBRARY, LL.IsFramework};
+ Record.clear();
+ Record.push_back(SUBMODULE_LINK_LIBRARY);
+ Record.push_back(LL.IsFramework);
Stream.EmitRecordWithBlob(LinkLibraryAbbrev, Record, LL.Library);
}
// Emit the conflicts.
for (const auto &C : Mod->Conflicts) {
+ Record.clear();
+ Record.push_back(SUBMODULE_CONFLICT);
// FIXME: This may fail; we don't require that all conflicting modules
// are local or imported.
- RecordDataRef Record = {SUBMODULE_CONFLICT, getSubmoduleID(C.Other)};
+ Record.push_back(getSubmoduleID(C.Other));
Stream.EmitRecordWithBlob(ConflictAbbrev, Record, C.Message);
}
// Emit the configuration macros.
for (const auto &CM : Mod->ConfigMacros) {
- RecordDataRef Record = {SUBMODULE_CONFIG_MACRO};
+ Record.clear();
+ Record.push_back(SUBMODULE_CONFIG_MACRO);
Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
}
@@ -2632,6 +2670,8 @@ void ASTWriter::WriteCXXCtorInitializers
if (CXXCtorInitializersOffsets.empty())
return;
+ RecordData Record;
+
// Create a blob abbreviation for the C++ ctor initializer offsets.
using namespace llvm;
@@ -2642,8 +2682,9 @@ void ASTWriter::WriteCXXCtorInitializers
unsigned CtorInitializersOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the base specifier offsets table.
- RecordDataRef Record = {CXX_CTOR_INITIALIZERS_OFFSETS,
- CXXCtorInitializersOffsets.size()};
+ Record.clear();
+ Record.push_back(CXX_CTOR_INITIALIZERS_OFFSETS);
+ Record.push_back(CXXCtorInitializersOffsets.size());
Stream.EmitRecordWithBlob(CtorInitializersOffsetAbbrev, Record,
bytes(CXXCtorInitializersOffsets));
}
@@ -2652,6 +2693,8 @@ void ASTWriter::WriteCXXBaseSpecifiersOf
if (CXXBaseSpecifiersOffsets.empty())
return;
+ RecordData Record;
+
// Create a blob abbreviation for the C++ base specifiers offsets.
using namespace llvm;
@@ -2662,8 +2705,9 @@ void ASTWriter::WriteCXXBaseSpecifiersOf
unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the base specifier offsets table.
- RecordDataRef Record = {CXX_BASE_SPECIFIER_OFFSETS,
- CXXBaseSpecifiersOffsets.size()};
+ Record.clear();
+ Record.push_back(CXX_BASE_SPECIFIER_OFFSETS);
+ Record.push_back(CXXBaseSpecifiersOffsets.size());
Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record,
bytes(CXXBaseSpecifiersOffsets));
}
@@ -2734,6 +2778,8 @@ uint64_t ASTWriter::WriteDeclContextLexi
return 0;
uint64_t Offset = Stream.GetCurrentBitNo();
+ RecordData Record;
+ Record.push_back(DECL_CONTEXT_LEXICAL);
SmallVector<uint32_t, 128> KindDeclPairs;
for (const auto *D : DC->decls()) {
KindDeclPairs.push_back(D->getKind());
@@ -2741,7 +2787,6 @@ uint64_t ASTWriter::WriteDeclContextLexi
}
++NumLexicalDeclContexts;
- RecordDataRef Record = {DECL_CONTEXT_LEXICAL};
Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
bytes(KindDeclPairs));
return Offset;
@@ -2749,6 +2794,7 @@ uint64_t ASTWriter::WriteDeclContextLexi
void ASTWriter::WriteTypeDeclOffsets() {
using namespace llvm;
+ RecordData Record;
// Write the type offsets array
BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
@@ -2757,11 +2803,11 @@ void ASTWriter::WriteTypeDeclOffsets() {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // base type index
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // types block
unsigned TypeOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
- {
- RecordDataRef Record = {TYPE_OFFSET, TypeOffsets.size(),
- FirstTypeID - NUM_PREDEF_TYPE_IDS};
- Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, bytes(TypeOffsets));
- }
+ Record.clear();
+ Record.push_back(TYPE_OFFSET);
+ Record.push_back(TypeOffsets.size());
+ Record.push_back(FirstTypeID - NUM_PREDEF_TYPE_IDS);
+ Stream.EmitRecordWithBlob(TypeOffsetAbbrev, Record, bytes(TypeOffsets));
// Write the declaration offsets array
Abbrev = new BitCodeAbbrev();
@@ -2770,15 +2816,16 @@ void ASTWriter::WriteTypeDeclOffsets() {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // base decl ID
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // declarations block
unsigned DeclOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
- {
- RecordDataRef Record = {DECL_OFFSET, DeclOffsets.size(),
- FirstDeclID - NUM_PREDEF_DECL_IDS};
- Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, bytes(DeclOffsets));
- }
+ Record.clear();
+ Record.push_back(DECL_OFFSET);
+ Record.push_back(DeclOffsets.size());
+ Record.push_back(FirstDeclID - NUM_PREDEF_DECL_IDS);
+ Stream.EmitRecordWithBlob(DeclOffsetAbbrev, Record, bytes(DeclOffsets));
}
void ASTWriter::WriteFileDeclIDsMap() {
using namespace llvm;
+ RecordData Record;
SmallVector<std::pair<FileID, DeclIDInFileInfo *>, 64> SortedFileDeclIDs(
FileDeclIDs.begin(), FileDeclIDs.end());
@@ -2799,7 +2846,8 @@ void ASTWriter::WriteFileDeclIDsMap() {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32));
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);
- RecordDataRef Record = {FILE_SORTED_DECLS, FileGroupedDeclIDs.size()};
+ Record.push_back(FILE_SORTED_DECLS);
+ Record.push_back(FileGroupedDeclIDs.size());
Stream.EmitRecordWithBlob(AbbrevCode, Record, bytes(FileGroupedDeclIDs));
}
@@ -3009,10 +3057,11 @@ void ASTWriter::WriteSelectors(Sema &Sem
unsigned MethodPoolAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the method pool
- {
- RecordDataRef Record = {METHOD_POOL, BucketOffset, NumTableEntries};
- Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
- }
+ RecordData Record;
+ Record.push_back(METHOD_POOL);
+ Record.push_back(BucketOffset);
+ Record.push_back(NumTableEntries);
+ Stream.EmitRecordWithBlob(MethodPoolAbbrev, Record, MethodPool);
// Create a blob abbreviation for the selector table offsets.
Abbrev = new BitCodeAbbrev();
@@ -3023,12 +3072,12 @@ void ASTWriter::WriteSelectors(Sema &Sem
unsigned SelectorOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the selector offsets table.
- {
- RecordDataRef Record = {SELECTOR_OFFSETS, SelectorOffsets.size(),
- FirstSelectorID - NUM_PREDEF_SELECTOR_IDS};
- Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
- bytes(SelectorOffsets));
- }
+ Record.clear();
+ Record.push_back(SELECTOR_OFFSETS);
+ Record.push_back(SelectorOffsets.size());
+ Record.push_back(FirstSelectorID - NUM_PREDEF_SELECTOR_IDS);
+ Stream.EmitRecordWithBlob(SelectorOffsetAbbrev, Record,
+ bytes(SelectorOffsets));
}
}
@@ -3298,7 +3347,9 @@ void ASTWriter::WriteIdentifierTable(Pre
unsigned IDTableAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the identifier table
- RecordDataRef Record = {IDENTIFIER_TABLE, BucketOffset};
+ RecordData Record;
+ Record.push_back(IDENTIFIER_TABLE);
+ Record.push_back(BucketOffset);
Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
}
@@ -3314,9 +3365,11 @@ void ASTWriter::WriteIdentifierTable(Pre
for (unsigned I = 0, N = IdentifierOffsets.size(); I != N; ++I)
assert(IdentifierOffsets[I] && "Missing identifier offset?");
#endif
-
- RecordDataRef Record = {IDENTIFIER_OFFSET, IdentifierOffsets.size(),
- FirstIdentID - NUM_PREDEF_IDENT_IDS};
+
+ RecordData Record;
+ Record.push_back(IDENTIFIER_OFFSET);
+ Record.push_back(IdentifierOffsets.size());
+ Record.push_back(FirstIdentID - NUM_PREDEF_IDENT_IDS);
Stream.EmitRecordWithBlob(IdentifierOffsetAbbrev, Record,
bytes(IdentifierOffsets));
@@ -3732,7 +3785,8 @@ uint64_t ASTWriter::WriteDeclContextVisi
GenerateNameLookupTable(DC, LookupTable);
// Write the lookup table
- RecordDataRef Record = {DECL_CONTEXT_VISIBLE};
+ RecordData Record;
+ Record.push_back(DECL_CONTEXT_VISIBLE);
Stream.EmitRecordWithBlob(DeclContextVisibleLookupAbbrev, Record,
LookupTable);
++NumVisibleDeclContexts;
@@ -3763,7 +3817,9 @@ void ASTWriter::WriteDeclContextVisibleU
DC = cast<DeclContext>(Chain->getKeyDeclaration(cast<Decl>(DC)));
// Write the lookup table
- RecordDataRef Record = {UPDATE_VISIBLE, getDeclID(cast<Decl>(DC))};
+ RecordData Record;
+ Record.push_back(UPDATE_VISIBLE);
+ Record.push_back(getDeclID(cast<Decl>(DC)));
Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable);
}
@@ -3827,12 +3883,14 @@ void ASTWriter::WriteObjCCategories() {
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // # of entries
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
unsigned AbbrevID = Stream.EmitAbbrev(Abbrev);
-
- RecordDataRef Record = {OBJC_CATEGORIES_MAP, CategoriesMap.size()};
- Stream.EmitRecordWithBlob(AbbrevID, Record,
- reinterpret_cast<char *>(CategoriesMap.data()),
+
+ RecordData Record;
+ Record.push_back(OBJC_CATEGORIES_MAP);
+ Record.push_back(CategoriesMap.size());
+ Stream.EmitRecordWithBlob(AbbrevID, Record,
+ reinterpret_cast<char*>(CategoriesMap.data()),
CategoriesMap.size() * sizeof(ObjCCategoriesInfo));
-
+
// Emit the category lists.
Stream.EmitRecord(OBJC_CATEGORIES, Categories);
}
@@ -3929,7 +3987,7 @@ void ASTWriter::AddPath(StringRef Path,
AddString(FilePath, Record);
}
-void ASTWriter::EmitRecordWithPath(unsigned Abbrev, const RecordDataRef &Record,
+void ASTWriter::EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
StringRef Path) {
SmallString<128> FilePath(Path);
PreparePathForOutput(FilePath);
@@ -4192,14 +4250,14 @@ void ASTWriter::WriteASTCore(Sema &SemaR
WriteControlBlock(PP, Context, isysroot, OutputFile);
// Write the remaining AST contents.
+ RecordData Record;
Stream.EnterSubblock(AST_BLOCK_ID, 5);
// This is so that older clang versions, before the introduction
// of the control block, can read and reject the newer PCH format.
- {
- RecordData Record = {VERSION_MAJOR};
- Stream.EmitRecord(METADATA_OLD_FORMAT, Record);
- }
+ Record.clear();
+ Record.push_back(VERSION_MAJOR);
+ Stream.EmitRecord(METADATA_OLD_FORMAT, Record);
// Create a lexical update block containing all of the declarations in the
// translation unit that do not come from other AST files.
@@ -4216,12 +4274,11 @@ void ASTWriter::WriteASTCore(Sema &SemaR
Abv->Add(llvm::BitCodeAbbrevOp(TU_UPDATE_LEXICAL));
Abv->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob));
unsigned TuUpdateLexicalAbbrev = Stream.EmitAbbrev(Abv);
- {
- RecordDataRef Record = {TU_UPDATE_LEXICAL};
- Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
- bytes(NewGlobalKindDeclPairs));
- }
-
+ Record.clear();
+ Record.push_back(TU_UPDATE_LEXICAL);
+ Stream.EmitRecordWithBlob(TuUpdateLexicalAbbrev, Record,
+ bytes(NewGlobalKindDeclPairs));
+
// And a visible updates block for the translation unit.
Abv = new llvm::BitCodeAbbrev();
Abv->Add(llvm::BitCodeAbbrevOp(UPDATE_VISIBLE));
@@ -4351,7 +4408,8 @@ void ASTWriter::WriteASTCore(Sema &SemaR
writeBaseIDOrNone(M->BaseTypeIndex, M->LocalNumTypes);
}
}
- RecordDataRef Record = {MODULE_OFFSET_MAP};
+ Record.clear();
+ Record.push_back(MODULE_OFFSET_MAP);
Stream.EmitRecordWithBlob(ModuleOffsetMapAbbrev, Record,
Buffer.data(), Buffer.size());
}
@@ -4515,7 +4573,7 @@ void ASTWriter::WriteASTCore(Sema &SemaR
WriteOptimizePragmaOptions(SemaRef);
// Some simple statistics
- RecordData Record;
+ Record.clear();
Record.push_back(NumStatements);
Record.push_back(NumMacros);
Record.push_back(NumLexicalDeclContexts);
Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=247183&r1=247182&r2=247183&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)
+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Wed Sep 9 15:35:37 2015
@@ -757,7 +757,9 @@ void GlobalModuleIndexBuilder::writeInde
unsigned IDTableAbbrev = Stream.EmitAbbrev(Abbrev);
// Write the identifier table
- ArrayRef<uint64_t> Record = {IDENTIFIER_INDEX, BucketOffset};
+ Record.clear();
+ Record.push_back(IDENTIFIER_INDEX);
+ Record.push_back(BucketOffset);
Stream.EmitRecordWithBlob(IDTableAbbrev, Record, IdentifierTable);
}
More information about the cfe-commits
mailing list