[llvm] 50fe87a - [Transforms] classifyArgUse - don't deference pointer before null test
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 09:24:20 PDT 2022
Author: Simon Pilgrim
Date: 2022-10-25T17:24:00+01:00
New Revision: 50fe87a5c8597eb72e6055356fa7dad364756ff7
URL: https://github.com/llvm/llvm-project/commit/50fe87a5c8597eb72e6055356fa7dad364756ff7
DIFF: https://github.com/llvm/llvm-project/commit/50fe87a5c8597eb72e6055356fa7dad364756ff7.diff
LOG: [Transforms] classifyArgUse - don't deference pointer before null test
Reported here: https://pvs-studio.com/en/blog/posts/cpp/1003/ (N11)
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index dd25fb3e9a84e..7922f785c338a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2621,9 +2621,7 @@ void LibCallSimplifier::classifyArgUse(
SmallVectorImpl<CallInst *> &SinCalls,
SmallVectorImpl<CallInst *> &CosCalls,
SmallVectorImpl<CallInst *> &SinCosCalls) {
- CallInst *CI = dyn_cast<CallInst>(Val);
- Module *M = CI->getModule();
-
+ auto *CI = dyn_cast<CallInst>(Val);
if (!CI || CI->use_empty())
return;
@@ -2631,6 +2629,7 @@ void LibCallSimplifier::classifyArgUse(
if (CI->getFunction() != F)
return;
+ Module *M = CI->getModule();
Function *Callee = CI->getCalledFunction();
LibFunc Func;
if (!Callee || !TLI->getLibFunc(*Callee, Func) ||
More information about the llvm-commits
mailing list