[PATCH] D95695: [clang-tblgen] AnnotateAttr::printPretty has spurious comma when no variadic argument is specified

FĂ©lix Cloutier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 29 12:51:55 PST 2021


fcloutier created this revision.
fcloutier added reviewers: jkorous, dcoughlin.
fcloutier added a project: clang.
Herald added a subscriber: Charusso.
Herald added a reviewer: aaron.ballman.
fcloutier requested review of this revision.
Herald added a subscriber: cfe-commits.

Since it gained a new `VariadicExprArgument`, `AnnotateAttr`'s `printPretty` no longer prints back compilable code when the attribute is only passed a string. This is because the comma-printing logic unconditionally prints a comma between the first, fixed argument and the `VariadicExprArgument`, which is most likely an empty collection.

This diff adds a `Comma` helper to AttrImpl.inc that prints a comma before an argument if it isn't the first argument. In the process, it simplifies substantially the generation code, and arguably the generated code, too.

rdar://73742471


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95695

Files:
  clang/test/AST/ast-print-attr.c
  clang/utils/TableGen/ClangAttrEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95695.320192.patch
Type: text/x-patch
Size: 4388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210129/a8ffcee2/attachment.bin>


More information about the cfe-commits mailing list