[analyzer][Casting] Support isa, cast, dyn_cast of SVals
This change specializes the LLVM RTTI mechanism for SVals. After this change, we can use the well-known `isa`, `cast`, `dyn_cast`. Examples: // SVal V = ...; // Loc MyLoc = ...; bool IsInteresting = isa<loc::MemRegionVal, loc::GotoLabel>(MyLoc); auto MRV = cast<loc::MemRegionVal>(MyLoc); Optional<loc::MemRegionVal> MaybeMRV = dyn_cast<loc::MemRegionVal>(V) The current `SVal::getAs` and `castAs` member functions are redundant at this point, but I believe that they are still handy. The member function version is terse and reads left-to-right, which IMO is a great plus. However, we should probably add a variadic `isa` member function version to have the same casting API in both cases. Thanks for the extensive TMP help @bzcheeseman! Reviewed By: bzcheeseman Differential Revision: https://reviews.llvm.org/D125709
Loading
Please sign in to comment