zixuw created this revision. Herald added a reviewer: dang. Herald added a project: All. zixuw requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
There is a bug in `DeclarationFragments::appendSpace` where the space character is added to a local copy of the last fragment. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D123259 Files: 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
Index: clang/test/ExtractAPI/objc_interface.m =================================================================== --- clang/test/ExtractAPI/objc_interface.m +++ clang/test/ExtractAPI/objc_interface.m @@ -142,7 +142,7 @@ }, { "kind": "text", - "spelling": ")" + "spelling": ") " }, { "kind": "identifier", @@ -163,7 +163,7 @@ }, { "kind": "text", - "spelling": ")" + "spelling": ") " }, { "kind": "internalParam", @@ -244,7 +244,7 @@ }, { "kind": "text", - "spelling": ")" + "spelling": ") " }, { "kind": "typeIdentifier", @@ -398,7 +398,7 @@ }, { "kind": "text", - "spelling": ")" + "spelling": ") " }, { "kind": "identifier", Index: clang/test/ExtractAPI/objc_category.m =================================================================== --- clang/test/ExtractAPI/objc_category.m +++ clang/test/ExtractAPI/objc_category.m @@ -131,7 +131,7 @@ }, { "kind": "text", - "spelling": ")" + "spelling": ") " }, { "kind": "identifier", @@ -185,7 +185,7 @@ }, { "kind": "text", - "spelling": ")" + "spelling": ") " }, { "kind": "identifier", @@ -266,7 +266,7 @@ }, { "kind": "text", - "spelling": ")" + "spelling": ") " }, { "kind": "typeIdentifier", Index: clang/test/ExtractAPI/macro_undefined.c =================================================================== --- clang/test/ExtractAPI/macro_undefined.c +++ clang/test/ExtractAPI/macro_undefined.c @@ -142,7 +142,7 @@ }, { "kind": "text", - "spelling": " *" + "spelling": " * " }, { "kind": "internalParam", @@ -189,7 +189,7 @@ }, { "kind": "text", - "spelling": " *" + "spelling": " * " }, { "kind": "internalParam", Index: clang/test/ExtractAPI/global_record_multifile.c =================================================================== --- clang/test/ExtractAPI/global_record_multifile.c +++ clang/test/ExtractAPI/global_record_multifile.c @@ -177,7 +177,7 @@ }, { "kind": "text", - "spelling": " *" + "spelling": " * " }, { "kind": "internalParam", @@ -333,7 +333,7 @@ }, { "kind": "text", - "spelling": " *" + "spelling": " * " }, { "kind": "internalParam", Index: clang/test/ExtractAPI/global_record.c =================================================================== --- clang/test/ExtractAPI/global_record.c +++ clang/test/ExtractAPI/global_record.c @@ -175,7 +175,7 @@ }, { "kind": "text", - "spelling": " *" + "spelling": " * " }, { "kind": "internalParam", @@ -331,7 +331,7 @@ }, { "kind": "text", - "spelling": " *" + "spelling": " * " }, { "kind": "internalParam", Index: clang/lib/ExtractAPI/DeclarationFragments.cpp =================================================================== --- clang/lib/ExtractAPI/DeclarationFragments.cpp +++ clang/lib/ExtractAPI/DeclarationFragments.cpp @@ -21,7 +21,7 @@ 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 @@ 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();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits