// Parse the file names
std::map<int, int> FileIDs;
- for (int I = 0, N = Record[Idx++]; I != N; ++I) {
+ for (unsigned I = 0; Record[Idx]; ++I) {
// Extract the file name
auto Filename = ReadPath(F, Record, Idx);
FileIDs[I] = LineTable.getLineTableFilenameID(Filename);
}
+ ++Idx;
// Parse the line entries
std::vector<LineEntry> Entries;
// Extract the line entries
unsigned NumEntries = Record[Idx++];
- assert(NumEntries && "Numentries is 00000");
+ assert(NumEntries && "no line entries for file ID");
Entries.clear();
Entries.reserve(NumEntries);
for (unsigned I = 0; I != NumEntries; ++I) {
LineTableInfo &LineTable = SourceMgr.getLineTable();
Record.clear();
- // Emit the file names.
- Record.push_back(LineTable.getNumFilenames());
- for (unsigned I = 0, N = LineTable.getNumFilenames(); I != N; ++I)
- AddPath(LineTable.getFilename(I), Record);
+
+ // Emit the needed file names.
+ llvm::DenseMap<int, int> FilenameMap;
+ for (const auto &L : LineTable) {
+ if (L.first.ID < 0)
+ continue;
+ for (auto &LE : L.second) {
+ if (FilenameMap.insert(std::make_pair(LE.FilenameID,
+ FilenameMap.size())).second)
+ AddPath(LineTable.getFilename(LE.FilenameID), Record);
+ }
+ }
+ Record.push_back(0);
// Emit the line entries
for (LineTableInfo::iterator L = LineTable.begin(), LEnd = LineTable.end();
LE != LEEnd; ++LE) {
Record.push_back(LE->FileOffset);
Record.push_back(LE->LineNo);
- Record.push_back(LE->FilenameID);
+ Record.push_back(FilenameMap[LE->FilenameID]);
Record.push_back((unsigned)LE->FileKind);
Record.push_back(LE->IncludeOffset);
}
}
+
Stream.EmitRecord(SOURCE_MANAGER_LINE_TABLE, Record);
}
}