Simplify boolean expressions

Use clang-tidy's readability-simplify-boolean-expr checker.
After applying the fix-its, revise all changes *very* carefully.
Be aware of false positives and invalid changes.
This commit is contained in:
Daniel Pfeifer 2016-06-01 23:29:53 +02:00 committed by Brad King
parent d6754d37d5
commit 7f6b8d3399
37 changed files with 73 additions and 169 deletions

View File

@ -45,16 +45,16 @@ bool cmCPackIFWRepository::IsValid() const
switch (Update) { switch (Update) {
case None: case None:
valid = Url.empty() ? false : true; valid = !Url.empty();
break; break;
case Add: case Add:
valid = Url.empty() ? false : true; valid = !Url.empty();
break; break;
case Remove: case Remove:
valid = Url.empty() ? false : true; valid = !Url.empty();
break; break;
case Replace: case Replace:
valid = (OldUrl.empty() || NewUrl.empty()) ? false : true; valid = !OldUrl.empty() && !NewUrl.empty();
break; break;
} }
@ -244,11 +244,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml()
fout.Close(); fout.Close();
if (!cmSystemTools::RenameFile(updatesPatchXml.data(), updatesXml.data())) { return cmSystemTools::RenameFile(updatesPatchXml.data(), updatesXml.data());
return false;
}
return true;
} }
void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout) void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout)

View File

@ -269,9 +269,5 @@ bool cmCPackArchiveGenerator::SupportsComponentInstallation() const
// The Component installation support should only // The Component installation support should only
// be activated if explicitly requested by the user // be activated if explicitly requested by the user
// (for backward compatibility reason) // (for backward compatibility reason)
if (IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL")) { return IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL");
return true;
} else {
return false;
}
} }

View File

