Skip to content

Commit

Permalink
[ExtractAPI] Remove extra attributes in property declaration fragments
Browse files Browse the repository at this point in the history
Use `getPropertyAttributesAsWritten` instead of `getPropertyAttributes`
to get property attributes actually specified in the source code.
Resolves issue #61478.

https://reviews.llvm.org/D146759

Reviewed By: zixuw, dang

Differential Revision: https://reviews.llvm.org/D146759
  • Loading branch information
Unique-Usman authored and zixu-w committed Apr 4, 2023
1 parent 7876489 commit 32b53cf
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 269 deletions.
2 changes: 1 addition & 1 deletion clang/lib/ExtractAPI/DeclarationFragments.cpp
Expand Up @@ -638,7 +638,7 @@ DeclarationFragments DeclarationFragmentsBuilder::getFragmentsForObjCProperty(
// Build the Objective-C property keyword.
Fragments.append("@property", DeclarationFragments::FragmentKind::Keyword);

const auto Attributes = Property->getPropertyAttributes();
const auto Attributes = Property->getPropertyAttributesAsWritten();
// Build the attributes if there is any associated with the property.
if (Attributes != ObjCPropertyAttribute::kind_noattr) {
// No leading comma for the first attribute.
Expand Down
34 changes: 1 addition & 33 deletions clang/test/ExtractAPI/objc_category.m
Expand Up @@ -282,39 +282,7 @@ + (void)ClassMethod;
},
{
"kind": "text",
"spelling": " ("
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
},
{
"kind": "text",
"spelling": ") "
"spelling": " "
},
{
"kind": "typeIdentifier",
Expand Down
32 changes: 0 additions & 32 deletions clang/test/ExtractAPI/objc_id_protocol.m
Expand Up @@ -122,14 +122,6 @@ @interface MyInterface
"kind": "text",
"spelling": " ("
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "copy"
Expand Down Expand Up @@ -206,30 +198,6 @@ @interface MyInterface
"kind": "text",
"spelling": " ("
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
Expand Down
8 changes: 0 additions & 8 deletions clang/test/ExtractAPI/objc_interface.m
Expand Up @@ -432,14 +432,6 @@ - (char)getIvar;
"kind": "text",
"spelling": " ("
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readonly"
Expand Down
198 changes: 3 additions & 195 deletions clang/test/ExtractAPI/objc_property.m
Expand Up @@ -161,38 +161,6 @@ @interface Interface (Category) <Protocol>
"kind": "keyword",
"spelling": "class"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
},
{
"kind": "text",
"spelling": ") "
Expand Down Expand Up @@ -255,39 +223,7 @@ @interface Interface (Category) <Protocol>
},
{
"kind": "text",
"spelling": " ("
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
},
{
"kind": "text",
"spelling": ") "
"spelling": " "
},
{
"kind": "typeIdentifier",
Expand Down Expand Up @@ -353,38 +289,6 @@ @interface Interface (Category) <Protocol>
"kind": "keyword",
"spelling": "class"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
},
{
"kind": "text",
"spelling": ") "
Expand Down Expand Up @@ -447,39 +351,7 @@ @interface Interface (Category) <Protocol>
},
{
"kind": "text",
"spelling": " ("
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
},
{
"kind": "text",
"spelling": ") "
"spelling": " "
},
{
"kind": "typeIdentifier",
Expand Down Expand Up @@ -595,38 +467,6 @@ @interface Interface (Category) <Protocol>
"kind": "keyword",
"spelling": "class"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
},
{
"kind": "text",
"spelling": ") "
Expand Down Expand Up @@ -689,39 +529,7 @@ @interface Interface (Category) <Protocol>
},
{
"kind": "text",
"spelling": " ("
},
{
"kind": "keyword",
"spelling": "atomic"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "assign"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "unsafe_unretained"
},
{
"kind": "text",
"spelling": ", "
},
{
"kind": "keyword",
"spelling": "readwrite"
},
{
"kind": "text",
"spelling": ") "
"spelling": " "
},
{
"kind": "typeIdentifier",
Expand Down

0 comments on commit 32b53cf

Please sign in to comment.