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

    <tr>
        <th>Summary</th>
        <td>
            Confusing diagnostic display of code the user didn't write
        </td>
    </tr>

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

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

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

<pre>
    The constant expression evaluator tries to reconstitute the syntactic form a function call to print in a note, but does a confusing job of handling member functions. Consider:
```
struct S {
  constexpr S() {}
  constexpr int f() const;
};
struct T : S {
  constexpr T(int n) : S(), n(n) {}
  int n;
};
constexpr int S::f() const {
  return static_cast<const T*>(this)->n;
}

static_assert(S().f(), "");
```
We correctly issue a diagnostic about the static assertion being an invalid constant expression, but the note we print out says `in call to '&S()->f()'` (live example: https://godbolt.org/z/Gxzv77a7v). The user never wrote that code, so already it's confusing, but that code isn't even syntactically valid.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1U9tuozAQ_Rp4GTUCkkB44CFNt_sBrbSPqwEPiSvHjmyTNv36HRtSmm0rOYRhbufMHLdGXJrnA0FntPOoPdDbyZJz0migM6oBvbHgrSQH3oClGCj94Ak857mL9th52UFv7BEQ-kGzydkdKhVSTlZyWanZp42npNhBO3gQhiti6NsPTuo9vJgWTA8H1EIF-0jHluxHPbeAHT-lIJsst0n2kGTbpMymE03n7dB5eIKkuh-_wMgrcIKnpNgkRR2d1cNXf0DZTzHxa7KcqoTw6_vU4xkYxE-dnrlKqKZjuxA3lg3U-dtGf4Uxhn_X8BbgU-C-3N7g_AzCkh-sBl4lr-Rvh4HFboxiVJz6izP9QTrOvmPrtuf4MvGMFdA5sp5zJgqLfqaSFEU89Vzjdh9_gqwsS8arC0jnBuKFC4l7bVxQDLaGhRBVFLvB2C2Ip6UgAdRMmkUoxXf6vCopFAjKgleaxBbKOrw4YChyVmJSVElRTkwC-w8yFQeye6PkmbgDHk-KwuIO3p9cGHnxyGdvRGuUXxi7Z-udf7_f3s9VhdU5jAbCPRqYAWg68_PVmnhJ0DN6EYXvDKCyhILnwVOt3Kz_mc0UzxNjihUzPpOe7xlzuUCcySKlJi_LrCiyZZmlolmKelljyrdTUbP7uFifJi6kOym8hHsWW_grYiHF2OzVSk_pYFXzH3fpD0O76MyRDaXO17-7kzUvvGE244ZZWI_rKtvk6aEps1Un1mLVVSV11OdZR0WOWSuyvhabTZkqbEm5Jlnfs5A6hTyF5XaG64K81g-pbIpAcpPneZHXeb1Y5TVSRpgVfVmWLSWrjI4o1SIgCutJbRPBtcPesVNJ593sZJnJvSaKjbk-Dv5gbLNFa_Q9z_eIOo1kmsjkH-Usnjg">