[PATCH] D136790: [Clang][Sema] Add -Wincompatible-function-pointer-types-strict

Sami Tolvanen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 14:10:17 PDT 2022


samitolvanen created this revision.
Herald added a project: All.
samitolvanen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang supports indirect call Control-Flow Integrity (CFI) sanitizers
(e.g. -fsanitize=cfi-icall), which enforce an exact type match
between a function pointer and the target function. Unfortunately,
Clang doesn't provide diagnostics that help developers avoid
function pointer assignments that can lead to runtime CFI
failures. -Wincompatible-function-pointer-types doesn't warn about
enum to integer mismatches if the types are otherwise compatible, for
example, which isn't sufficient with CFI.

Add -Wincompatible-function-pointer-types-strict, which checks for a
stricter function type compatibility in assignments and helps warn about
assignments that can potentially lead to CFI failures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136790

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/incompatible-function-pointer-types-strict.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136790.470930.patch
Type: text/x-patch
Size: 4980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221026/2e0b0f63/attachment-0001.bin>


More information about the cfe-commits mailing list