[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:
Xi Ge
2016-03-15 12:50:09 -07:00
parent f0e96f1e70
commit d0e176810f
7 changed files with 87 additions and 6 deletions

View File

@@ -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;