[PATCH] D105974: [analyzer] Do not assume that all pointers have the same bitwidth as void*

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 14 09:53:16 PDT 2021


NoQ added a comment.

I think this is a plausible use case, previously I thought it's too much work but it seems reasonable last time I looked into it, so I'm glad to see it going on!

Can you add a comment explaining that the new code is necessary for architectures with varying pointer bit width? That's often unobvious.



================
Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:718
+      QualType Ty = Sym->getType();
+      // FIXME: Why did we have references at this point?
+      // FIXME: Cleanup remainder of `getZeroWithPtrWidth ()`
----------------
I guess something like this?
```lang=c++
void foo(int &x) {
  int *p = &x; // 'p' is the same SVal as 'x'
  bool b = p;
}
```
I think we should return a concrete `true` in the reference case. We already know that such symbol is true-ish but returning a concrete `true` might be easier on the solver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105974



More information about the cfe-commits mailing list