From 32b53cf9d0c8c0e01ce5b0e7d5c717202a98cdf5 Mon Sep 17 00:00:00 2001 From: Usman Akinyemi Date: Tue, 4 Apr 2023 09:58:03 -0700 Subject: [PATCH] [ExtractAPI] Remove extra attributes in property declaration fragments 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 --- clang/lib/ExtractAPI/DeclarationFragments.cpp | 2 +- clang/test/ExtractAPI/objc_category.m | 34 +---- clang/test/ExtractAPI/objc_id_protocol.m | 32 ----- clang/test/ExtractAPI/objc_interface.m | 8 -- clang/test/ExtractAPI/objc_property.m | 198 +------------------------- 5 files changed, 5 insertions(+), 269 deletions(-) diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp index 912e58a..da75a70 100644 --- a/clang/lib/ExtractAPI/DeclarationFragments.cpp +++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -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. diff --git a/clang/test/ExtractAPI/objc_category.m b/clang/test/ExtractAPI/objc_category.m index 185016d..3323d75 100644 --- a/clang/test/ExtractAPI/objc_category.m +++ b/clang/test/ExtractAPI/objc_category.m @@ -282,39 +282,7 @@ }, { "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", diff --git a/clang/test/ExtractAPI/objc_id_protocol.m b/clang/test/ExtractAPI/objc_id_protocol.m index 551e908..02f4cde 100644 --- a/clang/test/ExtractAPI/objc_id_protocol.m +++ b/clang/test/ExtractAPI/objc_id_protocol.m @@ -124,14 +124,6 @@ }, { "kind": "keyword", - "spelling": "atomic" - }, - { - "kind": "text", - "spelling": ", " - }, - { - "kind": "keyword", "spelling": "copy" }, { @@ -208,30 +200,6 @@ }, { "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" }, { diff --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m index 159e97a..3f53546 100644 --- a/clang/test/ExtractAPI/objc_interface.m +++ b/clang/test/ExtractAPI/objc_interface.m @@ -434,14 +434,6 @@ }, { "kind": "keyword", - "spelling": "atomic" - }, - { - "kind": "text", - "spelling": ", " - }, - { - "kind": "keyword", "spelling": "readonly" }, { diff --git a/clang/test/ExtractAPI/objc_property.m b/clang/test/ExtractAPI/objc_property.m index f09a5ad..9c69a11 100644 --- a/clang/test/ExtractAPI/objc_property.m +++ b/clang/test/ExtractAPI/objc_property.m @@ -163,38 +163,6 @@ }, { "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": ") " }, { @@ -255,39 +223,7 @@ }, { "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", @@ -355,38 +291,6 @@ }, { "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": ") " }, { @@ -447,39 +351,7 @@ }, { "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", @@ -597,38 +469,6 @@ }, { "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": ") " }, { @@ -689,39 +529,7 @@ }, { "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", -- 2.7.4