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

    <tr>
        <th>Summary</th>
        <td>
            False positive dangling diagnostics when the [[gsl::Owner]] and [[clang::lifetimebound]] attributes are used together
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            clang:diagnostics
      </td>
    </tr>

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

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

<pre>
    Clang emits bogus dangling diagnostics when the `[[gsl::Owner]]` and `[[liftimebound]]` attributes are used together.

Consider the following case https://godbolt.org/z/z6fdqGEa7:

```
template <typename T>
struct [[gsl::Owner]] StatusOr {
  const T &value() [[clang::lifetimebound]];
};

template <typename V>
class Wrapper {
 public:
  operator V() const { return value; } 
  V value;
};

std::string_view test() {
 StatusOr<Wrapper<std::string_view>> k;
  std::string_view good = StatusOr<Wrapper<std::string_view>>().value(); // bad1: emit dangling diagnostic

  return k.value(); // bad2: emit dangling diagnostic
}
```

We should not emit diagnostics for these two cases.  (Removing either the `[[gsl::Owner]]` or `[[clang::lifetimebound]]` suppresses the diagnostics).


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2PozgQ_TXmUpoITALkwKGTdPY40u6o57gyuALeNjbrKhLN_voVkKTZUWe7RyLOh8uv3ntxPUVkGodYis1ObA6RGrj1oWz9KxoXVV7_KPdWuQawM0xQ-WYg0Mo11rgGtFGN88SmJri06IBbBJHFE9iuISvSJ5E-fb04DGJzGJ8sBuX0W5E1JzYdVn5welHCHEw1MBKogDAQamDfILcYViI-iPhpXvfekdEYps4nb62_jMRqRQgtc08jA3kU8th4XXnLKx8aIY__jK_spP_-7VnlY80Cc-Q2P9NXxq63ihFEuucfPTrVIXwT6fO8TRyGmuGxZPiDFQ_0NYDId_MZgNo7YvgGQmZnZQcUshBye0WpR8dnHGtO-LM_6RVF5IvPj6m-3KnWVhHB96D6Hpds-qGypr67AOB7DIp9gJcrr5muyHcQkIfgYCad7kDkB7gde7n__IggsZ51EQfjmj_PBi_ASHzTf-d0M02k-ythke7fOz6qS5_h9d4J4N0ujfcaRHr4VeSZ2WrxL02ypzsFldKJSJ-m6XhvLJba4ebd62Mw-Qmw_PDuNZ3X7wjU-sFqcJ6vSIshPflpUgiBL36aEloBCFn8jp0_j-3QjDP2uUH24a3mgzubxUBD3wckQprQF7RGf5ciIl2meptuVYRlksssLuI8z6O2TItTUcdJnteV1FmuC6WLOKk3WZIpVa11ZEoZy3W8TZKk2MhNvjrlhVxn2yTDrU4220ysY-yUsStrz92YBZEhGrBM4kLmMrKqQktTGEp5k3QK3jE6LaQUcr_Y-I8EOcZnKEfcL9XQkFjH1hDTWyc2bLE8KksIvSfD5owfZenjVJlS9BPW_2-WRkOw5U85abgdqlXtOyGPI_fr25c--L-wZiGPk2Uk5PHq2rmU_wYAAP__0FDrHQ">