Commit Graph

44 Commits

Author SHA1 Message Date
Ben Barham
c54c9c7079 [Gardening] Extract basic source info structs from RawComment.h 2021-04-14 10:05:27 +10:00
David Ungar
90ee114b4a add fingerprint excluding to basic source file info 2021-02-26 17:20:44 -08:00
Rintaro Ishizaki
bb45b2a822 [CodeCompletion] Lazily populate 'BasicSourceFileInfo' 2021-02-25 14:56:55 -08:00
David Ungar
6e034cac4e Revert "[NFC; Incremental] Rename BasicSourceFileInfo.InterfaceHash" 2021-02-25 09:06:53 -08:00
David Ungar
cbd92e65ff Rename BasicSourceFileInfo.InterfaceHash 2021-02-24 09:13:22 -08:00
Rintaro Ishizaki
4e391119e0 [Serialization] Serialize mtime with nanosecond precision
There's no reason to lose accuracy here.
2021-01-14 09:52:35 -08:00
Rintaro Ishizaki
36cfd10041 Cosmetic changes 2021-01-13 13:29:57 -08:00
Rintaro Ishizaki
a9a044c6e3 [Serialization] Serialize fingerprint, mtime, size of the source files 2021-01-13 11:49:52 -08:00
Rintaro Ishizaki
1b6e7857c2 [Serialization] Serialize/deserialize source file list 2021-01-13 11:49:52 -08:00
Ben Barham
b07c06e839 [Serialization] Fix crashes when allowing compiler errors in modules 2020-11-18 12:35:21 +10:00
Anthony Latsis
b26310ee97 TypeLoc: Offload TypeLoc off the ASTWalker 2020-08-04 18:13:28 +03:00
Suyash Srijan
58a84ea4c1 [NFC] Cleanup some code to use 'swift::getParameterList(ValueDecl)' to fetch parameter lists (#32979) 2020-07-20 19:50:37 +01:00
Alexis Laferrière
56c77df926 [Serialization] Skip SPI documentation in swiftdoc files
Hide comments from SPI decls in all swiftdoc files. This applies the
same restrictions as private declarations. This is a temporary solution,
a long term fix is to emit both a public and an internal swiftdoc file.

rdar://63729195
2020-05-28 12:58:59 -07:00
Owen Voorhees
dd0b1ebd3d [Gardening] Remove dead code in SerializeDoc.cpp 2020-05-26 08:24:36 -07:00
Owen Voorhees
45bc578ae5 [SourceManager] Rename line and column APIs for clarity 2020-05-21 12:54:07 -05:00
Michael Forster
345a9147ec Explicit SmallString->std::string conversion.
This is only needed temporarily until commit d7049213 from upstream
LLVM hits the swift/master branch.
2020-03-13 19:16:49 +01:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Ashley Garland
be77d57121 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
2020-02-17 16:20:59 -08:00
Jordan Rose
d8d18d3e0b [SerializeDoc] Don't crash in module-merging with a group info file (#27867)
Group info works by matching source filenames with groups, but in
module merging the decls in the module no longer have associated
SourceFiles. Long-term, maybe we should switch this to working on
filenames directly (using the new support provided by swiftsourceinfo
files), but for now just don't crash.

rdar://problem/56592085
2019-10-24 15:52:25 -07:00
Xi Ge
85a9006528 Some indentation issue fixes. NFC 2019-10-23 11:55:29 -07:00
Xi Ge
0abcc1db40 SerializeLoc: address Jordan's previous code review comments 2019-10-22 18:35:55 -07:00
Xi Ge
483bd5dbc3 SerializeLoc: implement SourceFile::getBasicLocsForDecl()
After having this function, the serialization logic doesn't have to
know where the source locations are coming from (.swift or .swiftmodule).
2019-10-09 17:30:34 -07:00
Xi Ge
014f863546 SerializeLoc: address more comments from Jordan. NFC 2019-10-09 15:29:52 -07:00
Xi Ge
adaf790f4c SerializeLoc: asserts USR id and basic decl location are always in sync 2019-10-09 15:29:52 -07:00
Xi Ge
5c092e7988 SerializeLoc: use decl_locs_block consistently. NFC 2019-10-09 15:29:52 -07:00
Xi Ge
29ab49ffe3 SerializeLoc: add an assertion to ensure we can use USR id as an index to access basic location records 2019-10-09 15:29:52 -07:00
Xi Ge
dd33540231 AST: rename printDeclUSRForModuleDoc to printDeclUSR. NFC 2019-10-09 15:29:52 -07:00
Xi Ge
c9647bb02e SerializeLoc: remove NameLoc entry in the serialized format
Having both Loc and NameLoc fields seems to be redundant.
2019-10-09 15:29:52 -07:00
Xi Ge
8293bdc9e9 SerilizeLoc: refactor table structures per Jordan's comments
After this change, we only use one single hash table for USR to USR id
mapping. The basic source locations are an array of fixed length
records that could be retrieved by using the USR id since each
USR id is guaranteed to be associated with one basic location entry.

The source file paths are refactored to a blob of 0-terminated strings.
Decl locations use offset in this blob to refer to the source file path
where the decl was defined.
2019-10-09 15:29:52 -07:00
Xi Ge
ba6891d7c8 SerializeLoc: include source locations for double underscored symbols in .swiftsourceinfo file
For .swiftdoc file, we don't expose doc-comments for underscored symbols. But this
seems to be an unnecessary constraint on .swiftsourceinfo file since we put
these symbols in .swiftinterface files anyway.
2019-10-09 15:29:52 -07:00
Xi Ge
adb9e1d42c SerializeLoc: add some comments about record structures. NFC 2019-10-09 15:29:52 -07:00
Xi Ge
e9dfdea6fd SerializeLoc: serialize basic decl source location information to .swiftsourceinfo file
After setting up the .swiftsourceinfo file, this patch starts to actually serialize
and de-serialize source locations for declaration. The binary format of .swiftsourceinfo
currently contains these three records:

BasicDeclLocs: a hash table mapping from a USR ID to a list of basic source locations. The USR id
could be retrieved from the following DeclUSRs record using an actual decl USR. The basic source locations
include a file ID and the results from Decl::getLoc(), ValueDecl::getNameLoc(), Decl::getStartLoc() and Decl::getEndLoc().
The file ID could be used to retrieve the actual file name from the following SourceFilePaths record.
Each location is encoded as a line:column pair.

DeclUSRS: a hash table mapping from USR to a USR ID used by location records.

SourceFilePaths: a hash table mapping from a file ID to actual file name.

BasicDeclLocs should be sufficient for most diagnostic cases. If additional source locations
are needed, we could always add new source location records without breaking the backward compatibility.
When de-serializing the source location from a module-imported decl, we calculate its USR, retrieve the USR ID
from the DeclUSRS record, and use the USR ID to look up the basic location list in the BasicDeclLocs record.

For more details about .swiftsourceinfo file: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation
2019-10-09 15:29:51 -07:00
Xi Ge
3103b5cec1 Frontend: set up output file .swiftsourceinfo
This patch will focus on teaching driver and frontend to emit this file.
The actual content and de-serialization parts will come later.

More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794
2019-09-24 13:52:17 -07:00
Jordan Rose
8d7f1b7c5d [AST] Separate SourceFile from FileUnit.h
Like the last commit, SourceFile is used a lot by Parse and Sema, but
less so by the ClangImporter and (de)Serialization. Split it out to
cut down on recompilation times when something changes.

This commit does /not/ split the implementation of SourceFile out of
Module.cpp, which is where most of it lives. That might also be a
reasonable change, but the reason I was reluctant to is because a
number of SourceFile members correspond to the entry points in
ModuleDecl. Someone else can pick this up later if they decide it's a
good idea.

No functionality change.
2019-09-17 17:54:41 -07:00
Jordan Rose
853caa66d4 [AST] Split FileUnit and its subclasses out of Module.h
Most of AST, Parse, and Sema deal with FileUnits regularly, but SIL
and IRGen certainly don't. Split FileUnit out into its own header to
cut down on recompilation times when something changes.

No functionality change.
2019-09-17 17:54:41 -07:00
Jordan Rose
b0ad06ae30 [Serialization] The hash seed for DeclCommentTableInfo can't change
Unlike compiled modules, swiftdoc files are considered a stable
format, so we can't change how information is stored in them. If we
add any more string-hashed tables to swiftdoc files, we should
consider using a new hash seed for those.
2019-08-29 09:19:49 -07:00
Jordan Rose
eddb736de6 [Serialization] Simplify reading of group info for swiftdoc files (#26734)
Before:
- call a helper object to get group name info
- which called another helper object to parse group name info (lazily)
- and cached that in a global map
- which was never accessed anywhere else

After:
- just parse the group name info up front
- and look up into it as necessary

No intended functionality change; in practice decls without groups
might now sort to the top where before they'd be "in the middle
somewhere" (wherever the first decl-without-group appeared).
2019-08-20 11:52:38 -07:00
Xi Ge
6fd332d62c Doc-serialization: skip declarations with double-underscore as name prefix
Double-underscored names suggest the symbols aren't supposed to be used by framework
clients. This patch excludes the doc-comments of these symbols in swiftdoc files.

rdar://51468650
2019-06-10 14:00:41 -07:00
Xi Ge
ea86a3402a doc-serialization: exclude non-public decls when serializing module group info.
This reduces the size of x86_64.swiftdoc about 10%.

rdar://48689311
2019-04-15 12:09:06 -07:00
Xi Ge
ecd1e84526 doc-serialization: diagnose missing group-info file or corrupted one.
rdar://45903094
2019-02-21 15:28:35 -08:00
Jordan Rose
449e5ecd74 [Serialization] Give swiftdocs a stable version
We're committing to this as a forwards-compatible format, and in most
cases probably backwards-compatible as well!
2018-10-23 19:55:44 -07:00
Jordan Rose
f3ea8bdd55 [Serialization] Preparation for giving swiftdoc its own version
The functionality change in this commit is that the control block in a
swiftdoc file is validated rather than just being ignored. Tests in
following commit.
2018-10-23 19:55:44 -07:00
Jordan Rose
ae9d86241c [Serialization] Split doc serialization out of the Serializer class
Extract the common utilities into a SerializerBase class, and make a
new DocSerializer.
2018-10-23 19:55:04 -07:00
Jordan Rose
6bcfc783cc [Serialization] Pull swiftdoc serialization out to a separate file
No functionality change.
2018-10-23 19:54:40 -07:00