[PATCH] D151727: [clang] Replace dyn_cast with cast in MemRegion::getMemorySpace
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 30 08:47:22 PDT 2023
gribozavr created this revision.
gribozavr added a reviewer: NoQ.
Herald added subscribers: steakhal, martong.
Herald added a project: All.
gribozavr requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151727
Files:
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1283,7 +1283,7 @@
SR = dyn_cast<SubRegion>(R);
}
- return dyn_cast<MemSpaceRegion>(R);
+ return cast<MemSpaceRegion>(R);
}
bool MemRegion::hasStackStorage() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151727.526656.patch
Type: text/x-patch
Size: 400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230530/818f1dce/attachment.bin>
More information about the cfe-commits
mailing list