[all-commits] [llvm/llvm-project] 1aad64: [Clang][Sema] Add -Wcast-function-type-strict

Sami Tolvanen via All-commits all-commits at lists.llvm.org
Wed Oct 26 13:50:30 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1aad641c793090b4d036c03e737df2ebe2c32c57
      https://github.com/llvm/llvm-project/commit/1aad641c793090b4d036c03e737df2ebe2c32c57
  Author: Sami Tolvanen <samitolvanen at google.com>
  Date:   2022-10-26 (Wed, 26 Oct 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaCast.cpp
    A clang/test/Sema/warn-cast-function-type-strict.c
    M clang/test/Sema/warn-cast-function-type.c
    A clang/test/SemaCXX/warn-cast-function-type-strict.cpp
    M clang/test/SemaCXX/warn-cast-function-type.cpp

  Log Message:
  -----------
  [Clang][Sema] Add -Wcast-function-type-strict

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.

Reviewed By: nickdesaulniers, aaron.ballman

Differential Revision: https://reviews.llvm.org/D134831




More information about the All-commits mailing list