[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 11 09:03:45 PST 2021


ASDenysPetrov updated this revision to Diff 329982.
ASDenysPetrov added a comment.

Updated.

In D96090#2618410 <https://reviews.llvm.org/D96090#2618410>, @NoQ wrote:

> In all cases we're supposed to have an **original** type, whether we need it or not. Simply because we're simulating a typed language. If we don't have it it's a bug.

I agree. That's how `evalCastFromNonLoc` and `evalCastFromLoc` work now. Finally I want to replace them along with passing a correct **original** type. This is just one another step closer to this direction. I don't want patches be too comlicated.

>> Some cases can extract the type from `SVal`
>
> Which is generally impossible because integral casts aren't modeled correctly.

Maybe I'm missing smth, But how about this:

  QualType T = V.castAs<nonloc::SymbolVal>().getSymbol()->getType();
  QualType T = cast<SymbolicRegion>(V.castAs<loc::MemRegionVal>().getAsRegion()).getSymbol()->getType();
  // Belowees are not exact types but well narrowed information which can be sufficient.
  V.castAs<nonloc::ConcreteInt>() <-> OriginalTy->isIntegralOrEnumerationType() 
  V.castAs<loc::ConcreteInt>() | V.castAs<loc::MemRegionVal>() | V.castAs<loc::GotoLabel>() <-> Loc::isLocType(CastTy)
  V.castAs<nonloc::PointerToMemberData>() <-> OriginalTy->isMemberPointerType()  (I guess)
  ...

> None of these ideal situations leave room for an API that receives the type //optionally//.

I've returned back `OriginalTy` param from a **default** to a **regular** one as @steakhal advised in D96090#2616666 <https://reviews.llvm.org/D96090#2616666>.


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

https://reviews.llvm.org/D96090

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96090.329982.patch
Type: text/x-patch
Size: 15192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210311/2233de6a/attachment.bin>


More information about the cfe-commits mailing list