[clang] [clang] Function type attribute to prevent CFI instrumentation (PR #135836)

Bruno De Fraine via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 10 01:12:02 PDT 2025


================
@@ -2510,12 +2542,15 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
 
   SCS.setToType(2, FromType);
 
-  if (CanonFrom == CanonTo)
-    return true;
-
   // If we have not converted the argument type to the parameter type,
   // this is a bad conversion sequence, unless we're resolving an overload in C.
-  if (S.getLangOpts().CPlusPlus || !InOverloadResolution)
+  //
+  // Permit conversions from a function without `cfi_unchecked_callee` to a
+  // function with `cfi_unchecked_callee`.
+  if (CanonFrom == CanonTo || S.AddingCFIUncheckedCallee(CanonFrom, CanonTo))
+    return true;
+
+  if ((S.getLangOpts().CPlusPlus || !InOverloadResolution))
     return false;
----------------
brunodf-snps wrote:

I think there is still a bug here: allowing the check of `CanonFrom == CanonTo` to be bypassed when `AddingCFIUncheckedCallee` creates a hole in semantic checking, see issue #162798.

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


More information about the cfe-commits mailing list