Skip to content

Commit

Permalink
[clang][ExtractAPI] Add semicolons to vars and fields and to test ref…
Browse files Browse the repository at this point in the history
…erence JSON

Differential Revision: https://reviews.llvm.org/D154038
  • Loading branch information
evelez7 committed Aug 1, 2023
1 parent 8d359b2 commit 422bcd1
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 2 deletions.
6 changes: 4 additions & 2 deletions clang/lib/ExtractAPI/DeclarationFragments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ DeclarationFragmentsBuilder::getFragmentsForVar(const VarDecl *Var) {
return Fragments.append(getFragmentsForType(T, Var->getASTContext(), After))
.appendSpace()
.append(Var->getName(), DeclarationFragments::FragmentKind::Identifier)
.append(std::move(After));
.append(std::move(After))
.append(";", DeclarationFragments::FragmentKind::Text);
}

DeclarationFragments
Expand Down Expand Up @@ -495,7 +496,8 @@ DeclarationFragmentsBuilder::getFragmentsForField(const FieldDecl *Field) {
return getFragmentsForType(Field->getType(), Field->getASTContext(), After)
.appendSpace()
.append(Field->getName(), DeclarationFragments::FragmentKind::Identifier)
.append(std::move(After));
.append(std::move(After))
.append(";", DeclarationFragments::FragmentKind::Text);
}

DeclarationFragments
Expand Down
8 changes: 8 additions & 0 deletions clang/test/ExtractAPI/anonymous_record_no_typedef.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ struct Vehicle {
{
"kind": "identifier",
"spelling": "type"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down Expand Up @@ -367,6 +371,10 @@ struct Vehicle {
{
"kind": "identifier",
"spelling": "information"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
4 changes: 4 additions & 0 deletions clang/test/ExtractAPI/global_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ char unavailable __attribute__((unavailable));
{
"kind": "identifier",
"spelling": "num"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
4 changes: 4 additions & 0 deletions clang/test/ExtractAPI/global_record_multifile.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ char unavailable __attribute__((unavailable));
{
"kind": "identifier",
"spelling": "num"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
4 changes: 4 additions & 0 deletions clang/test/ExtractAPI/known_files_only.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ struct Foo { int a; };
{
"kind": "identifier",
"spelling": "num"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
8 changes: 8 additions & 0 deletions clang/test/ExtractAPI/language.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ char objc;
{
"kind": "identifier",
"spelling": "c"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down Expand Up @@ -150,6 +154,10 @@ char objc;
{
"kind": "identifier",
"spelling": "objc"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
4 changes: 4 additions & 0 deletions clang/test/ExtractAPI/objc_interface.m
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ - (char)getIvar;
{
"kind": "identifier",
"spelling": "Ivar"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
8 changes: 8 additions & 0 deletions clang/test/ExtractAPI/relative_include.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
{
"kind": "identifier",
"spelling": "MyInt"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down Expand Up @@ -153,6 +157,10 @@
{
"kind": "identifier",
"spelling": "MyChar"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
16 changes: 16 additions & 0 deletions clang/test/ExtractAPI/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ struct Color {
{
"kind": "identifier",
"spelling": "Red"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down Expand Up @@ -213,6 +217,10 @@ struct Color {
{
"kind": "identifier",
"spelling": "Green"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down Expand Up @@ -265,6 +273,10 @@ struct Color {
{
"kind": "identifier",
"spelling": "Blue"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down Expand Up @@ -317,6 +329,10 @@ struct Color {
{
"kind": "identifier",
"spelling": "Alpha"
},
{
"kind": "text",
"spelling": ";"
}
],
"docComment": {
Expand Down
4 changes: 4 additions & 0 deletions clang/test/ExtractAPI/typedef_struct_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ struct Foo {
{
"kind": "identifier",
"spelling": "bar"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down
8 changes: 8 additions & 0 deletions clang/test/ExtractAPI/underscored.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ typedef _HiddenTypedef ExposedTypedefToHidden;
{
"kind": "identifier",
"spelling": "exposed_global"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down Expand Up @@ -190,6 +194,10 @@ typedef _HiddenTypedef ExposedTypedefToHidden;
{
"kind": "identifier",
"spelling": "a"
},
{
"kind": "text",
"spelling": ";"
}
],
"identifier": {
Expand Down

0 comments on commit 422bcd1

Please sign in to comment.