From d614e8fb3faac334e14c86f0ba2e34ecfcd92b43 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 29 Aug 2025 18:47:28 +0200 Subject: [PATCH] cmLocalGenerator: check variables before usage Reported by https://pvs-studio.com/en/blog/posts/cpp/1277/ (N2) Issue: 27159 --- Source/cmLocalGenerator.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2638af1d28..5fd931f69d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1441,7 +1441,7 @@ void cmLocalGenerator::GetDeviceLinkFlags( auto linklang = linkLineComputer.GetLinkerLanguage(target, config); auto ipoEnabled = target->IsIPOEnabled(linklang, config); - if (!ipoEnabled) { + if (!ipoEnabled && pcli) { ipoEnabled = linkLineComputer.ComputeRequiresDeviceLinkingIPOFlag(*pcli); } if (ipoEnabled) { @@ -3001,9 +3001,8 @@ void cmLocalGenerator::CopyPchCompilePdb( } else { cc->SetOutputs(outputs); cmSourceFile* copy_rule = this->AddCustomCommandToOutput(std::move(cc)); - copy_rule->SetProperty("CXX_SCAN_FOR_MODULES", "0"); - if (copy_rule) { + copy_rule->SetProperty("CXX_SCAN_FOR_MODULES", "0"); target->AddSource(copy_rule->ResolveFullPath()); } }