SymbolGraph: Serialize decl and raw comment locations

- Add DocRangesLayout to the `.swiftsourceinfo`.
  This is a blob containing an array of `SingleRawComment`
  source locations.

- Add DocLocWriter for serializing `SingleRawComment` locs into the
  `DocLocsLayout` buffer.
  Serialize start line, start column, and length of `SingleRawComment`
  pieces in `.swiftsourceinfo`

- Read doc locs when loading basic declaration locs from a ModuleFile.
  - Load `DOC_LOCS` blob into ModuleFile::DocLocsData
  - Reconstitute RawComment ranges when available from .swiftsourceinfo

- Allow requesting serialized raw comment if available

rdar://problem/58339492
This commit is contained in:
Ashley Garland
2020-02-15 15:34:16 -08:00
parent 709c58ae8e
commit be77d57121
14 changed files with 358 additions and 55 deletions

View File

@@ -705,6 +705,14 @@ SourceFile::getBasicLocsForDecl(const Decl *D) const {
SourceManager &SM = getASTContext().SourceMgr;
BasicDeclLocs Result;
Result.SourceFilePath = SM.getDisplayNameForLoc(D->getLoc());
for (const auto &SRC : D->getRawComment().Comments) {
Result.DocRanges.push_back(std::make_pair(
LineColumn { SRC.StartLine, SRC.StartColumn },
SRC.Range.getByteLength())
);
}
auto setLineColumn = [&SM](LineColumn &Home, SourceLoc Loc) {
if (Loc.isValid()) {
std::tie(Home.Line, Home.Column) = SM.getLineAndColumn(Loc);