[clang][analyzer][NFC] Replace dyn_cast with cast in MemRegion::getMemorySpace
commit8a40f89e2e9357539db0f9a119db0fcfc77232ab
authorDmitri Gribenko <gribozavr@gmail.com>
Tue, 30 May 2023 16:23:11 +0000 (30 18:23 +0200)
committerDmitri Gribenko <gribozavr@gmail.com>
Tue, 30 May 2023 16:30:30 +0000 (30 18:30 +0200)
treeb6b7ef1ba6ae54645def0b843dae6a9eff0b298a
parent0989ce947e3dd64f3e29e7c34f186c0a23c0323d
[clang][analyzer][NFC] Replace dyn_cast with cast in MemRegion::getMemorySpace

MemRegion::getMemorySpace() is annotated with
LLVM_ATTRIBUTE_RETURNS_NONNULL (which triggers instant UB if a null
pointer is returned), and callers indeed don't check the return value
for null. Thus, even though llvm::dyn_cast is called, it can never
return null in this context. Therefore, we can safely call llvm::cast.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D151727
clang/lib/StaticAnalyzer/Core/MemRegion.cpp