[llvm] d936c0c - [Clang] [OMPIRBuilder] Prevent Null Pointer Dereference in OpenMP IR Builder (#115506)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 21 08:35:17 PST 2024
Author: smanna12
Date: 2024-11-21T10:35:14-06:00
New Revision: d936c0cef0bddc577c9615ac46537413b92b19ee
URL: https://github.com/llvm/llvm-project/commit/d936c0cef0bddc577c9615ac46537413b92b19ee
DIFF: https://github.com/llvm/llvm-project/commit/d936c0cef0bddc577c9615ac46537413b92b19ee.diff
LOG: [Clang] [OMPIRBuilder] Prevent Null Pointer Dereference in OpenMP IR Builder (#115506)
This commit addresses Static Analyzer issues related to potential null
dereference by replacing dyn_cast<> with cast<> in OMPIRBuilder.cpp to
ensure that ArgStructType is not null before it is used, improving the
stability and reliability of the code.
Added:
Modified:
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 59d34f67f8cfbc..ef192813679ba9 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -6962,8 +6962,7 @@ static Function *emitTargetTaskProxyFunction(OpenMPIRBuilder &OMPBuilder,
assert(ArgStructAlloca &&
"Unable to find the alloca instruction corresponding to arguments "
"for extracted function");
- auto *ArgStructType =
- dyn_cast<StructType>(ArgStructAlloca->getAllocatedType());
+ auto *ArgStructType = cast<StructType>(ArgStructAlloca->getAllocatedType());
AllocaInst *NewArgStructAlloca =
Builder.CreateAlloca(ArgStructType, nullptr, "structArg");
More information about the llvm-commits
mailing list