@@ -172,12 +172,34 @@ void Symbol::serializeRange(size_t InitialIndentation,
172172 });
173173}
174174
175- void Symbol::serializeDocComment (llvm::json::OStream &OS) const {
175+ const ValueDecl *Symbol::getDeclInheritingDocs () const {
176+ // get the decl that would provide docs for this symbol
176177 const auto *DocCommentProvidingDecl =
177- dyn_cast_or_null<ValueDecl>(
178- getDocCommentProvidingDecl (VD, /* AllowSerialized=*/ true ));
179- if (!DocCommentProvidingDecl) {
180- DocCommentProvidingDecl = VD;
178+ dyn_cast_or_null<ValueDecl>(
179+ getDocCommentProvidingDecl (VD, /* AllowSerialized=*/ true ));
180+
181+ // if the decl is the same as the one for this symbol, we're not
182+ // inheriting docs, so return null. however, if this symbol is
183+ // a synthesized symbol, `VD` is actually the source symbol, and
184+ // we should point to that one regardless.
185+ if (DocCommentProvidingDecl == VD && !SynthesizedBaseTypeDecl) {
186+ return nullptr ;
187+ } else {
188+ // otherwise, return whatever `getDocCommentProvidingDecl` returned.
189+ // it will be null if there are no decls that provide docs for this
190+ // symbol.
191+ return DocCommentProvidingDecl;
192+ }
193+ }
194+
195+ void Symbol::serializeDocComment (llvm::json::OStream &OS) const {
196+ const auto *DocCommentProvidingDecl = VD;
197+ if (!Graph->Walker .Options .SkipInheritedDocs ) {
198+ DocCommentProvidingDecl = dyn_cast_or_null<ValueDecl>(
199+ getDocCommentProvidingDecl (VD, /* AllowSerialized=*/ true ));
200+ if (!DocCommentProvidingDecl) {
201+ DocCommentProvidingDecl = VD;
202+ }
181203 }
182204 auto RC = DocCommentProvidingDecl->getRawComment (/* SerializedOK=*/ true );
183205 if (RC.isEmpty ()) {
0 commit comments