[all-commits] [llvm/llvm-project] 88501d: [Sema] -Wformat: support C23 format specifier %b %B

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Aug 4 10:26:44 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 88501dc74911b00186298fe1fffe8dfb1f09b1c1
      https://github.com/llvm/llvm-project/commit/88501dc74911b00186298fe1fffe8dfb1f09b1c1
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-08-04 (Thu, 04 Aug 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/AST/FormatString.h
    M clang/lib/AST/FormatString.cpp
    M clang/lib/AST/PrintfFormatString.cpp
    M clang/lib/AST/ScanfFormatString.cpp
    M clang/test/Sema/format-strings-fixit.c
    M clang/test/Sema/format-strings-scanf.c
    M clang/test/Sema/format-strings.c
    M clang/test/SemaObjC/format-strings-objc.m

  Log Message:
  -----------
  [Sema] -Wformat: support C23 format specifier %b %B

Close #56885: WG14 N2630 added %b to fprintf/fscanf and recommended %B for
fprintf. This patch teaches -Wformat %b for the printf/scanf family of functions
and %B for the printf family of functions.

glibc 2.35 and latest Android bionic added %b/%B printf support. From
https://www.openwall.com/lists/libc-coord/2022/07/ no scanf support is available
yet.

Like GCC, we don't test library support.

GCC 12 -Wformat -pedantic emits a warning:

> warning: ISO C17 does not support the ‘%b’ gnu_printf format [-Wformat=]

The behavior is not ported.

Note: `freebsd_kernel_printf` uses %b differently.

Reviewed By: aaron.ballman, dim, enh

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




More information about the All-commits mailing list