[clang][ExtractAPI] Complete declaration fragments for TagDecl types defined in a...
authorruturaj4 <ruturajkvaidya@ku.edu>
Thu, 13 Apr 2023 12:48:30 +0000 (13:48 +0100)
committerDaniel Grumberg <dgrumberg@apple.com>
Thu, 13 Apr 2023 16:55:45 +0000 (17:55 +0100)
commit3ac550984e83c2478772c800b1f1b5cffd63a10d
treec0d77ace173bbe12c03ee83119af5af104095700
parent1fb24cef40d26d2533b2786b21ec795cb1953133
[clang][ExtractAPI] Complete declaration fragments for TagDecl types defined in a typedef

enums and structs declared inside typedefs have incorrect declaration fragments, where the typedef keyword and other syntax is missing.

For the following struct:

typedef struct Test {
    int hello;
} Test;
The produced declaration is:

"declarationFragments": [
  {
    "kind": "keyword",
    "spelling": "struct"
  },
  {
    "kind": "text",
    "spelling": " "
  },
  {
    "kind": "identifier",
    "spelling": "Test"
  }
],
instead the declaration fragments should represent the following

typedef struct Test {
    …
} Test;

This patch removes the condition in SymbolGraphSerializer.cpp file and completes declaration fragments

Reviewed By: dang

Differential Revision: https://reviews.llvm.org/D146385
clang/include/clang/ExtractAPI/DeclarationFragments.h
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
clang/test/ExtractAPI/typedef_struct_enum.c [new file with mode: 0644]