@ -675,11 +675,7 @@ int cmCPackDebGenerator::createDeb()
bool cmCPackDebGenerator::SupportsComponentInstallation() const bool cmCPackDebGenerator::SupportsComponentInstallation() const
{ {
if (IsOn("CPACK_DEB_COMPONENT_INSTALL")) { return IsOn("CPACK_DEB_COMPONENT_INSTALL");
return true;
} else {
return false;
}
} }
std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(

View File

@ -228,11 +228,7 @@ int cmCPackRPMGenerator::PackageFiles()
bool cmCPackRPMGenerator::SupportsComponentInstallation() const bool cmCPackRPMGenerator::SupportsComponentInstallation() const
{ {
if (IsOn("CPACK_RPM_COMPONENT_INSTALL")) { return IsOn("CPACK_RPM_COMPONENT_INSTALL");
return true;
} else {
return false;
}
} }
std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix( std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(

View File

@ -209,11 +209,7 @@ int main(int argc, char const* const* argv)
* should launch cpack using "cpackConfigFile" if it exists * should launch cpack using "cpackConfigFile" if it exists
* in the current directory. * in the current directory.
*/ */
if ((doc.CheckOptions(argc, argv, "-G")) && !(argc == 1)) { help = doc.CheckOptions(argc, argv, "-G") && argc != 1;
help = true;
} else {
help = false;
}
// This part is used for cpack documentation lookup as well. // This part is used for cpack documentation lookup as well.
cminst.AddCMakePaths(); cminst.AddCMakePaths();

View File

@ -90,11 +90,8 @@ public:
cmsysProcess_Execute(this->Process); cmsysProcess_Execute(this->Process);
this->PipeState = cmsysProcess_GetState(this->Process); this->PipeState = cmsysProcess_GetState(this->Process);
// if the process is running or exited return true // if the process is running or exited return true
if (this->PipeState == cmsysProcess_State_Executing || return this->PipeState == cmsysProcess_State_Executing ||
this->PipeState == cmsysProcess_State_Exited) { this->PipeState == cmsysProcess_State_Exited;
return true;
}
return false;
} }
void SetStdoutFile(const char* fname) void SetStdoutFile(const char* fname)
{ {
@ -705,13 +702,8 @@ bool IsFileInDir(const std::string& infile, const std::string& indir)
std::string file = cmSystemTools::CollapseFullPath(infile); std::string file = cmSystemTools::CollapseFullPath(infile);
std::string dir = cmSystemTools::CollapseFullPath(indir); std::string dir = cmSystemTools::CollapseFullPath(indir);
if (file.size() > dir.size() && return file.size() > dir.size() &&
(fnc(file.substr(0, dir.size())) == fnc(dir)) && fnc(file.substr(0, dir.size())) == fnc(dir) && file[dir.size()] == '/';
file[dir.size()] == '/') {
return true;
}
return false;
} }
int cmCTestCoverageHandler::HandlePHPCoverage( int cmCTestCoverageHandler::HandlePHPCoverage(

View File

@ -594,12 +594,8 @@ bool cmCTestLaunch::Match(std::string const& line,
bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const
{ {
if (!this->OptionFilterPrefix.empty() && return !this->OptionFilterPrefix.empty() &&
cmSystemTools::StringStartsWith(line.c_str(), cmSystemTools::StringStartsWith(line, this->OptionFilterPrefix.c_str());
this->OptionFilterPrefix.c_str())) {
return true;
}
return false;
} }
int cmCTestLaunch::Main(int argc, const char* const argv[]) int cmCTestLaunch::Main(int argc, const char* const argv[])

View File

@ -722,10 +722,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
ostr << *i << std::endl; ostr << *i << std::endl;
} }
log = ostr.str(); log = ostr.str();
if (defects) { return defects == 0;
return false;
}
return true;
} }
bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
const std::string& str, std::string& log, std::vector<int>& results) const std::string& str, std::string& log, std::vector<int>& results)
@ -766,10 +763,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
} }
log = ostr.str(); log = ostr.str();
if (defects) { return defects == 0;
return false;
}
return true;
} }
bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
@ -904,10 +898,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
<< (cmSystemTools::GetTime() - sttime) << std::endl, << (cmSystemTools::GetTime() - sttime) << std::endl,
this->Quiet); this->Quiet);
log = ostr.str(); log = ostr.str();
if (defects) { return defects == 0;
return false;
}
return true;
} }
bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(

View File

@ -845,10 +845,7 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command,
} }
} }
cmsysProcess_Delete(cp); cmsysProcess_Delete(cp);
if (problems) { return problems == 0;
return false;
}
return true;
} }
bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix, bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
@ -870,7 +867,6 @@ bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
} }
cmCTest::SetOfStrings::const_iterator file; cmCTest::SetOfStrings::const_iterator file;
bool problems = false;
for (file = files.begin(); file != files.end(); ++file) { for (file = files.begin(); file != files.end(); ++file) {
std::string lfname = localprefix; std::string lfname = localprefix;
cmSystemTools::ConvertToUnixSlashes(lfname); cmSystemTools::ConvertToUnixSlashes(lfname);
@ -883,9 +879,6 @@ bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
} }
std::string tagDoneFile = destination + "/" + remoteprefix + "DONE"; std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
cmSystemTools::Touch(tagDoneFile, true); cmSystemTools::Touch(tagDoneFile, true);
if (problems) {
return false;
}
return true; return true;
} }

View File

@ -1406,7 +1406,7 @@ void cmCTestTestHandler::UseIncludeRegExp()
void cmCTestTestHandler::UseExcludeRegExp() void cmCTestTestHandler::UseExcludeRegExp()
{ {
this->UseExcludeRegExpFlag = true; this->UseExcludeRegExpFlag = true;
this->UseExcludeRegExpFirst = this->UseIncludeRegExpFlag ? false : true; this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag;
} }
const char* cmCTestTestHandler::GetTestStatus(int status) const char* cmCTestTestHandler::GetTestStatus(int status)

View File

@ -27,10 +27,7 @@ bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until)
char c = 0; char c = 0;
while (in.get(c) && c != until) { while (in.get(c) && c != until) {
} }
if (c != until) { return c == until;
return false;
}
return true;
} }
bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
std::string const& fileName) std::string const& fileName)

View File

@ -54,9 +54,5 @@ void cmCursesBoolWidget::SetValueAsBool(bool value)
bool cmCursesBoolWidget::GetValueAsBool() bool cmCursesBoolWidget::GetValueAsBool()
{ {
if (this->Value == "ON") { return this->Value == "ON";
return true;
} else {
return false;
}
} }

