[PATCH] D97699: [analyzer] Add InvalidPtrChecker

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 10 07:59:16 PDT 2021


steakhal added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/cert/InvalidPtrChecker.cpp:159
+// Note: This pointer has type 'const MemRegion *'
+REGISTER_TRAIT_WITH_PROGRAMSTATE(EnvPtrRegion, const void *)
+
----------------
martong wrote:
> Why is it `const void *`? Why can't we use `const MemRegion *` and get rid of the ugly reinterpret_cast?  There must be a reason ,which I'd like to see documented in the comments. 
The trait is only specialized to `const void*` and `void*` see here:

https://github.com/llvm/llvm-project/blob/main/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h#L298-L323

```lang=C++
template <> struct ProgramStatePartialTrait<void *>
template <> struct ProgramStatePartialTrait<const void *>
```

I'm not exactly sure why don't we specialize to //any// pointer type of type `T`.


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

https://reviews.llvm.org/D97699



More information about the cfe-commits mailing list