[clang] Fix the double space and double attribute printing of the final keyword. (PR #88600)
Kim Gräsman via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 13 08:24:07 PDT 2024
================
@@ -252,16 +252,19 @@ static DeclPrinter::AttrPosAsWritten getPosAsWritten(const Attr *A,
return DeclPrinter::AttrPosAsWritten::Right;
}
-void DeclPrinter::prettyPrintAttributes(const Decl *D,
+// returns true if an attribute was printed.
+bool DeclPrinter::prettyPrintAttributes(const Decl *D,
AttrPosAsWritten Pos /*=Default*/) {
- if (Policy.PolishForDeclaration)
- return;
+ bool hasPrinted = false;
if (D->hasAttrs()) {
const AttrVec &Attrs = D->getAttrs();
for (auto *A : Attrs) {
if (A->isInherited() || A->isImplicit())
continue;
+ // Don't strip out the keyword attributes, they aren't regular attributes.
+ if (Policy.PolishForDeclaration && !A->isKeywordAttribute())
----------------
kimgr wrote:
Nice, I was about to suggest something like this, but didn't know `isKeywordAttribute` existed.
https://github.com/llvm/llvm-project/pull/88600
More information about the cfe-commits
mailing list