mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #29874 from bitjammer/acgarland/rdar-58339492-sg-source-locations
SymbolGraph: Serialize source locations and doc comment ranges
This commit is contained in:
@@ -1460,6 +1460,9 @@ bool ModuleFile::readDeclLocsBlock(llvm::BitstreamCursor &cursor) {
|
||||
case decl_locs_block::DECL_USRS:
|
||||
DeclUSRsTable = readDeclUSRsTable(scratch, blobData);
|
||||
break;
|
||||
case decl_locs_block::DOC_RANGES:
|
||||
DocRangesData = blobData;
|
||||
break;
|
||||
default:
|
||||
// Unknown index kind, which this version of the compiler won't use.
|
||||
break;
|
||||
@@ -2697,7 +2700,10 @@ ModuleFile::getBasicDeclLocsForDecl(const Decl *D) const {
|
||||
// Size of BasicDeclLocs in the buffer.
|
||||
// FilePathOffset + LocNum * LineColumn
|
||||
uint32_t LineColumnCount = 3;
|
||||
uint32_t RecordSize = NumSize + NumSize * 2 * LineColumnCount;
|
||||
uint32_t RecordSize =
|
||||
NumSize + // Offset into source filename blob
|
||||
NumSize + // Offset into doc ranges blob
|
||||
NumSize * 2 * LineColumnCount; // Line/column of: Loc, StartLoc, EndLoc
|
||||
uint32_t RecordOffset = RecordSize * UsrId;
|
||||
assert(RecordOffset < BasicDeclLocsData.size());
|
||||
assert(BasicDeclLocsData.size() % RecordSize == 0);
|
||||
@@ -2711,6 +2717,23 @@ ModuleFile::getBasicDeclLocsForDecl(const Decl *D) const {
|
||||
size_t TerminatorOffset = FilePath.find('\0');
|
||||
assert(TerminatorOffset != StringRef::npos && "unterminated string data");
|
||||
Result.SourceFilePath = FilePath.slice(0, TerminatorOffset);
|
||||
|
||||
const auto DocRangesOffset = ReadNext();
|
||||
if (DocRangesOffset) {
|
||||
assert(!DocRangesData.empty());
|
||||
const auto *Data = DocRangesData.data() + DocRangesOffset;
|
||||
const auto NumLocs = endian::readNext<uint32_t, little, unaligned>(Data);
|
||||
assert(NumLocs);
|
||||
|
||||
for (uint32_t i = 0; i < NumLocs; ++i) {
|
||||
LineColumn LC;
|
||||
LC.Line = endian::readNext<uint32_t, little, unaligned>(Data);
|
||||
LC.Column = endian::readNext<uint32_t, little, unaligned>(Data);
|
||||
auto Length = endian::readNext<uint32_t, little, unaligned>(Data);
|
||||
Result.DocRanges.push_back(std::make_pair(LC, Length));
|
||||
}
|
||||
}
|
||||
|
||||
#define READ_FIELD(X) \
|
||||
Result.X.Line = ReadNext(); \
|
||||
Result.X.Column = ReadNext();
|
||||
|
||||
Reference in New Issue
Block a user