ast-print generates empty parameter for attributes with optional string parameter
Hi all,
the AST printer (-Xclang -ast-print) always generates an empty parameter for attributes with optional string parameters.
The following code (see https://godbolt.org/z/v69YW7rsb)
int a() __attribute__((warn_unused_result));
int b1() __attribute__((deprecated));
int b2() __attribute__((deprecated("xyz")));
int b3() __attribute__((deprecated("xyz", "y")));
is generates as
int a() __attribute__((warn_unused_result("")));
int b1() __attribute__((deprecated("")));
int b2() __attribute__((deprecated("xyz")));
int b3() __attribute__((deprecated("xyz", "y")));
For the attributes of the function a and b1 an empty parameter ("") is added to the output code. In principle, the code is correct for Clang. It is only problematic that for warn_unused_result the optional parameter is not supported by GCC and the code becomes incompatible.
The Clang source code to output an attributes is within the *Attr::printPretty functions within the TableGen'erated file Attrs.inc.
@llvm/issue-subscribers-clang-frontend
any plan to fix this?
Not from my side as I am lacking experience how Attrs.inc is generated...
Not from my side as I am lacking experience how Attrs.inc is generated...
me neither. and since nodiscard and warn_unused_result are sharing the same rule. i have no idea how to fix this without effecting nodiscard
seems your commit doesnt fix this issue problem? @strimo378
@yangdiangzb Hmm, yes that is correct. it seems I used the wrong link for the commit. Thanks for the information.
Sorry about this. My private fork accidentally closed this issue.
I've opened #239378 which omits empty optional string arguments for all
affected attributes, including deprecated. Feedback welcome.