[all-commits] [llvm/llvm-project] d378a0: [Sema] Recognize format argument indicated by form...

apple-fcloutier via All-commits all-commits at lists.llvm.org
Wed Oct 27 15:48:51 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d378a0febc7e13aae7853b2e8733626f61140e55
      https://github.com/llvm/llvm-project/commit/d378a0febc7e13aae7853b2e8733626f61140e55
  Author: FĂ©lix Cloutier <fcloutier at apple.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M clang/lib/Sema/SemaChecking.cpp
    M clang/test/Sema/format-strings.c

  Log Message:
  -----------
  [Sema] Recognize format argument indicated by format attribute inside blocks

- `[[format(archetype, fmt-idx, ellipsis)]]` specifies that a function accepts a
  format string and arguments according to `archetype`. This is how Clang
  type-checks `printf` arguments based on the format string.
- Clang has a `-Wformat-nonliteral` warning that is triggered when a function
  with the `format` attribute is called with a format string that is not
  inspectable because it isn't constant. This warning is suppressed if the
  caller has the `format` attribute itself and the format argument to the callee
  is the caller's own format parameter.
- When using the `format` attribute on a block, Clang wouldn't recognize its
  format parameter when calling another function with the format attribute. This
  would cause unsuppressed -Wformat-nonliteral warnings for no supported reason.

Reviewed By: ahatanak

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

Radar-Id: rdar://84603673




More information about the All-commits mailing list