[PATCH] D118050: [analyzer] Different address spaces cannot overlap

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 28 11:30:00 PST 2022


NoQ added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:728
+    const MemRegion *R = loc.castAs<loc::MemRegionVal>().getRegion();
+    if (const auto *SR = dyn_cast<SymbolicRegion>(R)) {
+      QualType Ty = SR->getSymbol()->getType();
----------------
That's a pretty big "if".

The natural way to handle the opposite case is `TypedRegion::getLocationType()`.

You can probably go with `SVal::getType()` here as it happens to do the right thing (treat `Loc` values as if they were pointers). But, again, it's speculative.


================
Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:750-751
+  if (RhsBitwidth && LhsBitwidth) {
+    assert(RhsBitwidth == LhsBitwidth &&
+           "RhsLoc bitwidth must be same as LhsLoc bitwidth!");
+    return RhsBitwidth == LhsBitwidth;
----------------
I think this is a good, correct assertion. It is up to the AST to insert implicit casts when bit widths don't match (or outright reject the code, I've no idea what really happens in such cases, but it's up to the compiler in any case).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118050



More information about the cfe-commits mailing list