diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index d7eebcbc3c2f9..348e7588690a2 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -883,6 +883,9 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForCXXMethod( if (Method->isVolatile()) Fragments.append("volatile", DeclarationFragments::FragmentKind::Keyword) .appendSpace(); + if (Method->isVirtual()) + Fragments.append("virtual", DeclarationFragments::FragmentKind::Keyword) + .appendSpace(); // Build return type DeclarationFragments After; diff --git a/clang/test/ExtractAPI/methods.cpp b/clang/test/ExtractAPI/methods.cpp index 67f04b4d33db8..180c2f92b2772 100644 --- a/clang/test/ExtractAPI/methods.cpp +++ b/clang/test/ExtractAPI/methods.cpp @@ -45,11 +45,19 @@ class Foo { // GETCOUNT-NEXT: ] // RUN: FileCheck %s --input-file %t/output.symbols.json --check-prefix SETL - void setLength(int length) noexcept; + virtual void setLength(int length) noexcept; // SETL: "!testRelLabel": "memberOf $ c:@S@Foo@F@setLength#I# $ c:@S@Foo" // SETL-LABEL: "!testLabel": "c:@S@Foo@F@setLength#I#" // SETL: "declarationFragments": [ // SETL-NEXT: { + // SETL-NEXT: "kind": "keyword", + // SETL-NEXT: "spelling": "virtual" + // SETL-NEXT: }, + // SETL-NEXT: { + // SETL-NEXT: "kind": "text", + // SETL-NEXT: "spelling": " " + // SETL-NEXT: }, + // SETL-NEXT: { // SETL-NEXT: "kind": "typeIdentifier", // SETL-NEXT: "preciseIdentifier": "c:v", // SETL-NEXT: "spelling": "void"