[PATCH] D132413: [NFC] Make format() more amenable to format attributes

Akira Hatanaka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 8 14:36:05 PDT 2022


ahatanak added a comment.

If you write `format_chk("<fallback: %u>", Format.c_str(), (unsigned char)(From));` in your code and at runtime the format string passed to the function is `"%hu"` (which means an argument of type short is expected), `EnsureCompatible` will just accept it.  Is that correct?

Since clang emits a warning when compiling `printf("%hu", (char)c);` with `-Wformat-type-confusion`, it seems that you may want `EnsureCompatible` to reject it at runtime if you want to be strict and follow what clang is doing.

What are the rules for accepting or rejecting a format string at runtime?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132413/new/

https://reviews.llvm.org/D132413



More information about the llvm-commits mailing list