[PATCH] D134831: [Clang][Sema] Add -Wcast-function-type-strict

Sami Tolvanen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 28 14:32:25 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 would help developers avoid function
type casts that lead to runtime CFI failures. -Wcast-function-type,
while helpful, only warns about ABI incompatibility, which isn't
sufficient with CFI.

Add -Wcast-function-type-strict, which checks for a strict type
compatibility in function type casts and helps warn about casts that
can potentially lead to CFI failures.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134831

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/warn-cast-function-type-strict.c
  clang/test/SemaCXX/warn-cast-function-type-strict.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134831.463675.patch
Type: text/x-patch
Size: 9365 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220928/aff26357/attachment.bin>


More information about the cfe-commits mailing list