[Serialization] Store offset of decls in .swiftsourceinfo

The locations stored in .swiftsourceinfo included the presumed file,
line, and column. When a location is requested it would read these, open
the external file, create a line map, and find the offset corresponding
to that line/column.

The offset is known during serialization though, so output it as well to
avoid having to read the file and generate the line map.

Since the serialized location is returned from `Decl::getLoc()`, it
should not be the presumed location. Instead, also output the line
directives so that the presumed location can be built as per normal
locations.

Finally, move the cache out of `Decl` and into `ASTContext`, since very
few declarations will actually have their locations deserialized. Make
sure to actually write to that cache so it's used - the old cache was
never written to.
This commit is contained in:
Ben Barham
2021-04-23 11:36:18 +10:00
parent 02b5be7047
commit c763ab5d1e
18 changed files with 309 additions and 225 deletions

View File

@@ -392,7 +392,8 @@ public:
Optional<StringRef> getGroupNameByUSR(StringRef USR) const override;
Optional<BasicDeclLocs> getBasicLocsForDecl(const Decl *D) const override;
Optional<ExternalSourceLocs::RawLocs>
getExternalRawLocsForDecl(const Decl *D) const override;
void collectAllGroups(SmallVectorImpl<StringRef> &Names) const override;