View File

@ -642,5 +642,5 @@ void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v)
bool cmCacheManager::CacheIterator::PropertyExists( bool cmCacheManager::CacheIterator::PropertyExists(
const std::string& prop) const const std::string& prop) const
{ {
return this->GetProperty(prop) ? true : false; return this->GetProperty(prop) != NULL;
} }

View File

@ -274,8 +274,7 @@ cmComputeLinkInformation::cmComputeLinkInformation(
// Check whether we should use an import library for linking a target. // Check whether we should use an import library for linking a target.
this->UseImportLibrary = this->UseImportLibrary =
this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX") ? true this->Makefile->IsDefinitionSet("CMAKE_IMPORT_LIBRARY_SUFFIX");
: false;
// Check whether we should skip dependencies on shared library files. // Check whether we should skip dependencies on shared library files.
this->LinkDependsNoShared = this->LinkDependsNoShared =

View File

@ -38,7 +38,7 @@ cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
, Backtrace() , Backtrace()
, Comment(comment ? comment : "") , Comment(comment ? comment : "")
, WorkingDirectory(workingDirectory ? workingDirectory : "") , WorkingDirectory(workingDirectory ? workingDirectory : "")
, HaveComment(comment ? true : false) , HaveComment(comment != NULL)
, EscapeAllowMakeVars(false) , EscapeAllowMakeVars(false)
, EscapeOldStyle(true) , EscapeOldStyle(true)
{ {

View File

@ -278,21 +278,21 @@ void cmDependsC::ReadCacheFile()
continue; continue;
} }
// the first line after an empty line is the name of the parsed file // the first line after an empty line is the name of the parsed file
if (haveFileName == false) { if (!haveFileName) {
haveFileName = true; haveFileName = true;
int newer = 0; int newer = 0;
cmFileTimeComparison comp; cmFileTimeComparison comp;
bool res = comp.FileTimeCompare(this->CacheFileName.c_str(), bool res = comp.FileTimeCompare(this->CacheFileName.c_str(),
line.c_str(), &newer); line.c_str(), &newer);
if ((res == true) && (newer == 1)) // cache is newer than the parsed file if (res && newer == 1) // cache is newer than the parsed file
{ {
cacheEntry = new cmIncludeLines; cacheEntry = new cmIncludeLines;
this->FileCache[line] = cacheEntry; this->FileCache[line] = cacheEntry;
} }
// file doesn't exist, check that the regular expressions // file doesn't exist, check that the regular expressions
// haven't changed // haven't changed
else if (res == false) { else if (!res) {
if (line.find(INCLUDE_REGEX_LINE_MARKER) == 0) { if (line.find(INCLUDE_REGEX_LINE_MARKER) == 0) {
if (line != this->IncludeRegexLineString) { if (line != this->IncludeRegexLineString) {
return; return;

View File

@ -654,10 +654,9 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
// but also do not include a date so we can fall through to // but also do not include a date so we can fall through to
// compare them without skipping any prefix. // compare them without skipping any prefix.
unsigned char hdr[2]; unsigned char hdr[2];
bool okay = bool okay = !finModFile.read(reinterpret_cast<char*>(hdr), 2).fail();
finModFile.read(reinterpret_cast<char*>(hdr), 2) ? true : false;
finModFile.seekg(0); finModFile.seekg(0);
if (!(okay && hdr[0] == 0x1f && hdr[1] == 0x8b)) { if (!okay || hdr[0] != 0x1f || hdr[1] != 0x8b) {
const char seq[1] = { '\n' }; const char seq[1] = { '\n' };
const int seqlen = 1; const int seqlen = 1;

View File

@ -143,7 +143,7 @@ public:
{ {
this->Stream.seekg(pos); this->Stream.seekg(pos);
this->Stream.read(buf, size); this->Stream.read(buf, size);
return this->Stream ? true : false; return !this->Stream.fail();
} }
// Lookup the SONAME in the DYNAMIC section. // Lookup the SONAME in the DYNAMIC section.
@ -497,7 +497,7 @@ private:
this->NeedSwap) { this->NeedSwap) {
ByteSwap(x); ByteSwap(x);
} }
return this->Stream ? true : false; return !this->Stream.fail();
} }
bool Read(ELF_Dyn& x) bool Read(ELF_Dyn& x)
{ {
@ -505,7 +505,7 @@ private:
this->NeedSwap) { this->NeedSwap) {
ByteSwap(x); ByteSwap(x);
} }
return this->Stream ? true : false; return !this->Stream.fail();
} }
bool LoadSectionHeader(ELF_Half i) bool LoadSectionHeader(ELF_Half i)

View File

@ -655,11 +655,11 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
// projects with C/C++ and Fortran are handled as C/C++ projects // projects with C/C++ and Fortran are handled as C/C++ projects
bool pureFortran = false; bool pureFortran = false;
std::string compilerIdVar; std::string compilerIdVar;
if (this->GlobalGenerator->GetLanguageEnabled("CXX") == true) { if (this->GlobalGenerator->GetLanguageEnabled("CXX")) {
compilerIdVar = "CMAKE_CXX_COMPILER_ID"; compilerIdVar = "CMAKE_CXX_COMPILER_ID";
} else if (this->GlobalGenerator->GetLanguageEnabled("C") == true) { } else if (this->GlobalGenerator->GetLanguageEnabled("C")) {
compilerIdVar = "CMAKE_C_COMPILER_ID"; compilerIdVar = "CMAKE_C_COMPILER_ID";
} else if (this->GlobalGenerator->GetLanguageEnabled("Fortran") == true) { } else if (this->GlobalGenerator->GetLanguageEnabled("Fortran")) {
compilerIdVar = "CMAKE_Fortran_COMPILER_ID"; compilerIdVar = "CMAKE_Fortran_COMPILER_ID";
pureFortran = true; pureFortran = true;
} }
@ -667,7 +667,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
std::string compiler = "gcc"; // default to gcc std::string compiler = "gcc"; // default to gcc
if (compilerId == "MSVC") { if (compilerId == "MSVC") {
if (mf->IsDefinitionSet("MSVC10") == true) { if (mf->IsDefinitionSet("MSVC10")) {
compiler = "msvc10"; compiler = "msvc10";
} else { } else {
compiler = "msvc8"; compiler = "msvc8";

View File

@ -407,7 +407,7 @@ std::string cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(
// figure out which language to use // figure out which language to use
// for now care only for C and C++ // for now care only for C and C++
std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID"; std::string compilerIdVar = "CMAKE_CXX_COMPILER_ID";
if (this->GlobalGenerator->GetLanguageEnabled("CXX") == false) { if (!this->GlobalGenerator->GetLanguageEnabled("CXX")) {
compilerIdVar = "CMAKE_C_COMPILER_ID"; compilerIdVar = "CMAKE_C_COMPILER_ID";
} }

View File

@ -129,7 +129,7 @@ void cmExtraEclipseCDT4Generator::Generate()
(this->IsOutOfSourceBuild && (this->IsOutOfSourceBuild &&
mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT")); mf->IsOn("CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT"));
if ((this->GenerateSourceProject == false) && if (!this->GenerateSourceProject &&
(mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"))) { (mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"))) {
mf->IssueMessage( mf->IssueMessage(
cmake::WARNING, cmake::WARNING,

View File

@ -42,7 +42,7 @@ cmGeneratedFileStream::~cmGeneratedFileStream()
// stream will be destroyed which will close the temporary file. // stream will be destroyed which will close the temporary file.
// Finally the base destructor will be called to replace the // Finally the base destructor will be called to replace the
// destination file. // destination file.
this->Okay = (*this) ? true : false; this->Okay = !this->fail();
} }
cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name, cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name,
@ -71,7 +71,7 @@ cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name,
bool cmGeneratedFileStream::Close() bool cmGeneratedFileStream::Close()
{ {
// Save whether the temporary output file is valid before closing. // Save whether the temporary output file is valid before closing.
this->Okay = (*this) ? true : false; this->Okay = !this->fail();
// Close the temporary output file. // Close the temporary output file.
this->Stream::close(); this->Stream::close();

View File

@ -1306,11 +1306,7 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
this->GetName()); this->GetName());
} }
if (cmp0042 == cmPolicies::NEW) { return cmp0042 == cmPolicies::NEW;
return true;
}
return false;
} }
std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string cmGeneratorTarget::GetSOName(const std::string& config) const

View File

@ -180,8 +180,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
} else { } else {
path = name; path = name;
} }
if ((path.empty() || !cmSystemTools::FileExists(path.c_str())) && if (!optional && (path.empty() || !cmSystemTools::FileExists(path))) {
(optional == false)) {
return; return;
} }
const char* cname = const char* cname =

View File

@ -1227,9 +1227,9 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const
bool cmGlobalNinjaGenerator::SupportsConsolePool() const bool cmGlobalNinjaGenerator::SupportsConsolePool() const
{ {
return cmSystemTools::VersionCompare( return !cmSystemTools::VersionCompare(
cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
RequiredNinjaVersionForConsolePool().c_str()) == false; RequiredNinjaVersionForConsolePool().c_str());
} }
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)

View File

@ -140,7 +140,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
// which other targets depend on it. // which other targets depend on it.
void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
{ {
if (this->GenerateDependers == false) { if (!this->GenerateDependers) {
return; return;
} }
@ -153,7 +153,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
continue; continue;
} }
if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) { if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
continue; continue;
} }
@ -184,7 +184,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
// on which targets it depends. // on which targets it depends.
void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
{ {
if (this->GeneratePerTarget == false) { if (!this->GeneratePerTarget) {
return; return;
} }
@ -197,7 +197,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
continue; continue;
} }
if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) { if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
continue; continue;
} }
@ -243,7 +243,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
continue; continue;
} }
if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) { if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
continue; continue;
} }
@ -344,7 +344,7 @@ void cmGraphVizWriter::WriteDependerConnections(
continue; continue;
} }
if (this->GenerateForTargetType(dependerIt->second->GetType()) == false) { if (!this->GenerateForTargetType(dependerIt->second->GetType())) {
continue; continue;
} }
@ -403,7 +403,7 @@ void cmGraphVizWriter::WriteNode(const std::string& targetName,
void cmGraphVizWriter::CollectTargetsAndLibs() void cmGraphVizWriter::CollectTargetsAndLibs()
{ {
if (this->HaveTargetsAndLibs == false) { if (!this->HaveTargetsAndLibs) {
this->HaveTargetsAndLibs = true; this->HaveTargetsAndLibs = true;
int cnt = this->CollectAllTargets(); int cnt = this->CollectAllTargets();
if (this->GenerateForExternals) { if (this->GenerateForExternals) {

View File

@ -202,10 +202,7 @@ bool cmListFile::ParseFile(const char* filename, bool topLevel, cmMakefile* mf)
this->Functions.insert(this->Functions.begin(), project); this->Functions.insert(this->Functions.begin(), project);
} }
} }
if (parseError) { return !parseError;
return false;
}
return true;
} }
bool cmListFileParser::ParseFunction(const char* name, long line) bool cmListFileParser::ParseFunction(const char* name, long line)

View File

@ -1322,7 +1322,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
// not be considered. // not be considered.
std::map<std::string, cmDepends::DependencyVector> validDependencies; std::map<std::string, cmDepends::DependencyVector> validDependencies;
bool needRescanDependencies = false; bool needRescanDependencies = false;
if (needRescanDirInfo == false) { if (!needRescanDirInfo) {
cmDependsC checker; cmDependsC checker;
checker.SetVerbose(verbose); checker.SetVerbose(verbose);
checker.SetFileComparison(ftc); checker.SetFileComparison(ftc);

View File

@ -2124,20 +2124,11 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) const
// If we are doing an in-source build, then the test will always fail // If we are doing an in-source build, then the test will always fail
if (cmSystemTools::SameFile(this->GetHomeDirectory(), if (cmSystemTools::SameFile(this->GetHomeDirectory(),
this->GetHomeOutputDirectory())) { this->GetHomeOutputDirectory())) {
if (this->IsOn("CMAKE_DISABLE_IN_SOURCE_BUILD")) { return !this->IsOn("CMAKE_DISABLE_IN_SOURCE_BUILD");
return false;
}
return true;
} }
// Check if this is a subdirectory of the source tree but not a return !cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) ||
// subdirectory of the build tree cmSystemTools::IsSubDirectory(fileName, this->GetHomeOutputDirectory());
if (cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) &&
!cmSystemTools::IsSubDirectory(fileName,
this->GetHomeOutputDirectory())) {
return false;
}
return true;
} }
const char* cmMakefile::GetRequiredDefinition(const std::string& name) const const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
@ -2166,7 +2157,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const
} }
} }
#endif #endif
return def ? true : false; return def != NULL;
} }
const char* cmMakefile::GetDefinition(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const

View File

@ -454,8 +454,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::vector<std::string> archiveFinishCommands; std::vector<std::string> archiveFinishCommands;
std::string::size_type archiveCommandLimit = std::string::npos; std::string::size_type archiveCommandLimit = std::string::npos;
if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) {
haveStaticLibraryRule = haveStaticLibraryRule = this->Makefile->IsDefinitionSet(linkRuleVar);
this->Makefile->GetDefinition(linkRuleVar) ? true : false;
std::string arCreateVar = "CMAKE_"; std::string arCreateVar = "CMAKE_";
arCreateVar += linkLanguage; arCreateVar += linkLanguage;
arCreateVar += "_ARCHIVE_CREATE"; arCreateVar += "_ARCHIVE_CREATE";

View File

@ -130,8 +130,7 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
// Add include directory flags. // Add include directory flags.
std::string includeFlags = this->LocalGenerator->GetIncludeFlags( std::string includeFlags = this->LocalGenerator->GetIncludeFlags(
includes, this->GeneratorTarget, language, includes, this->GeneratorTarget, language,
language == "RC" ? true : false, // full include paths for RC language == "RC", // full include paths for RC needed by cmcldeps
// needed by cmcldeps
false, this->GetConfigName()); false, this->GetConfigName());
if (this->GetGlobalGenerator()->IsGCCOnWindows()) if (this->GetGlobalGenerator()->IsGCCOnWindows())
std::replace(includeFlags.begin(), includeFlags.end(), '\\', '/'); std::replace(includeFlags.begin(), includeFlags.end(), '\\', '/');

View File

@ -31,12 +31,7 @@ void cmPropertyDefinitionMap::DefineProperty(const std::string& name,
bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) const bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) const
{ {
cmPropertyDefinitionMap::const_iterator it = this->find(name); return this->find(name) != this->end();
if (it == this->end()) {
return false;
}
return true;
} }
bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) const bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) const

