mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Serialize doc comments for extensions. Need this for rdar://25157796
We did not serialize them because getting USR for extensions is tricky (USRs are usually for value decls). This commit starts to make up an USR for an extension by combining the extended nominal's USR with the USR of the first value member of the extension. We use this made-up USR to associate doc comments when (de)serializing them.
This commit is contained in:
@@ -1525,6 +1525,17 @@ Optional<CommentInfo> ModuleFile::getCommentForDecl(const Decl *D) const {
|
||||
if (D->isImplicit())
|
||||
return None;
|
||||
|
||||
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
|
||||
// Compute the USR.
|
||||
llvm::SmallString<128> USRBuffer;
|
||||
{
|
||||
llvm::raw_svector_ostream OS(USRBuffer);
|
||||
if (ide::printExtensionUSR(ED, OS))
|
||||
return None;
|
||||
}
|
||||
return getCommentForDeclByUSR(USRBuffer.str());
|
||||
}
|
||||
|
||||
auto *VD = dyn_cast<ValueDecl>(D);
|
||||
if (!VD)
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user