Author: Dmitri Gribenko
Date: 2023-05-30T18:30:30+02:00
New Revision: 8a40f89e2e9357539db0f9a119db0fcfc77232ab

URL: 
https://github.com/llvm/llvm-project/commit/8a40f89e2e9357539db0f9a119db0fcfc77232ab
DIFF: 
https://github.com/llvm/llvm-project/commit/8a40f89e2e9357539db0f9a119db0fcfc77232ab.diff

LOG: [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

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Core/MemRegion.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp 
b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index bb45a879471a..d7409ae6aebe 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -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 {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to