View File

@ -636,14 +636,14 @@ void cmQtAutoGenerators::ParseCppFile(
} }
} else { } else {
std::string fileToMoc = absFilename; std::string fileToMoc = absFilename;
if ((basename != scannedFileBasename) || (requiresMoc == false)) { if (!requiresMoc || basename != scannedFileBasename) {
std::string mocSubDir = extractSubDir(absPath, currentMoc); std::string mocSubDir = extractSubDir(absPath, currentMoc);
std::string headerToMoc = std::string headerToMoc =
findMatchingHeader(absPath, mocSubDir, basename, headerExtensions); findMatchingHeader(absPath, mocSubDir, basename, headerExtensions);
if (!headerToMoc.empty()) { if (!headerToMoc.empty()) {
// this is for KDE4 compatibility: // this is for KDE4 compatibility:
fileToMoc = headerToMoc; fileToMoc = headerToMoc;
if ((requiresMoc == false) && (basename == scannedFileBasename)) { if (!requiresMoc && basename == scannedFileBasename) {
std::stringstream err; std::stringstream err;
err << "AUTOGEN: warning: " << absFilename err << "AUTOGEN: warning: " << absFilename
<< ": The file " << ": The file "
@ -696,8 +696,8 @@ void cmQtAutoGenerators::ParseCppFile(
// If this is the case, the moc_foo.cpp should probably be generated from // If this is the case, the moc_foo.cpp should probably be generated from
// foo.cpp instead of foo.h, because otherwise it won't build. // foo.cpp instead of foo.h, because otherwise it won't build.
// But warn, since this is not how it is supposed to be used. // But warn, since this is not how it is supposed to be used.
if ((dotMocIncluded == false) && (requiresMoc == true)) { if (!dotMocIncluded && requiresMoc) {
if (mocUnderscoreIncluded == true) { if (mocUnderscoreIncluded) {
// this is for KDE4 compatibility: // this is for KDE4 compatibility:
std::stringstream err; std::stringstream err;
err << "AUTOGEN: warning: " << absFilename << ": The file " err << "AUTOGEN: warning: " << absFilename << ": The file "
@ -833,8 +833,7 @@ void cmQtAutoGenerators::StrictParseCppFile(
// foo.cpp instead of foo.h, because otherwise it won't build. // foo.cpp instead of foo.h, because otherwise it won't build.
// But warn, since this is not how it is supposed to be used. // But warn, since this is not how it is supposed to be used.
std::string macroName; std::string macroName;
if ((dotMocIncluded == false) && if (!dotMocIncluded && requiresMocing(contentsString, macroName)) {
(requiresMocing(contentsString, macroName))) {
// otherwise always error out since it will not compile: // otherwise always error out since it will not compile:
std::stringstream err; std::stringstream err;
err << "AUTOGEN: error: " << absFilename << ": The file " err << "AUTOGEN: error: " << absFilename << ": The file "

View File

@ -177,10 +177,7 @@ bool cmSourceFileLocation::MatchesAmbiguousExtension(
} }
std::vector<std::string> hdrExts = std::vector<std::string> hdrExts =
mf->GetCMakeInstance()->GetHeaderExtensions(); mf->GetCMakeInstance()->GetHeaderExtensions();
if (std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) { return std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end();
return true;
}
return false;
} }
bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc) bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)

View File

@ -86,11 +86,7 @@ bool cmSourceGroup::MatchesRegex(const char* name)
bool cmSourceGroup::MatchesFiles(const char* name) bool cmSourceGroup::MatchesFiles(const char* name)
{ {
std::set<std::string>::const_iterator i = this->GroupFiles.find(name); return this->GroupFiles.find(name) != this->GroupFiles.end();
if (i != this->GroupFiles.end()) {
return true;
}
return false;
} }
void cmSourceGroup::AssignSource(const cmSourceFile* sf) void cmSourceGroup::AssignSource(const cmSourceFile* sf)

View File

@ -2108,11 +2108,8 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
// If the symlink points at an extended version of the same name // If the symlink points at an extended version of the same name
// assume it is the soname. // assume it is the soname.
std::string name = cmSystemTools::GetFilenameName(fullPath); std::string name = cmSystemTools::GetFilenameName(fullPath);
if (soname.length() > name.length() && return soname.length() > name.length() &&
soname.substr(0, name.length()) == name) { soname.compare(0, name.length(), name) == 0;
return true;
}
return false;
} }
bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath, bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,

View File

@ -1027,11 +1027,7 @@ int cmcmd::ExecuteEchoColor(std::vector<std::string>& args)
// Enable or disable color based on the switch value. // Enable or disable color based on the switch value.
std::string value = args[i].substr(9); std::string value = args[i].substr(9);
if (!value.empty()) { if (!value.empty()) {
if (cmSystemTools::IsOn(value.c_str())) { enabled = cmSystemTools::IsOn(value.c_str());
enabled = true;
} else {
enabled = false;
}
} }
} else if (cmHasLiteralPrefix(args[i], "--progress-dir=")) { } else if (cmHasLiteralPrefix(args[i], "--progress-dir=")) {
progressDir = args[i].substr(15); progressDir = args[i].substr(15);
@ -1226,7 +1222,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
if (args.size() < 2) { if (args.size() < 2) {
return -1; return -1;
} }
bool verbose = cmSystemTools::GetEnv("VERBOSE") ? true : false; bool verbose = cmSystemTools::GetEnv("VERBOSE") != NULL;
std::vector<std::string> expandedArgs; std::vector<std::string> expandedArgs;
for (std::vector<std::string>::iterator i = args.begin(); i != args.end(); for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
++i) { ++i) {