[clang-tools-extra] [clang][dataflow]Use dyn_cast_or_null instead cast to prevent crash (PR #68510)

Congcong Cai via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 9 22:00:13 PDT 2023


================
@@ -599,7 +599,7 @@ void transferAssignment(const CXXOperatorCallExpr *E, BoolValue &HasValueVal,
                         LatticeTransferState &State) {
   assert(E->getNumArgs() > 0);
 
-  if (auto *Loc = cast<RecordStorageLocation>(
+  if (auto *Loc = dyn_cast_or_null<RecordStorageLocation>(
----------------
HerrCai0907 wrote:

If getStorageLocation may return nullptr, it should be cast_or_null. `dyn_cast` means it may be not RecordStorageLocation

https://github.com/llvm/llvm-project/pull/68510


More information about the cfe-commits mailing list