Source: Remove unnecessary comparisons to nullptr

This commit is contained in:
Vitaly Stakhovsky
2021-05-10 11:00:00 -04:00
parent 2ee55f9718
commit ce97b7909b
14 changed files with 40 additions and 43 deletions
+1 -1
View File
@@ -1229,7 +1229,7 @@ bool cmExportFileGenerator::PopulateExportProperties(
return false;
}
cmProp propertyValue = targetProperties.GetPropertyValue(prop);
if (propertyValue == nullptr) {
if (!propertyValue) {
// Asked to export a property that isn't defined on the target. Do not
// consider this an error, there's just nothing to export.
continue;
+3 -3
View File
@@ -248,17 +248,17 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
// now we have both, decide which one to use
std::string valueToUse;
if (!envVarSet && cacheValue == nullptr) {
if (!envVarSet && !cacheValue) {
// nothing known, do nothing
valueToUse.clear();
} else if (envVarSet && cacheValue == nullptr) {
} else if (envVarSet && !cacheValue) {
// The variable is in the env, but not in the cache. Use it and put it
// in the cache
valueToUse = envVarValue;
mf->AddCacheDefinition(cacheEntryName, valueToUse, cacheEntryName.c_str(),
cmStateEnums::STRING, true);
mf->GetCMakeInstance()->SaveCache(lg.GetBinaryDirectory());
} else if (!envVarSet && cacheValue != nullptr) {
} else if (!envVarSet && cacheValue) {
// It is already in the cache, but not in the env, so use it from the cache
valueToUse = *cacheValue;
} else {
+1 -1
View File
@@ -130,7 +130,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg,
if (targetName == "edit_cache") {
cmProp editCommand =
localGen->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND");
if (editCommand == nullptr ||
if (!editCommand ||
strstr(editCommand->c_str(), "ccmake") != nullptr) {
insertTarget = false;
}
+5 -6
View File
@@ -970,7 +970,7 @@ cmProp cmGeneratorTarget::GetPropertyWithPairedLanguageSupport(
std::string const& lang, const char* suffix) const
{
cmProp propertyValue = this->Target->GetProperty(cmStrCat(lang, suffix));
if (propertyValue == nullptr) {
if (!propertyValue) {
// Check if we should use the value set by another language.
if (lang == "OBJC") {
propertyValue = this->GetPropertyWithPairedLanguageSupport("C", suffix);
@@ -4715,21 +4715,20 @@ bool cmGeneratorTarget::ComputeCompileFeatures(
cmStrCat(cmSystemTools::UpperCase(config), '-', language.first);
BTs<std::string> const* standardToCopy =
this->GetLanguageStandardProperty(language.second, config);
if (standardToCopy != nullptr) {
if (standardToCopy) {
this->LanguageStandardMap[key] = *standardToCopy;
generatorTargetLanguageStandard = &this->LanguageStandardMap[key];
} else {
cmProp defaultStandard = this->Makefile->GetDefinition(
cmStrCat("CMAKE_", language.second, "_STANDARD_DEFAULT"));
if (defaultStandard != nullptr) {
if (defaultStandard) {
this->LanguageStandardMap[key] = BTs<std::string>(*defaultStandard);
generatorTargetLanguageStandard = &this->LanguageStandardMap[key];
}
}
// Custom updates for the CUDA standard.
if (generatorTargetLanguageStandard != nullptr &&
language.first == "CUDA") {
if (generatorTargetLanguageStandard && language.first == "CUDA") {
if (generatorTargetLanguageStandard->Value == "98") {
this->LanguageStandardMap[key].Value = "03";
}
@@ -6771,7 +6770,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
return;
}
iface.Exists = true;
iface.Explicit = cmp0022NEW || explicitLibraries != nullptr;
iface.Explicit = cmp0022NEW || explicitLibraries;
if (explicitLibraries) {
// The interface libraries have been explicitly set.
+1 -1
View File
@@ -710,7 +710,7 @@ void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
std::ostream& fout, const cmSourceFile* sourceFile)
{
cmProp rawLangProp = sourceFile->GetProperty("LANGUAGE");
if (nullptr != rawLangProp) {
if (rawLangProp) {
std::string sourceLangProp(*rawLangProp);
std::string const& extension = sourceFile->GetExtension();
if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) {
+3 -3
View File
@@ -2438,7 +2438,7 @@ void cmLocalGenerator::AddISPCDependencies(cmGeneratorTarget* target)
}
cmProp ispcHeaderSuffixProp = target->GetProperty("ISPC_HEADER_SUFFIX");
assert(ispcHeaderSuffixProp != nullptr);
assert(ispcHeaderSuffixProp);
std::vector<std::string> ispcArchSuffixes =
detail::ComputeISPCObjectSuffixes(target);
@@ -3001,7 +3001,7 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags,
const std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_IPO";
cmProp rawFlagsList = this->Makefile->GetDefinition(name);
if (rawFlagsList == nullptr) {
if (!rawFlagsList) {
return;
}
@@ -3240,7 +3240,7 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags,
{
cmProp optionList = this->Makefile->GetDefinition(
cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_", feature));
if (optionList != nullptr) {
if (optionList) {
std::vector<std::string> options = cmExpandedList(*optionList);
for (std::string const& o : options) {
this->AppendFlagEscape(flags, o);
+2 -2
View File
@@ -1214,7 +1214,7 @@ void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
cmProp additionalFiles =
target->GetProperty("DEPLOYMENT_ADDITIONAL_FILES");
if (dir == nullptr && additionalFiles == nullptr) {
if (!dir && !additionalFiles) {
return;
}
@@ -1228,7 +1228,7 @@ void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
<< GetEscapedPropertyIfValueNotNULL(additionalFiles->c_str())
<< "\"/>\n";
if (dir != nullptr) {
if (dir) {
std::string const exe = *dir + "\\" + target->GetFullName(config);
fout << "\t\t\t<DebuggerTool\n"
+1 -1
View File
@@ -663,7 +663,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
cmProp ispcSuffixProp =
this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX");
assert(ispcSuffixProp != nullptr);
assert(ispcSuffixProp);
std::string directory = this->GeneratorTarget->GetObjectDirectory(config);
if (cmProp prop =
+1 -1
View File
@@ -1444,7 +1444,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
cmProp ispcSuffixProp =
this->GeneratorTarget->GetProperty("ISPC_HEADER_SUFFIX");
assert(ispcSuffixProp != nullptr);
assert(ispcSuffixProp);
std::string ispcHeaderDirectory =
this->GeneratorTarget->GetObjectDirectory(config);
+1 -1
View File
@@ -185,7 +185,7 @@ void cmQtAutoGenGlobalInitializer::GetOrCreateGlobalTarget(
{
cmProp folder =
makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
if (folder != nullptr) {
if (folder) {
target->SetProperty("FOLDER", *folder);
}
}
+17 -17
View File
@@ -114,10 +114,10 @@ bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin,
// Collect all static_library dependencies from the test target
cmLinkImplementationLibraries const* libs =
testTarget->GetLinkImplementationLibraries(config);
if (libs != nullptr) {
if (libs) {
for (cmLinkItem const& item : libs->Libraries) {
cmGeneratorTarget const* depTarget = item.Target;
if ((depTarget != nullptr) &&
if (depTarget &&
(depTarget->GetType() == cmStateEnums::STATIC_LIBRARY) &&
knownLibs.insert(depTarget).second) {
testLibs.push_back(depTarget);
@@ -357,15 +357,15 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
{
cmProp folder =
this->Makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
if (folder == nullptr) {
if (!folder) {
folder = this->Makefile->GetState()->GetGlobalProperty(
"AUTOGEN_TARGETS_FOLDER");
}
// Inherit FOLDER property from target (#13688)
if (folder == nullptr) {
if (!folder) {
folder = this->GenTarget->GetProperty("FOLDER");
}
if (folder != nullptr) {
if (folder) {
this->TargetsFolder = *folder;
}
}
@@ -490,7 +490,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
for (std::string const& depName : cmExpandedList(deps)) {
// Allow target and file dependencies
auto* depTarget = this->Makefile->FindTargetToUse(depName);
if (depTarget != nullptr) {
if (depTarget) {
this->AutogenTarget.DependTargets.insert(depTarget);
} else {
this->AutogenTarget.DependFiles.insert(depName);
@@ -662,7 +662,7 @@ bool cmQtAutoGenInitializer::InitMoc()
return false;
}
// Let the _autogen target depend on the moc executable
if (this->Moc.ExecutableTarget != nullptr) {
if (this->Moc.ExecutableTarget) {
this->AutogenTarget.DependTargets.insert(
this->Moc.ExecutableTarget->Target);
}
@@ -710,7 +710,7 @@ bool cmQtAutoGenInitializer::InitUic()
return false;
}
// Let the _autogen target depend on the uic executable
if (this->Uic.ExecutableTarget != nullptr) {
if (this->Uic.ExecutableTarget) {
this->AutogenTarget.DependTargets.insert(
this->Uic.ExecutableTarget->Target);
}
@@ -865,7 +865,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
auto constexpr locationKind = cmSourceFileLocationKind::Known;
cmSourceFile* sf =
this->Makefile->GetSource(fullPath, locationKind);
if (sf != nullptr) {
if (sf) {
// Check if we know about this header already
if (cm::contains(this->AutogenTarget.Headers, sf)) {
continue;
@@ -880,7 +880,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
sf = this->Makefile->CreateSource(fullPath, false, locationKind);
}
if (sf != nullptr) {
if (sf) {
auto eMuf = makeMUFile(sf, fullPath, muf.Configs, true);
// Only process moc/uic when the parent is processed as well
if (!muf.MocIt) {
@@ -1243,10 +1243,10 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
for (std::string const& config : this->ConfigsList) {
cmLinkImplementationLibraries const* libs =
this->GenTarget->GetLinkImplementationLibraries(config);
if (libs != nullptr) {
if (libs) {
for (cmLinkItem const& item : libs->Libraries) {
cmGeneratorTarget const* libTarget = item.Target;
if ((libTarget != nullptr) &&
if (libTarget &&
!StaticLibraryCycle(this->GenTarget, libTarget, config)) {
// Increment target config count
commonTargets[libTarget]++;
@@ -1780,7 +1780,7 @@ void cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
// Generate a source group on demand
if (!groupName.empty()) {
sourceGroup = this->Makefile->GetOrCreateSourceGroup(groupName);
if (sourceGroup == nullptr) {
if (!sourceGroup) {
cmSystemTools::Error(
cmStrCat(genNameUpper, " error in ", property,
": Could not find or create the source group ",
@@ -1788,7 +1788,7 @@ void cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
}
}
}
if (sourceGroup != nullptr) {
if (sourceGroup) {
sourceGroup->AddGroupFile(fileName);
}
}
@@ -1894,14 +1894,14 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target,
// Converts a char ptr to an unsigned int value
auto toUInt = [](const char* const input) -> unsigned int {
unsigned long tmp = 0;
if (input != nullptr && cmStrToULong(input, &tmp)) {
if (input && cmStrToULong(input, &tmp)) {
return static_cast<unsigned int>(tmp);
}
return 0u;
};
auto toUInt2 = [](cmProp input) -> unsigned int {
unsigned long tmp = 0;
if (input != nullptr && cmStrToULong(*input, &tmp)) {
if (input && cmStrToULong(*input, &tmp)) {
return static_cast<unsigned int>(tmp);
}
return 0u;
@@ -2073,7 +2073,7 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
// Find target
cmGeneratorTarget* genTarget =
this->LocalGen->FindGeneratorTargetToUse(targetName);
if (genTarget != nullptr) {
if (genTarget) {
genVars.ExecutableTargetName = targetName;
genVars.ExecutableTarget = genTarget;
if (genTarget->IsImported()) {
+1 -1
View File
@@ -184,7 +184,7 @@ struct StanardLevelComputer
auto needed = this->HighestStandardNeeded(makefile, feature);
cmProp existingStandard = currentLangStandardValue;
if (existingStandard == nullptr) {
if (!existingStandard) {
cmProp defaultStandard = makefile->GetDefinition(
cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT"));
if (cmNonempty(defaultStandard)) {
+1 -1
View File
@@ -324,7 +324,7 @@ bool cmXCodeScheme::WriteLaunchActionBooleanAttribute(
bool defaultValue)
{
cmProp property = Target->GetTarget()->GetProperty(varName);
bool isOn = (property == nullptr && defaultValue) || cmIsOn(property);
bool isOn = (!property && defaultValue) || cmIsOn(property);
if (isOn) {
xout.Attribute(attrName.c_str(), "YES");
+2 -4
View File
@@ -1251,15 +1251,13 @@ void cmake::SetArgs(const std::vector<std::string>& args)
this->UnprocessedPresetEnvironment = expandedPreset->Environment;
if (!expandedPreset->InstallDir.empty() &&
this->State->GetInitializedCacheValue("CMAKE_INSTALL_PREFIX") ==
nullptr) {
!this->State->GetInitializedCacheValue("CMAKE_INSTALL_PREFIX")) {
this->UnprocessedPresetVariables["CMAKE_INSTALL_PREFIX"] = {
"PATH", expandedPreset->InstallDir
};
}
if (!expandedPreset->ToolchainFile.empty() &&
this->State->GetInitializedCacheValue("CMAKE_TOOLCHAIN_FILE") ==
nullptr) {
!this->State->GetInitializedCacheValue("CMAKE_TOOLCHAIN_FILE")) {
this->UnprocessedPresetVariables["CMAKE_TOOLCHAIN_FILE"] = {
"FILEPATH", expandedPreset->ToolchainFile
};