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

    <tr>
        <th>Summary</th>
        <td>
            [[clang::always_destroy]] attribute while emitting exit-time-destructors diagnostic 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    Compiling this code with the [-Wexit-time-desctuctors](https://clang.llvm.org/docs/DiagnosticsReference.html#wexit-time-destructors) diagnostic enabled will raise the warning, for good reason.

```
static Foo ResourceHandler;
```

here is the output

```
[build] /somefile.cpp:X:14: warning: declaration requires an exit-time destructor [-Wexit-time-destructors]
[build] static Foo ResourceHandler;
[build]              ^
```
However, being happy with the destructor call on exit time, not only do I want to silence the warning but to flag the variable accordingly.  For that I [add the [[clang::always_destroy]] attribute](https://clang.llvm.org/docs/AttributeReference.html#always-destroy) to the static variable. 

```
[[clang::always_destroy]]
static Foo ResourceHandler;
```

This is meant to tell the compiler that I am aware of the exit time destructor and willing to pay the price, and properly release the resource.

The [[always_destroy]] attibute documentation states that it

> specifies that a variable with static or thread storage duration should have its exit-time destructor run. This attribute is the default unless clang was invoked with -fno-c++-static-destructors.

I believe this is explicit enough to prevent the compiler to emit the diagnostic for that variable, but it is not the case.



</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVV2v4jYT_jXmZkQUHMLCBRewLNpzu3qlt3fVxJ4kbh079QeUf1_ZCRzQnm63KkJBJPb4medjgt6rzhDtWX1k9WmBMfTW7W9CButx0Vh523-2w6i0Mh2EXnkQVhJcVegh9ASsPi7_T3-qsAxqoKUkL0IUwTrP6hPj2z6E0bPqwPiZ8bPQaLpC68tQWNcxfpZWeMbPJ4WdsT4o4b9RS46MoKIPg2a8ur5UD26uzncgH7uADDaaJFyV1uBQec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