[clang] [PAC] Ignore noexcept on function type when computing discriminator of member function pointers (PR #109056)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 16 11:08:09 PST 2025


================
@@ -3442,6 +3442,13 @@ uint16_t ASTContext::getPointerAuthTypeDiscriminator(QualType T) {
     encodeTypeForFunctionPointerAuth(*this, Out, T);
   } else {
     T = T.getUnqualifiedType();
+    // Drop exception specification from member function pointer type.
----------------
rjmccall wrote:

```suggestion
    // Calls to member function pointers don't need to worry about
    // language interop or the laxness of the C type compatibility rules.
    // We just mangle the member pointer type directly, which is
    // implicitly much stricter about type matching. However, we do
    // strip any top-level exception specification before this mangling.
    // C++23 requires calls to work when the function type is convertible
    // to the pointer type by a function pointer conversion, which can
    // change the exception specification. This does not technically
    // require the exception specification to not affect representation,
    // because the function pointer conversion is still always a direct
    // value conversion and therefore an opportunity to resign the
    // pointer. (This is in contrast to e.g. qualification conversions,
    // which can be applied in nested pointer positions, effectively
    // requiring qualified and unqualified representations to match.)
    // However, it is pragmatic to ignore exception specifications
    // because it allows a certain amount of `noexcept` mismatching
    // to not become a visible ODR problem. This also leaves some
    // room for the committee to add laxness to function pointer
    // conversions in future standards.
```

https://github.com/llvm/llvm-project/pull/109056


More information about the cfe-commits mailing list