[PATCH] D154838: [analyzer] Add check for null pointer passed to %p of printf family

Georgiy Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 10 01:00:11 PDT 2023


CuriousGeorgiy added a comment.

@MitalAshok

> Instead of checking for hard-coded names, you can check functions with the format(printf, x, y) attribute

@NoQ pointed out this is too generic, and we should go for a case-by-case approach.

> You also have to check for pointer types first. This currently warns on printf("%d", 0), since 0 is a null pointer constant

Fixed, thanks for spotting!

> Also this only works for null pointer *constants*.

No, it works for symbolic values too, please look at the test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154838



More information about the cfe-commits mailing list