Skip to content

Commit 7d764ce

Browse files
RKSimonfhahn
authored andcommitted
[Transforms] classifyArgUse - don't deference pointer before null test
Reported here: https://pvs-studio.com/en/blog/posts/cpp/1003/ (N11)
1 parent 01bda06 commit 7d764ce

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,16 +2621,15 @@ void LibCallSimplifier::classifyArgUse(
26212621
SmallVectorImpl<CallInst *> &SinCalls,
26222622
SmallVectorImpl<CallInst *> &CosCalls,
26232623
SmallVectorImpl<CallInst *> &SinCosCalls) {
2624-
CallInst *CI = dyn_cast<CallInst>(Val);
2625-
Module *M = CI->getModule();
2626-
2624+
auto *CI = dyn_cast<CallInst>(Val);
26272625
if (!CI || CI->use_empty())
26282626
return;
26292627

26302628
// Don't consider calls in other functions.
26312629
if (CI->getFunction() != F)
26322630
return;
26332631

2632+
Module *M = CI->getModule();
26342633
Function *Callee = CI->getCalledFunction();
26352634
LibFunc Func;
26362635
if (!Callee || !TLI->getLibFunc(*Callee, Func) ||

0 commit comments

Comments
 (0)