<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62996>62996</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ast-print generates empty parameter for attributes with optional string parameter
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          strimo378
      </td>
    </tr>
</table>

<pre>
    Hi all,

the AST printer (`-Xclang -ast-print`) always generates an empty parameter for attributes with option 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`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVcGO2zYQ_RrqMrBAUbYsHXRwduE0twJdoO3JIKmRzYIiBXIU1_n6gvRm4zi7xRboJYBhw-LMmzePfs8yRnN0iD3bfGCbx0IudPKhjxTM5OttWyg_XPpfDEhrmXhg_JHx3fWdTgi7355gDsYRBmCiZQ1f_aGtdEdYyUirfMQazkQH0p7lJcIRHQZJGEE6wGmmC8wyyAkTxOgDSKJg1JIqzoZO4Gcy3kFi5I7famN5y-XphDB6a_05FWk_YKITEeFENEdW75jYM7E_-kF5S6UPRyb2X5jYf266P3_fhqiAie4WMtG-vvJX4whkWlF0cDi8kDwc8rP2LIM7LG6JOBwCxsVSghMdqz_cgiYUVb0NM-AcUEvC4a49N4r3NbZMiL8vX5gQzyD3OPV_x3kAJsTlVcg7oZ7nfHfT8f8Vts083trunfL-O8hPJPXeB0hevDGOH_OTcXE6m0eCdAOo6jXPZXveiNFwMBHkMOAA5DOOX2heKNuqhE8uO16b2WIimwqy4UwE7UNATdnHOQZK-ETpwDt7gTl4ZXGSZDTQSV7LWMNfueKGXwdn70t7Q9dEcJ4gLvPsA-EA6gIfHx7ygi9UFGo_YQTjtJ9mSUZZ_CEvrjkV_RL0cxv5r6tKdyunuUaRcXlCFmy3IwopVupdDrlfAxJdEu-von_X8ySVxY_omNhmTwwwGpuhEk4sjdOs4WUx9PXQ1Z0ssK-adrPmXdWK4tQPAuuxWmusBG551aquqTbbba1x6HDkujC94KLmm5rzqqq5KLFS41qNm6Yb65ZvN2zNcZLGltZ-nlL-FSbGBftGdF1TWKnQxvwnIITDM-TD9IvYPBahTz0rtRwjW3NrIsVvKGTIYv8S9jeuf3-4S_tDvBdLsP1ddhs6LarUfmJin-Y_f6zm4P9CTUzsM-vIxD5v9U8AAAD___tFI3Q">