[clang] [clang] Implement __attribute__((format_matches)) (PR #116708)

via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 09:10:40 PST 2024


apple-fcloutier wrote:

There's a handful of drivers for the size of the SemaChecking change:

* generalize things that were previously specific to FormatAttr, pipe through expected format where applicable;
* tolerate the new FAPK_External for when the format arguments are invisible to the caller;
* implement comparing format strings.

The last one is the biggest one. SemaChecking knows how to check that a format string matches a provided list of arguments, but it doesn't know (before this change) how to check that two format strings are equivalent. This is because checking format strings is done (conceptually) by zipping format specifiers and argument types and seeing if they match with some fuzziness, rather than converting a format string to a list of types and then checking them together. I needed to implement a way to match two format strings "in abstract" for FormatMatches.

The second one causes change that look large in the diff but that are actually rather simple (for instance, wrapping a large-ish block of code in `CheckPrintfHandler::HandlePrintfSpecifier` with `if (HasFormatArguments()) {`).

https://github.com/llvm/llvm-project/pull/116708


More information about the cfe-commits mailing list