<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116543>116543</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`GetTypeForDeclarator` duplicates attribute in DeclSpec and Declarator chunks.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
v01dXYZ
</td>
</tr>
</table>
<pre>
With the following declaration (the fact the attribute comes first matters):
```
__attribute__((noreturn)) void f() {
}
```
`GetTypeForDeclarator` is invoked. The implementation will move the attribute from the declspec of the declarator to the first chunk of the declarator that is a function.
But at the end of `GetTypeForDeclarator`, the destructor of a object managing some state is called and it restores the attributes of the declspec.
Thus at the end, the attribute is attached to the declspec and to a chunk of the Declarator.
I wonder if it is expected.
* Should `TypeProcessingState` restore more than just the declspec attributes ?
* Is `GetTypeForDeclarator` meant to mutate the declarator as it currently does ?
* If `GetTypeForDeclarator` is meant to mutate it, why restore the declspec attributes ?
Below the functions involved (in a stack trace):
* `GetTypeForDeclarator`
* `GetDeclSpecTypeForDeclarator`
* `ConvertDeclSpecToType`
* `processTypeAttrs` <- iterates over the attributes
* `distributeFunctionTypeAttrFromDeclSpec` <- in a iteration loop
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVF1vqzgQ_TXmZdQIDCHJAw_9EKv7tlIr7cdL5dhD8K2xkT2Q7b9fGUjSZLu5UkQEnjlzzpkZixD0wSJWbP3E1i-JGKh1vhrTTP3519_J3qnP6g9NLVCL0Dhj3FHbAyiURnhB2llgfDsdCklTlCDyej8QgnQdBmi0DwSdIEIfGN-x_JGlLyw9Pct0-U2v7-_n_Pd3xreMb63zSIO3MZfvYHRaQTMd7YBtnhaYzcu3eOePvyG9ffZYO_-ykHeelSnoANqO7gPVCt5aBN31Bju0NKs7amOgcyPeaGu866ZP0YrQowTXnN9ndCA32zYZINvBfnwX1AqKJAQ0g5Wx5uor86eBQMzGolUx__-1MP68oAfyg4zorgEBbv8TZWyBFYfYveA6hECCMBaWwhhUIKwCTeAxkPMYruWGr8Sj2iuOb-0QvpA80biYFeURCdmiOplyti3WJQfi2qCLrqtKP-DorEIPuolkdQD8p0dJqK7CGH-E19YNRkW3olW_eycxBG0Pr1F3bPyiFLr4oFZY-DkEuiF3MYDl9QX8R7jTBuhQWIqiumEy-abjIkTucvAeLZlPUO4_8Pe6HFXfVtAUTT-2n2dVv5Yxjxcad5yndJm-eR3MiCputrYg4qjIDyAvJH6zv_zx3kjexMTD1x7lL2OfnR3RX-JdzLgN6ueuxqNHIh-iOyx_fgBN6MU0tiP6m1G-QlA6LN_rRf8JrPauO1W_4EY7ZvB4ORjn-kRVudrlO5FglW3ybFtseZYlbZU3m1IWjVRlWpbroixyxRXfppwLtSkynuiKp7zIsmyT8XW5zlZZVjTrciP35Sbdy3LHihQ7oc3KmLFbOX9IdAgDVllWros8MWKPJkw3N-cWjzCdMs7jRe6rmPSwHw6BFanRgcIFhjQZrO6MmBp6o-Xk4JcttnAyZNraS8q8u2GVDN5ULVEf4pDwmvH6oKkd9ivpOsbrSGD5e-i9i7cS4_VEOzBeL7rGiv8bAAD__5AIKtI">