Skip to content

Commit 23b66a6

Browse files
authored
[ExtractAPI] Include virtual keyword for methods (#145412)
This information was being left out of the symbol graph. rdar://131780883
1 parent 4b9f7cd commit 23b66a6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/ExtractAPI/DeclarationFragments.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,9 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForCXXMethod(
883883
if (Method->isVolatile())
884884
Fragments.append("volatile", DeclarationFragments::FragmentKind::Keyword)
885885
.appendSpace();
886+
if (Method->isVirtual())
887+
Fragments.append("virtual", DeclarationFragments::FragmentKind::Keyword)
888+
.appendSpace();
886889

887890
// Build return type
888891
DeclarationFragments After;

clang/test/ExtractAPI/methods.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,19 @@ class Foo {
4545
// GETCOUNT-NEXT: ]
4646

4747
// RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix SETL
48-
void setLength(int length) noexcept;
48+
virtual void setLength(int length) noexcept;
4949
// SETL: "!testRelLabel": "memberOf $ c:@S@Foo@F@setLength#I# $ c:@S@Foo"
5050
// SETL-LABEL: "!testLabel": "c:@S@Foo@F@setLength#I#"
5151
// SETL: "declarationFragments": [
5252
// SETL-NEXT: {
53+
// SETL-NEXT: "kind": "keyword",
54+
// SETL-NEXT: "spelling": "virtual"
55+
// SETL-NEXT: },
56+
// SETL-NEXT: {
57+
// SETL-NEXT: "kind": "text",
58+
// SETL-NEXT: "spelling": " "
59+
// SETL-NEXT: },
60+
// SETL-NEXT: {
5361
// SETL-NEXT: "kind": "typeIdentifier",
5462
// SETL-NEXT: "preciseIdentifier": "c:v",
5563
// SETL-NEXT: "spelling": "void"

0 commit comments

Comments
 (0)