diff options
author | Qizhi Hu <836744285@qq.com> | 2023-10-21 09:39:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-21 09:39:30 +0800 |
commit | 14bc11a651971bbbdf96565898be2c94fa2b1cf5 (patch) | |
tree | c3e6357e061451da4079f84a281723a8de8c01dd /clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp | |
parent | bdc3e6cb45203ba59e6654da2cb7212ef3a15854 (diff) | |
download | llvm-14bc11a651971bbbdf96565898be2c94fa2b1cf5.zip llvm-14bc11a651971bbbdf96565898be2c94fa2b1cf5.tar.gz llvm-14bc11a651971bbbdf96565898be2c94fa2b1cf5.tar.bz2 |
[clang][dataflow]Use cast_or_null instead of cast to prevent crash (#68510)
`getStorageLocation` may return `nullptr` and this will produce crash
when use `cast`, use `dyn_cast_or_null` instead. I test it locally using
[FTXUI](https://github.com/ArthurSonzogni/FTXUI) and it may be the cause
of issue [issue](https://github.com/llvm/llvm-project/issues/68412), but
I am not sure.
Co-authored-by: huqizhi <huqizhi@836744285@qq.com>
Diffstat (limited to 'clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp')
-rw-r--r-- | clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp index f61f26f..8bd9a03 100644 --- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp +++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp @@ -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 = cast_or_null<RecordStorageLocation>( State.Env.getStorageLocation(*E->getArg(0)))) { createOptionalValue(*Loc, HasValueVal, State.Env); |