summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-10-21 21:32:43 +0200
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2016-10-21 21:32:43 +0200
commit569509f4bfbf44c67e237a01f957fdfe52223cfa (patch)
treefae8b2848d52b1f3ba8ed8f50f5e4135f170ee95
parent6c9b3b5c03b41842d3d79c1bd80691be7e5c6f89 (diff)
downloadcmake-569509f4bfbf44c67e237a01f957fdfe52223cfa.tar.gz
Fix newly discovered clang-tidy issues
Clang-tidy reports some issues only from the currently compiled source file and its associated header file. Separating the compilation of commands exposed some clang-tidy issues that were not reported previously. Fix them.
-rw-r--r--Source/cmAddLibraryCommand.cxx4
-rw-r--r--Source/cmConditionEvaluator.cxx12
-rw-r--r--Source/cmFileCommand.cxx8
-rw-r--r--Source/cmFindBase.cxx2
-rw-r--r--Source/cmFindPackageCommand.cxx16
-rw-r--r--Source/cmHexFileConverter.cxx2
-rw-r--r--Source/cmLoadCommandCommand.cxx2
7 files changed, 20 insertions, 26 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index 18118a3b72..56cf91ae4b 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -270,8 +270,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
yet its linker language. */
if ((type == cmStateEnums::SHARED_LIBRARY ||
type == cmStateEnums::MODULE_LIBRARY) &&
- (this->Makefile->GetState()->GetGlobalPropertyAsBool(
- "TARGET_SUPPORTS_SHARED_LIBS") == false)) {
+ !this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ "TARGET_SUPPORTS_SHARED_LIBS")) {
std::ostringstream w;
w << "ADD_LIBRARY called with "
<< (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE")
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 4c0b6491a0..7d98e737b7 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -222,7 +222,7 @@ bool cmConditionEvaluator::GetBooleanValue(
double d = strtod(arg.c_str(), &end);
if (*end == '\0') {
// The whole string is a number. Use C conversion to bool.
- return d ? true : false;
+ return static_cast<bool>(d);
}
}
@@ -444,7 +444,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end()) {
cmCommand* command =
this->Makefile.GetState()->GetCommand(argP1->c_str());
- this->HandlePredicate(command ? true : false, reducible, arg, newArgs,
+ this->HandlePredicate(command != CM_NULLPTR, reducible, arg, newArgs,
argP1, argP2);
}
// does a policy exist
@@ -456,7 +456,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
// does a target exist
if (this->IsKeyword(keyTARGET, *arg) && argP1 != newArgs.end()) {
this->HandlePredicate(
- this->Makefile.FindTargetToUse(argP1->GetValue()) ? true : false,
+ this->Makefile.FindTargetToUse(argP1->GetValue()) != CM_NULLPTR,
reducible, arg, newArgs, argP1, argP2);
}
// does a test exist
@@ -464,7 +464,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
this->Policy64Status != cmPolicies::WARN) {
if (this->IsKeyword(keyTEST, *arg) && argP1 != newArgs.end()) {
const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str());
- this->HandlePredicate(haveTest ? true : false, reducible, arg,
+ this->HandlePredicate(haveTest != CM_NULLPTR, reducible, arg,
newArgs, argP1, argP2);
}
} else if (this->Policy64Status == cmPolicies::WARN &&
@@ -638,8 +638,8 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
bool success = cmSystemTools::FileTimeCompare(
arg->GetValue(), (argP2)->GetValue(), &fileIsNewer);
this->HandleBinaryOp(
- (success == false || fileIsNewer == 1 || fileIsNewer == 0),
- reducible, arg, newArgs, argP1, argP2);
+ (!success || fileIsNewer == 1 || fileIsNewer == 0), reducible, arg,
+ newArgs, argP1, argP2);
}
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 8dd204b653..6b5870b08a 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2449,18 +2449,14 @@ public:
{
}
- ~cURLEasyGuard(void)
+ ~cURLEasyGuard()
{
if (this->Easy) {
::curl_easy_cleanup(this->Easy);
}
}
- inline void release(void)
- {
- this->Easy = CM_NULLPTR;
- return;
- }
+ void release() { this->Easy = CM_NULLPTR; }
private:
::CURL* Easy;
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 9e08f30e52..118c58121b 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -302,7 +302,7 @@ bool cmFindBase::CheckForVariableInCache()
cmState* state = this->Makefile->GetState();
const char* cacheEntry = state->GetCacheEntryValue(this->VariableName);
bool found = !cmSystemTools::IsNOTFOUND(cacheValue);
- bool cached = cacheEntry ? true : false;
+ bool cached = cacheEntry != CM_NULLPTR;
if (found) {
// If the user specifies the entry on the command line without a
// type we should add the type and docstring but keep the
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 2784e16f0a..373b728be4 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -673,8 +673,8 @@ bool cmFindPackageCommand::HandlePackageMode()
bool configFileSetFOUNDFalse = false;
if (fileFound) {
- if ((this->Makefile->IsDefinitionSet(foundVar)) &&
- (this->Makefile->IsOn(foundVar) == false)) {
+ if (this->Makefile->IsDefinitionSet(foundVar) &&
+ !this->Makefile->IsOn(foundVar)) {
// by removing Foo_FOUND here if it is FALSE, we don't really change
// the situation for the Config file which is about to be included,
// but we make it possible to detect later on whether the Config file
@@ -693,8 +693,8 @@ bool cmFindPackageCommand::HandlePackageMode()
found = true;
// Check whether the Config file has set Foo_FOUND to FALSE:
- if ((this->Makefile->IsDefinitionSet(foundVar)) &&
- (this->Makefile->IsOn(foundVar) == false)) {
+ if (this->Makefile->IsDefinitionSet(foundVar) &&
+ !this->Makefile->IsOn(foundVar)) {
// we get here if the Config file has set Foo_FOUND actively to FALSE
found = false;
configFileSetFOUNDFalse = true;
@@ -1416,8 +1416,7 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
// Look for foo-config-version.cmake
std::string version_file = version_file_base;
version_file += "-version.cmake";
- if ((haveResult == false) &&
- (cmSystemTools::FileExists(version_file.c_str(), true))) {
+ if (!haveResult && cmSystemTools::FileExists(version_file.c_str(), true)) {
result = this->CheckVersionFile(version_file, version);
haveResult = true;
}
@@ -1425,14 +1424,13 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
// Look for fooConfigVersion.cmake
version_file = version_file_base;
version_file += "Version.cmake";
- if ((haveResult == false) &&
- (cmSystemTools::FileExists(version_file.c_str(), true))) {
+ if (!haveResult && cmSystemTools::FileExists(version_file.c_str(), true)) {
result = this->CheckVersionFile(version_file, version);
haveResult = true;
}
// If no version was requested a versionless package is acceptable.
- if ((haveResult == false) && (this->Version.empty())) {
+ if (!haveResult && this->Version.empty()) {
result = true;
}
diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx
index 6f3ea6a04b..db855d2c9b 100644
--- a/Source/cmHexFileConverter.cxx
+++ b/Source/cmHexFileConverter.cxx
@@ -206,7 +206,7 @@ bool cmHexFileConverter::TryConvert(const char* inFileName,
} else if (type == IntelHex) {
success = ConvertIntelHexLine(buf, outFile);
}
- if (success == false) {
+ if (!success) {
break;
}
}
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 12b3aa8131..82d2ee3266 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -64,7 +64,7 @@ public:
void FinalPass() CM_OVERRIDE;
bool HasFinalPass() const CM_OVERRIDE
{
- return this->info.FinalPass ? true : false;
+ return this->info.FinalPass != CM_NULLPTR;
}
/**