Commit Graph

5 Commits

Author SHA1 Message Date
Doug Gregor
5df96a7a6e Turn pretty-printing of a declaration into a request
The diagnostics engine has some code to pretty-print a declaration when
there is no source location for that declaration. The declaration is
pretty-printed into a source buffer, and a source location into that
buffer is synthesizes. This applies to synthesized declarations as well
as those imported from Swift modules (without source code) or from Clang.

Reimplement this pretty-printing for declarations as a request. In
doing so, change the manner in which we do the printing: the
diagnostics engine printed the entire enclosing type into a buffer
whose name was the module + that type. This meant that the buffer was
shared by every member of that type, but also meant that we would end
up deserializing a lot of declarations just for printing and
potentially doing a lot more work for these diagnostics.
2024-10-01 15:49:15 -07:00
Ben Barham
fff50ba791 [AST] Do not return invalid SourceLocs from Decl::getLoc
When loading locations from .swiftsourceinfo, make sure that the offset
is actually within the buffer.

Resolves rdar://78833833
2021-06-10 14:51:20 +10:00
Ben Barham
2f29cbe559 [Serialization] Do not absolute path the serialized line directive
Line directive paths are used as-is, do not convert them to their
absolute path during serialization.
2021-04-29 23:07:46 +10:00
Ben Barham
c763ab5d1e [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.
2021-04-29 12:33:05 +10:00
Ben Barham
54b80f82c2 [Diagnostics] Add tests to check diagnostic locations across modules 2021-04-28 18:38:22 +10:00