Skip to content
Snippets Groups Projects
Commit fe2c77a0 authored by Zixu Wang's avatar Zixu Wang
Browse files

[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
parent 82662b75
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ using namespace llvm; ...@@ -21,7 +21,7 @@ using namespace llvm;
DeclarationFragments &DeclarationFragments::appendSpace() { DeclarationFragments &DeclarationFragments::appendSpace() {
if (!Fragments.empty()) { if (!Fragments.empty()) {
Fragment Last = Fragments.back(); Fragment &Last = Fragments.back();
if (Last.Kind == FragmentKind::Text) { if (Last.Kind == FragmentKind::Text) {
// Merge the extra space into the last fragment if the last fragment is // Merge the extra space into the last fragment if the last fragment is
// also text. // also text.
...@@ -390,7 +390,7 @@ DeclarationFragmentsBuilder::getFragmentsForParam(const ParmVarDecl *Param) { ...@@ -390,7 +390,7 @@ DeclarationFragmentsBuilder::getFragmentsForParam(const ParmVarDecl *Param) {
if (Param->isObjCMethodParameter()) if (Param->isObjCMethodParameter())
Fragments.append("(", DeclarationFragments::FragmentKind::Text) Fragments.append("(", DeclarationFragments::FragmentKind::Text)
.append(std::move(TypeFragments)) .append(std::move(TypeFragments))
.append(")", DeclarationFragments::FragmentKind::Text); .append(") ", DeclarationFragments::FragmentKind::Text);
else else
Fragments.append(std::move(TypeFragments)).appendSpace(); Fragments.append(std::move(TypeFragments)).appendSpace();
......
...@@ -175,7 +175,7 @@ char unavailable __attribute__((unavailable)); ...@@ -175,7 +175,7 @@ char unavailable __attribute__((unavailable));
}, },
{ {
"kind": "text", "kind": "text",
"spelling": " *" "spelling": " * "
}, },
{ {
"kind": "internalParam", "kind": "internalParam",
...@@ -331,7 +331,7 @@ char unavailable __attribute__((unavailable)); ...@@ -331,7 +331,7 @@ char unavailable __attribute__((unavailable));
}, },
{ {
"kind": "text", "kind": "text",
"spelling": " *" "spelling": " * "
}, },
{ {
"kind": "internalParam", "kind": "internalParam",
......
...@@ -177,7 +177,7 @@ char unavailable __attribute__((unavailable)); ...@@ -177,7 +177,7 @@ char unavailable __attribute__((unavailable));
}, },
{ {
"kind": "text", "kind": "text",
"spelling": " *" "spelling": " * "
}, },
{ {
"kind": "internalParam", "kind": "internalParam",
...@@ -333,7 +333,7 @@ char unavailable __attribute__((unavailable)); ...@@ -333,7 +333,7 @@ char unavailable __attribute__((unavailable));
}, },
{ {
"kind": "text", "kind": "text",
"spelling": " *" "spelling": " * "
}, },
{ {
"kind": "internalParam", "kind": "internalParam",
......
...@@ -142,7 +142,7 @@ FUNC_GEN(bar, const int *, unsigned); ...@@ -142,7 +142,7 @@ FUNC_GEN(bar, const int *, unsigned);
}, },
{ {
"kind": "text", "kind": "text",
"spelling": " *" "spelling": " * "
}, },
{ {
"kind": "internalParam", "kind": "internalParam",
...@@ -189,7 +189,7 @@ FUNC_GEN(bar, const int *, unsigned); ...@@ -189,7 +189,7 @@ FUNC_GEN(bar, const int *, unsigned);
}, },
{ {
"kind": "text", "kind": "text",
"spelling": " *" "spelling": " * "
}, },
{ {
"kind": "internalParam", "kind": "internalParam",
......
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
}, },
{ {
"kind": "text", "kind": "text",
"spelling": ")" "spelling": ") "
}, },
{ {
"kind": "identifier", "kind": "identifier",
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
}, },
{ {
"kind": "text", "kind": "text",
"spelling": ")" "spelling": ") "
}, },
{ {
"kind": "identifier", "kind": "identifier",
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
}, },
{ {
"kind": "text", "kind": "text",
"spelling": ")" "spelling": ") "
}, },
{ {
"kind": "typeIdentifier", "kind": "typeIdentifier",
......
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
}, },
{ {
"kind": "text", "kind": "text",
"spelling": ")" "spelling": ") "
}, },
{ {
"kind": "identifier", "kind": "identifier",
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
}, },
{ {
"kind": "text", "kind": "text",
"spelling": ")" "spelling": ") "
}, },
{ {
"kind": "internalParam", "kind": "internalParam",
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
}, },
{ {
"kind": "text", "kind": "text",
"spelling": ")" "spelling": ") "
}, },
{ {
"kind": "typeIdentifier", "kind": "typeIdentifier",
...@@ -398,7 +398,7 @@ ...@@ -398,7 +398,7 @@
}, },
{ {
"kind": "text", "kind": "text",
"spelling": ")" "spelling": ") "
}, },
{ {
"kind": "identifier", "kind": "identifier",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment