Skip to content

Commit

Permalink
[clang][analyzer][NFC] Replace dyn_cast with cast in MemRegion::getMe…
Browse files Browse the repository at this point in the history
…morySpace

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
  • Loading branch information
gribozavr committed May 30, 2023
1 parent 0989ce9 commit 8a40f89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/MemRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ const MemSpaceRegion *MemRegion::getMemorySpace() const {
SR = dyn_cast<SubRegion>(R);
}

return dyn_cast<MemSpaceRegion>(R);
return cast<MemSpaceRegion>(R);
}

bool MemRegion::hasStackStorage() const {
Expand Down

0 comments on commit 8a40f89

Please sign in to comment.