[Transforms] classifyArgUse - don't deference pointer before null test

Reported here: https://pvs-studio.com/en/blog/posts/cpp/1003/ (N11)
This commit is contained in:
Simon Pilgrim
2022-10-25 17:23:25 +01:00
parent 60809cd293
commit 50fe87a5c8

View File

@@ -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) ||