[clang] fe2c77a - [clang][ExtractAPI] Fix appendSpace in DeclarationFragments
Zixu Wang via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 7 09:17:38 PDT 2022
Author: Zixu Wang
Date: 2022-04-07T09:17:30-07:00
New Revision: fe2c77a0065cda43418d625f0162a974ce8ec1e5
URL: https://github.com/llvm/llvm-project/commit/fe2c77a0065cda43418d625f0162a974ce8ec1e5
DIFF: https://github.com/llvm/llvm-project/commit/fe2c77a0065cda43418d625f0162a974ce8ec1e5.diff
LOG: [clang][ExtractAPI] Fix appendSpace in DeclarationFragments
There is a bug in `DeclarationFragments::appendSpace` where the space
character is added to a local copy of the last fragment.
Differential Revision: https://reviews.llvm.org/D123259
Added:
Modified:
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/test/ExtractAPI/global_record.c
clang/test/ExtractAPI/global_record_multifile.c
clang/test/ExtractAPI/macro_undefined.c
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_interface.m
Removed:
################################################################################
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index fa28fad358db9..a569ff9168bc3 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -21,7 +21,7 @@ using namespace llvm;
DeclarationFragments &DeclarationFragments::appendSpace() {
if (!Fragments.empty()) {
- Fragment Last = Fragments.back();
+ Fragment &Last = Fragments.back();
if (Last.Kind == FragmentKind::Text) {
// Merge the extra space into the last fragment if the last fragment is
// also text.
@@ -390,7 +390,7 @@ DeclarationFragmentsBuilder::getFragmentsForParam(const ParmVarDecl *Param) {
if (Param->isObjCMethodParameter())
Fragments.append("(", DeclarationFragments::FragmentKind::Text)
.append(std::move(TypeFragments))
- .append(")", DeclarationFragments::FragmentKind::Text);
+ .append(") ", DeclarationFragments::FragmentKind::Text);
else
Fragments.append(std::move(TypeFragments)).appendSpace();
diff --git a/clang/test/ExtractAPI/global_record.c b/clang/test/ExtractAPI/global_record.c
index 4c14cae2de877..dfe99c2f55f67 100644
--- a/clang/test/ExtractAPI/global_record.c
+++ b/clang/test/ExtractAPI/global_record.c
@@ -175,7 +175,7 @@ char unavailable __attribute__((unavailable));
},
{
"kind": "text",
- "spelling": " *"
+ "spelling": " * "
},
{
"kind": "internalParam",
@@ -331,7 +331,7 @@ char unavailable __attribute__((unavailable));
},
{
"kind": "text",
- "spelling": " *"
+ "spelling": " * "
},
{
"kind": "internalParam",
diff --git a/clang/test/ExtractAPI/global_record_multifile.c b/clang/test/ExtractAPI/global_record_multifile.c
index 76e18811a53b4..577eb121cf922 100644
--- a/clang/test/ExtractAPI/global_record_multifile.c
+++ b/clang/test/ExtractAPI/global_record_multifile.c
@@ -177,7 +177,7 @@ char unavailable __attribute__((unavailable));
},
{
"kind": "text",
- "spelling": " *"
+ "spelling": " * "
},
{
"kind": "internalParam",
@@ -333,7 +333,7 @@ char unavailable __attribute__((unavailable));
},
{
"kind": "text",
- "spelling": " *"
+ "spelling": " * "
},
{
"kind": "internalParam",
diff --git a/clang/test/ExtractAPI/macro_undefined.c b/clang/test/ExtractAPI/macro_undefined.c
index feb4b3f43637e..0ae04d02e1543 100644
--- a/clang/test/ExtractAPI/macro_undefined.c
+++ b/clang/test/ExtractAPI/macro_undefined.c
@@ -142,7 +142,7 @@ FUNC_GEN(bar, const int *, unsigned);
},
{
"kind": "text",
- "spelling": " *"
+ "spelling": " * "
},
{
"kind": "internalParam",
@@ -189,7 +189,7 @@ FUNC_GEN(bar, const int *, unsigned);
},
{
"kind": "text",
- "spelling": " *"
+ "spelling": " * "
},
{
"kind": "internalParam",
diff --git a/clang/test/ExtractAPI/objc_category.m b/clang/test/ExtractAPI/objc_category.m
index bc572adfcd161..2416e3049bd55 100644
--- a/clang/test/ExtractAPI/objc_category.m
+++ b/clang/test/ExtractAPI/objc_category.m
@@ -131,7 +131,7 @@ + (void)ClassMethod;
},
{
"kind": "text",
- "spelling": ")"
+ "spelling": ") "
},
{
"kind": "identifier",
@@ -185,7 +185,7 @@ + (void)ClassMethod;
},
{
"kind": "text",
- "spelling": ")"
+ "spelling": ") "
},
{
"kind": "identifier",
@@ -266,7 +266,7 @@ + (void)ClassMethod;
},
{
"kind": "text",
- "spelling": ")"
+ "spelling": ") "
},
{
"kind": "typeIdentifier",
diff --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m
index a105a58281fba..a74a53c8db2cf 100644
--- a/clang/test/ExtractAPI/objc_interface.m
+++ b/clang/test/ExtractAPI/objc_interface.m
@@ -142,7 +142,7 @@ - (char)getIvar;
},
{
"kind": "text",
- "spelling": ")"
+ "spelling": ") "
},
{
"kind": "identifier",
@@ -163,7 +163,7 @@ - (char)getIvar;
},
{
"kind": "text",
- "spelling": ")"
+ "spelling": ") "
},
{
"kind": "internalParam",
@@ -244,7 +244,7 @@ - (char)getIvar;
},
{
"kind": "text",
- "spelling": ")"
+ "spelling": ") "
},
{
"kind": "typeIdentifier",
@@ -398,7 +398,7 @@ - (char)getIvar;
},
{
"kind": "text",
- "spelling": ")"
+ "spelling": ") "
},
{
"kind": "identifier",
More information about the cfe-commits
mailing list