summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-08-18 18:36:29 (GMT)
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2016-08-18 18:36:29 (GMT)
commit7b6349da4dc968691f1a374211fcc153c8b4f1c6 (patch)
treebb0fc76955ef3166c3416522fef009c9d65ab7f3
parent50ad1e0a144ae1f2267a4966789e5a16372f458e (diff)
downloadCMake-7b6349da4dc968691f1a374211fcc153c8b4f1c6.zip
CMake-7b6349da4dc968691f1a374211fcc153c8b4f1c6.tar.gz
CMake-7b6349da4dc968691f1a374211fcc153c8b4f1c6.tar.bz2
CMake: don't use else after return
-rw-r--r--Source/cmArchiveWrite.cxx3
-rw-r--r--Source/cmCTest.cxx11
-rw-r--r--Source/cmCacheManager.cxx3
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx14
-rw-r--r--Source/cmCryptoHash.cxx24
-rw-r--r--Source/cmDependsFortran.cxx3
-rw-r--r--Source/cmDocumentation.cxx3
-rw-r--r--Source/cmELF.cxx27
-rw-r--r--Source/cmExportBuildFileGenerator.cxx7
-rw-r--r--Source/cmExprParserHelper.cxx5
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx43
-rw-r--r--Source/cmFileLockPool.cxx5
-rw-r--r--Source/cmFileTimeComparison.cxx27
-rw-r--r--Source/cmFortranParserImpl.cxx50
-rw-r--r--Source/cmGeneratorExpression.cxx3
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx23
-rw-r--r--Source/cmGeneratorExpressionNode.cxx6
-rw-r--r--Source/cmGeneratorTarget.cxx83
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx9
-rw-r--r--Source/cmInstallExportGenerator.cxx3
-rw-r--r--Source/cmListFileCache.cxx10
-rw-r--r--Source/cmLocalGenerator.cxx29
-rw-r--r--Source/cmMakefile.cxx167
-rw-r--r--Source/cmNewLineStyle.cxx15
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx3
-rw-r--r--Source/cmSourceFile.cxx3
-rw-r--r--Source/cmState.cxx18
-rw-r--r--Source/cmSystemTools.cxx26
-rw-r--r--Source/cmTarget.cxx41
-rw-r--r--Source/cmUuid.cxx9
-rw-r--r--Source/cmake.cxx20
-rw-r--r--Source/cmakemain.cxx9
-rw-r--r--Source/cmcmd.cxx19
33 files changed, 352 insertions, 369 deletions
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 3da4f28..df07ccc 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -71,9 +71,8 @@ struct cmArchiveWrite::Callback
if (self->Stream.write(static_cast<const char*>(b),
static_cast<std::streamsize>(n))) {
return static_cast<__LA_SSIZE_T>(n);
- } else {
- return static_cast<__LA_SSIZE_T>(-1);
}
+ return static_cast<__LA_SSIZE_T>(-1);
}
};
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 8a856a8..b4ddc3e 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -781,13 +781,12 @@ bool cmCTest::SetTest(const char* ttype, bool report)
if (p != PartCount) {
this->Parts[p].Enable();
return true;
- } else {
- if (report) {
- cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \""
- << ttype << "\" yet..." << std::endl);
- }
- return false;
}
+ if (report) {
+ cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \""
+ << ttype << "\" yet..." << std::endl);
+ }
+ return false;
}
void cmCTest::Finalize()
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index bdd7303..2571698 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -574,7 +574,8 @@ const char* cmCacheManager::CacheEntry::GetProperty(
{
if (prop == "TYPE") {
return cmState::CacheEntryTypeToString(this->Type);
- } else if (prop == "VALUE") {
+ }
+ if (prop == "VALUE") {
return this->Value.c_str();
}
return this->Properties.GetPropertyValue(prop);
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 42fb105..68111a0 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -75,9 +75,8 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
if (cmSystemTools::GetEnv(var, str)) {
if (this->EscapeQuotes) {
return this->AddString(cmSystemTools::EscapeQuotes(str.c_str()));
- } else {
- return this->AddString(str);
}
+ return this->AddString(str);
}
return this->EmptyVariable;
}
@@ -86,9 +85,8 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
this->Makefile->GetState()->GetInitializedCacheValue(var)) {
if (this->EscapeQuotes) {
return this->AddString(cmSystemTools::EscapeQuotes(c));
- } else {
- return this->AddString(c);
}
+ return this->AddString(c);
}
return this->EmptyVariable;
}
@@ -162,7 +160,8 @@ char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
{
if (!in1) {
return in2;
- } else if (!in2) {
+ }
+ if (!in2) {
return in1;
}
size_t len = strlen(in1) + strlen(in2) + 1;
@@ -282,10 +281,9 @@ int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen)
this->CurrentLine++;
}
return (1);
- } else {
- buf[0] = '\n';
- return (0);
}
+ buf[0] = '\n';
+ return (0);
}
void cmCommandArgumentParserHelper::Error(const char* str)
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 9bd07a3..8e2d87e 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -19,19 +19,23 @@ CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo)
{
if (strcmp(algo, "MD5") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashMD5);
- } else if (strcmp(algo, "SHA1") == 0) {
+ }
+ if (strcmp(algo, "SHA1") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA1);
- } else if (strcmp(algo, "SHA224") == 0) {
+ }
+ if (strcmp(algo, "SHA224") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA224);
- } else if (strcmp(algo, "SHA256") == 0) {
+ }
+ if (strcmp(algo, "SHA256") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA256);
- } else if (strcmp(algo, "SHA384") == 0) {
+ }
+ if (strcmp(algo, "SHA384") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA384);
- } else if (strcmp(algo, "SHA512") == 0) {
+ }
+ if (strcmp(algo, "SHA512") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA512);
- } else {
- return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR);
}
+ return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR);
}
bool cmCryptoHash::IntFromHexDigit(char input, char& output)
@@ -39,10 +43,12 @@ bool cmCryptoHash::IntFromHexDigit(char input, char& output)
if (input >= '0' && input <= '9') {
output = char(input - '0');
return true;
- } else if (input >= 'a' && input <= 'f') {
+ }
+ if (input >= 'a' && input <= 'f') {
output = char(input - 'a' + 0xA);
return true;
- } else if (input >= 'A' && input <= 'F') {
+ }
+ if (input >= 'A' && input <= 'F') {
output = char(input - 'A' + 0xA);
return true;
}
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index d1521f0..5c863f0 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -521,7 +521,8 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
}
}
return true;
- } else if (cmSystemTools::FileExists(mod_lower.c_str(), true)) {
+ }
+ if (cmSystemTools::FileExists(mod_lower.c_str(), true)) {
if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
compilerId.c_str())) {
if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 919a45e..5516cf1 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -719,9 +719,8 @@ const char* cmDocumentation::GetNameString() const
{
if (!this->NameString.empty()) {
return this->NameString.c_str();
- } else {
- return "CMake";
}
+ return "CMake";
}
bool cmDocumentation::IsOption(const char* arg) const
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index c687e2f..150593b 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -832,45 +832,40 @@ cmELF::FileType cmELF::GetFileType() const
{
if (this->Valid()) {
return this->Internal->GetFileType();
- } else {
- return FileTypeInvalid;
}
+ return FileTypeInvalid;
}
unsigned int cmELF::GetNumberOfSections() const
{
if (this->Valid()) {
return this->Internal->GetNumberOfSections();
- } else {
- return 0;
}
+ return 0;
}
unsigned int cmELF::GetDynamicEntryCount() const
{
if (this->Valid()) {
return this->Internal->GetDynamicEntryCount();
- } else {
- return 0;
}
+ return 0;
}
unsigned long cmELF::GetDynamicEntryPosition(int index) const
{
if (this->Valid()) {
return this->Internal->GetDynamicEntryPosition(index);
- } else {
- return 0;
}
+ return 0;
}
bool cmELF::ReadBytes(unsigned long pos, unsigned long size, char* buf) const
{
if (this->Valid()) {
return this->Internal->ReadBytes(pos, size, buf);
- } else {
- return false;
}
+ return false;
}
bool cmELF::GetSOName(std::string& soname)
@@ -878,9 +873,8 @@ bool cmELF::GetSOName(std::string& soname)
if (StringEntry const* se = this->GetSOName()) {
soname = se->Value;
return true;
- } else {
- return false;
}
+ return false;
}
cmELF::StringEntry const* cmELF::GetSOName()
@@ -888,9 +882,8 @@ cmELF::StringEntry const* cmELF::GetSOName()
if (this->Valid() &&
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) {
return this->Internal->GetSOName();
- } else {
- return CM_NULLPTR;
}
+ return CM_NULLPTR;
}
cmELF::StringEntry const* cmELF::GetRPath()
@@ -899,9 +892,8 @@ cmELF::StringEntry const* cmELF::GetRPath()
(this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRPath();
- } else {
- return CM_NULLPTR;
}
+ return CM_NULLPTR;
}
cmELF::StringEntry const* cmELF::GetRunPath()
@@ -910,9 +902,8 @@ cmELF::StringEntry const* cmELF::GetRunPath()
(this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRunPath();
- } else {
- return CM_NULLPTR;
}
+ return CM_NULLPTR;
}
void cmELF::PrintInfo(std::ostream& os) const
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index a53d285..390477a 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -211,11 +211,10 @@ void cmExportBuildFileGenerator::HandleMissingTarget(
link_libs += missingTarget;
missingTargets.push_back(missingTarget);
return;
- } else {
- // We are not appending, so all exported targets should be
- // known here. This is probably user-error.
- this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
}
+ // We are not appending, so all exported targets should be
+ // known here. This is probably user-error.
+ this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
}
// Assume the target will be exported by another command.
// Append it with the export namespace.
diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx
index 0771a4e..1a101ab 100644
--- a/Source/cmExprParserHelper.cxx
+++ b/Source/cmExprParserHelper.cxx
@@ -81,10 +81,9 @@ int cmExprParserHelper::LexInput(char* buf, int maxlen)
this->CurrentLine++;
}
return (1);
- } else {
- buf[0] = '\n';
- return (0);
}
+ buf[0] = '\n';
+ return (0);
}
void cmExprParserHelper::Error(const char* str)
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 0ded17a..559974e 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -124,11 +124,10 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
if (start + 1 < splitted.size()) {
it->InsertPath(splitted, start + 1, fileName);
return;
- } else {
- // last part of splitted
- it->files.push_back(fileName);
- return;
}
+ // last part of splitted
+ it->files.push_back(fileName);
+ return;
}
}
// Not found in folders, thus insert
@@ -138,12 +137,11 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
newFolder.InsertPath(splitted, start + 1, fileName);
folders.push_back(newFolder);
return;
- } else {
- // last part of splitted
- newFolder.files.push_back(fileName);
- folders.push_back(newFolder);
- return;
}
+ // last part of splitted
+ newFolder.files.push_back(fileName);
+ folders.push_back(newFolder);
+ return;
}
void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
@@ -717,21 +715,22 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
// Translate the cmake target type into the CodeBlocks target type id
int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target)
{
- if (target->GetType() == cmState::EXECUTABLE) {
- if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) ||
- (target->GetPropertyAsBool("MACOSX_BUNDLE"))) {
- return 0;
- } else {
+ switch (target->GetType()) {
+ case cmState::EXECUTABLE:
+ if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) ||
+ (target->GetPropertyAsBool("MACOSX_BUNDLE"))) {
+ return 0;
+ }
return 1;
- }
- } else if ((target->GetType() == cmState::STATIC_LIBRARY) ||
- (target->GetType() == cmState::OBJECT_LIBRARY)) {
- return 2;
- } else if ((target->GetType() == cmState::SHARED_LIBRARY) ||
- (target->GetType() == cmState::MODULE_LIBRARY)) {
- return 3;
+ case cmState::STATIC_LIBRARY:
+ case cmState::OBJECT_LIBRARY:
+ return 2;
+ case cmState::SHARED_LIBRARY:
+ case cmState::MODULE_LIBRARY:
+ return 3;
+ default:
+ return 4;
}
- return 4;
}
// Create the command line for building the given target using the selected
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index 7c51459..5521ac4 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -140,10 +140,9 @@ cmFileLockResult cmFileLockPool::ScopePool::Lock(const std::string& filename,
if (result.IsOk()) {
this->Locks.push_back(lock);
return cmFileLockResult::MakeOk();
- } else {
- delete lock;
- return result;
}
+ delete lock;
+ return result;
}
cmFileLockResult cmFileLockPool::ScopePool::Release(
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 9d63505..1360b44 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -140,11 +140,14 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1,
// Compare using nanosecond resolution.
if (s1->st_mtim.tv_sec < s2->st_mtim.tv_sec) {
return -1;
- } else if (s1->st_mtim.tv_sec > s2->st_mtim.tv_sec) {
+ }
+ if (s1->st_mtim.tv_sec > s2->st_mtim.tv_sec) {
return 1;
- } else if (s1->st_mtim.tv_nsec < s2->st_mtim.tv_nsec) {
+ }
+ if (s1->st_mtim.tv_nsec < s2->st_mtim.tv_nsec) {
return -1;
- } else if (s1->st_mtim.tv_nsec > s2->st_mtim.tv_nsec) {
+ }
+ if (s1->st_mtim.tv_nsec > s2->st_mtim.tv_nsec) {
return 1;
}
#elif CMake_STAT_HAS_ST_MTIMESPEC
@@ -185,11 +188,11 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
long long t2 = s2->st_mtim.tv_sec * bil + s2->st_mtim.tv_nsec;
if (t1 < t2) {
return (t2 - t1) >= bil;
- } else if (t2 < t1) {
+ }
+ if (t2 < t1) {
return (t1 - t2) >= bil;
- } else {
- return false;
}
+ return false;
#elif CMake_STAT_HAS_ST_MTIMESPEC
// Times are integers in units of 1ns.
long long bil = 1000000000;
@@ -240,11 +243,10 @@ bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
// Compare the two modification times.
*result = this->Compare(&s1, &s2);
return true;
- } else {
- // No comparison available. Default to the same time.
- *result = 0;
- return false;
}
+ // No comparison available. Default to the same time.
+ *result = 0;
+ return false;
}
bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
@@ -256,8 +258,7 @@ bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
if (this->Stat(f1, &s1) && this->Stat(f2, &s2)) {
// Compare the two modification times.
return this->TimesDiffer(&s1, &s2);
- } else {
- // No comparison available. Default to different times.
- return true;
}
+ // No comparison available. Default to different times.
+ return true;
}
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index 7d04898..30a33b4 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -22,29 +22,27 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
if (cmSystemTools::FileIsFullPath(includeName)) {
fileName = includeName;
return cmSystemTools::FileExists(fileName.c_str(), true);
- } else {
- // Check for the file in the directory containing the including
- // file.
- std::string fullName = dir;
+ }
+ // Check for the file in the directory containing the including
+ // file.
+ std::string fullName = dir;
+ fullName += "/";
+ fullName += includeName;
+ if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+ fileName = fullName;
+ return true;
+ }
+
+ // Search the include path for the file.
+ for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
+ i != this->IncludePath.end(); ++i) {
+ fullName = *i;
fullName += "/";
fullName += includeName;
if (cmSystemTools::FileExists(fullName.c_str(), true)) {
fileName = fullName;
return true;
}
-
- // Search the include path for the file.
- for (std::vector<std::string>::const_iterator i =
- this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
- fullName = *i;
- fullName += "/";
- fullName += includeName;
- if (cmSystemTools::FileExists(fullName.c_str(), true)) {
- fileName = fullName;
- return true;
- }
- }
}
return false;
}
@@ -88,9 +86,8 @@ bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname)
cmFortran_yy_switch_to_buffer(buffer, parser->Scanner);
parser->FileStack.push(f);
return 1;
- } else {
- return 0;
}
+ return 0;
}
bool cmFortranParser_FilePop(cmFortranParser* parser)
@@ -99,15 +96,14 @@ bool cmFortranParser_FilePop(cmFortranParser* parser)
// to the next one on the stack.
if (parser->FileStack.empty()) {
return 0;
- } else {
- cmFortranFile f = parser->FileStack.top();
- parser->FileStack.pop();
- fclose(f.File);
- YY_BUFFER_STATE current = cmFortranLexer_GetCurrentBuffer(parser->Scanner);
- cmFortran_yy_delete_buffer(current, parser->Scanner);
- cmFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner);
- return 1;
}
+ cmFortranFile f = parser->FileStack.top();
+ parser->FileStack.pop();
+ fclose(f.File);
+ YY_BUFFER_STATE current = cmFortranLexer_GetCurrentBuffer(parser->Scanner);
+ cmFortran_yy_delete_buffer(current, parser->Scanner);
+ cmFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner);
+ return 1;
}
int cmFortranParser_Input(cmFortranParser* parser, char* buffer,
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 983bfb4..6cd6439 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -352,7 +352,8 @@ std::string cmGeneratorExpression::Preprocess(const std::string& input,
{
if (context == StripAllGeneratorExpressions) {
return stripAllGeneratorExpressions(input);
- } else if (context == BuildInterface || context == InstallInterface) {
+ }
+ if (context == BuildInterface || context == InstallInterface) {
return stripExportInterface(input, context, resolveRelative);
}
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 66437eb..b4b74c5 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -154,20 +154,19 @@ std::string GeneratorExpressionContent::EvaluateParameters(
node, identifier, context, dagChecker, pit);
parameters.push_back(lastParam);
return std::string();
- } else {
- std::string parameter;
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator
- end = pit->end();
- for (; it != end; ++it) {
- parameter += (*it)->Evaluate(context, dagChecker);
- if (context->HadError) {
- return std::string();
- }
+ }
+ std::string parameter;
+ std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
+ pit->begin();
+ const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
+ pit->end();
+ for (; it != end; ++it) {
+ parameter += (*it)->Evaluate(context, dagChecker);
+ if (context->HadError) {
+ return std::string();
}
- parameters.push_back(parameter);
}
+ parameters.push_back(parameter);
}
}
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 86fbd44..12cf980 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -92,7 +92,8 @@ static const struct ZeroNode installInterfaceNode;
for (; it != end; ++it) { \
if (*it == #FAILURE_VALUE) { \
return #FAILURE_VALUE; \
- } else if (*it != #SUCCESS_VALUE) { \
+ } \
+ if (*it != #SUCCESS_VALUE) { \
reportError(context, content->GetOriginalExpression(), \
"Parameters to $<" #OP \
"> must resolve to either '0' or '1'."); \
@@ -790,7 +791,8 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
"$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
"generators.");
return std::string();
- } else if (genName.find("Xcode") != std::string::npos) {
+ }
+ if (genName.find("Xcode") != std::string::npos) {
if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
dagChecker->EvaluatingIncludeDirectories())) {
reportError(
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 308051b..8bd3b82 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -361,10 +361,9 @@ const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
if (implib) {
// A DLL import library is treated as an archive target.
return "ARCHIVE";
- } else {
- // A DLL shared library is treated as a runtime target.
- return "RUNTIME";
}
+ // A DLL shared library is treated as a runtime target.
+ return "RUNTIME";
} else {
// For non-DLL platforms shared libraries are treated as
// library targets.
@@ -1324,26 +1323,23 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const
// The imported library has no builtin soname so the name
// searched at runtime will be just the filename.
return cmSystemTools::GetFilenameName(info->Location);
- } else {
- // Use the soname given if any.
- if (info->SOName.find("@rpath/") == 0) {
- return info->SOName.substr(6);
- }
- return info->SOName;
}
- } else {
- return "";
+ // Use the soname given if any.
+ if (info->SOName.find("@rpath/") == 0) {
+ return info->SOName.substr(6);
+ }
+ return info->SOName;
}
- } else {
- // Compute the soname that will be built.
- std::string name;
- std::string soName;
- std::string realName;
- std::string impName;
- std::string pdbName;
- this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
- return soName;
+ return "";
}
+ // Compute the soname that will be built.
+ std::string name;
+ std::string soName;
+ std::string realName;
+ std::string impName;
+ std::string pdbName;
+ this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
+ return soName;
}
std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
@@ -1418,9 +1414,8 @@ std::string cmGeneratorTarget::GetFullName(const std::string& config,
{
if (this->IsImported()) {
return this->GetFullNameImported(config, implib);
- } else {
- return this->GetFullNameInternal(config, implib);
}
+ return this->GetFullNameInternal(config, implib);
}
std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
@@ -1444,9 +1439,8 @@ std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
}
dir += "/";
return dir;
- } else {
- return "";
}
+ return "";
}
std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
@@ -1468,9 +1462,8 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
}
}
return dir;
- } else {
- return "";
}
+ return "";
}
cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
@@ -1516,9 +1509,8 @@ const char* cmGeneratorTarget::GetExportMacro() const
this->ExportMacro = cmSystemTools::MakeCidentifier(in);
}
return this->ExportMacro.c_str();
- } else {
- return CM_NULLPTR;
}
+ return CM_NULLPTR;
}
class cmTargetCollectLinkLanguages
@@ -1642,7 +1634,8 @@ public:
{
if (this->Preferred.empty()) {
return "";
- } else if (this->Preferred.size() > 1) {
+ }
+ if (this->Preferred.size() > 1) {
std::ostringstream e;
e << "Target " << this->Target->GetName()
<< " contains multiple languages with the highest linker preference"
@@ -2723,9 +2716,8 @@ std::string cmGeneratorTarget::GetFullPath(const std::string& config,
{
if (this->IsImported()) {
return this->Target->ImportedGetFullPath(config, implib);
- } else {
- return this->NormalGetFullPath(config, implib, realname);
}
+ return this->NormalGetFullPath(config, implib, realname);
}
std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
@@ -2770,16 +2762,15 @@ std::string cmGeneratorTarget::NormalGetRealName(
std::string pdbName;
this->GetExecutableNames(name, realName, impName, pdbName, config);
return realName;
- } else {
- // Compute the real name that will be built.
- std::string name;
- std::string soName;
- std::string realName;
- std::string impName;
- std::string pdbName;
- this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
- return realName;
}
+ // Compute the real name that will be built.
+ std::string name;
+ std::string soName;
+ std::string realName;
+ std::string impName;
+ std::string pdbName;
+ this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
+ return realName;
}
void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
@@ -3587,9 +3578,8 @@ std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
if (t == NumberMaxType) {
return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs);
- } else {
- return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs);
}
+ return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs);
}
template <>
@@ -3906,11 +3896,11 @@ std::string cmGeneratorTarget::GetFrameworkVersion() const
if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) {
return fversion;
- } else if (const char* tversion = this->GetProperty("VERSION")) {
+ }
+ if (const char* tversion = this->GetProperty("VERSION")) {
return tversion;
- } else {
- return "A";
}
+ return "A";
}
void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
@@ -4169,7 +4159,8 @@ std::string cmGeneratorTarget::GetDirectory(const std::string& config,
// Return the directory from which the target is imported.
return cmSystemTools::GetFilenamePath(
this->Target->ImportedGetFullPath(config, implib));
- } else if (OutputInfo const* info = this->GetOutputInfo(config)) {
+ }
+ if (OutputInfo const* info = this->GetOutputInfo(config)) {
// Return the directory in which the target will be built.
return implib ? info->ImpDir : info->OutDir;
}
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 3b8aaa6..2b83479 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -93,12 +93,11 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string& ident,
names << "ident" << VarNum++;
vars << names.str() << " = " << ident << "\n";
return "$" + names.str();
- } else {
- std::string result = ident;
- cmSystemTools::ReplaceString(result, " ", "$ ");
- cmSystemTools::ReplaceString(result, ":", "$:");
- return result;
}
+ std::string result = ident;
+ cmSystemTools::ReplaceString(result, " ", "$ ");
+ cmSystemTools::ReplaceString(result, ":", "$:");
+ return result;
}
std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit)
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 0fcd8ba..72c4d1f 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -63,9 +63,8 @@ void cmInstallExportGenerator::ComputeTempDir()
this->TempDir += "/Export";
if (this->Destination.empty()) {
return;
- } else {
- this->TempDir += "/";
}
+ this->TempDir += "/";
// Enforce a maximum length.
bool useMD5 = false;
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 28b3781..1967d2a 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -259,10 +259,9 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
if (isError) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
return false;
- } else {
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
- return true;
}
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+ return true;
}
struct cmListFileBacktrace::Entry : public cmListFileContext
@@ -377,10 +376,9 @@ cmListFileContext const& cmListFileBacktrace::Top() const
{
if (this->Cur) {
return *this->Cur;
- } else {
- static cmListFileContext const empty;
- return empty;
}
+ static cmListFileContext const empty;
+ return empty;
}
void cmListFileBacktrace::PrintTitle(std::ostream& out) const
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index accce49..d8f6bdf 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -626,16 +626,14 @@ std::string cmLocalGenerator::ExpandRuleVariable(
if (variable == "TARGET_VERSION_MAJOR") {
if (replaceValues.TargetVersionMajor) {
return replaceValues.TargetVersionMajor;
- } else {
- return "0";
}
+ return "0";
}
if (variable == "TARGET_VERSION_MINOR") {
if (replaceValues.TargetVersionMinor) {
return replaceValues.TargetVersionMinor;
- } else {
- return "0";
}
+ return "0";
}
if (replaceValues.Target) {
if (variable == "TARGET_BASE") {
@@ -644,9 +642,8 @@ std::string cmLocalGenerator::ExpandRuleVariable(
std::string::size_type pos = targetBase.rfind('.');
if (pos != targetBase.npos) {
return targetBase.substr(0, pos);
- } else {
- return targetBase;
}
+ return targetBase;
}
}
}
@@ -813,9 +810,8 @@ const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
{
if (target) {
return target->GetProperty(prop);
- } else {
- return this->Makefile->GetProperty(prop);
}
+ return this->Makefile->GetProperty(prop);
}
void cmLocalGenerator::InsertRuleLauncher(std::string& s,
@@ -2365,10 +2361,9 @@ static bool cmLocalGeneratorShortenObjectName(std::string& objName,
// The object name is now short enough.
return true;
- } else {
- // The object name could not be shortened enough.
- return false;
}
+ // The object name could not be shortened enough.
+ return false;
}
bool cmLocalGeneratorCheckObjectName(std::string& objName,
@@ -2382,15 +2377,13 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName,
if (objName.size() > max_obj_len) {
// The current object file name is too long. Try to shorten it.
return cmLocalGeneratorShortenObjectName(objName, max_obj_len);
- } else {
- // The object file name is short enough.
- return true;
}
- } else {
- // The build directory in which the object will be stored is
- // already too deep.
- return false;
+ // The object file name is short enough.
+ return true;
}
+ // The build directory in which the object will be stored is
+ // already too deep.
+ return false;
}
#endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ab7de57..28a3ab5 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -813,11 +813,10 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
// The existing custom command is identical. Silently ignore
// the duplicate.
return file;
- } else {
- // The existing custom command is different. We need to
- // generate a rule file for this new command.
- file = CM_NULLPTR;
}
+ // The existing custom command is different. We need to
+ // generate a rule file for this new command.
+ file = CM_NULLPTR;
} else if (!file) {
file = this->CreateSource(main_dependency);
}
@@ -2029,7 +2028,8 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
sg->SetGroupRegex(regex);
}
return;
- } else if (i == -1) {
+ }
+ if (i == -1) {
// group does not exist nor belong to any existing group
// add its first component
this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex));
@@ -2817,13 +2817,12 @@ std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
cmSystemTools::ExpandListArgument(configTypes, configs);
}
return "";
- } else {
- const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
- if (singleConfig && !buildType.empty()) {
- configs.push_back(buildType);
- }
- return buildType;
}
+ const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ if (singleConfig && !buildType.empty()) {
+ configs.push_back(buildType);
+ }
+ return buildType;
}
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -3129,9 +3128,8 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
{
if (cmSourceFile* esf = this->GetSource(sourceName)) {
return esf;
- } else {
- return this->CreateSource(sourceName, generated);
}
+ return this->CreateSource(sourceName, generated);
}
void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
@@ -3756,69 +3754,67 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
<< "\" because an imported target with the same name already exists.";
msg = e.str();
return false;
- } else {
- // target names must be globally unique
- switch (this->GetPolicyStatus(cmPolicies::CMP0002)) {
- case cmPolicies::WARN:
- this->IssueMessage(
- cmake::AUTHOR_WARNING,
- cmPolicies::GetPolicyWarning(cmPolicies::CMP0002));
- case cmPolicies::OLD:
- return true;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- this->IssueMessage(
- cmake::FATAL_ERROR,
- cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0002));
- return true;
- case cmPolicies::NEW:
- break;
- }
-
- // The conflict is with a non-imported target.
- // Allow this if the user has requested support.
- cmake* cm = this->GetCMakeInstance();
- if (isCustom && existing->GetType() == cmState::UTILITY &&
- this != existing->GetMakefile() &&
- cm->GetState()->GetGlobalPropertyAsBool(
- "ALLOW_DUPLICATE_CUSTOM_TARGETS")) {
+ }
+ // target names must be globally unique
+ switch (this->GetPolicyStatus(cmPolicies::CMP0002)) {
+ case cmPolicies::WARN:
+ this->IssueMessage(cmake::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0002));
+ case cmPolicies::OLD:
return true;
- }
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ this->IssueMessage(
+ cmake::FATAL_ERROR,
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0002));
+ return true;
+ case cmPolicies::NEW:
+ break;
+ }
- // Produce an error that tells the user how to work around the
- // problem.
- std::ostringstream e;
- e << "cannot create target \"" << name
- << "\" because another target with the same name already exists. "
- << "The existing target is ";
- switch (existing->GetType()) {
- case cmState::EXECUTABLE:
- e << "an executable ";
- break;
- case cmState::STATIC_LIBRARY:
- e << "a static library ";
- break;
- case cmState::SHARED_LIBRARY:
- e << "a shared library ";
- break;
- case cmState::MODULE_LIBRARY:
- e << "a module library ";
- break;
- case cmState::UTILITY:
- e << "a custom target ";
- break;
- case cmState::INTERFACE_LIBRARY:
- e << "an interface library ";
- break;
- default:
- break;
- }
- e << "created in source directory \""
- << existing->GetMakefile()->GetCurrentSourceDirectory() << "\". "
- << "See documentation for policy CMP0002 for more details.";
- msg = e.str();
- return false;
+ // The conflict is with a non-imported target.
+ // Allow this if the user has requested support.
+ cmake* cm = this->GetCMakeInstance();
+ if (isCustom && existing->GetType() == cmState::UTILITY &&
+ this != existing->GetMakefile() &&
+ cm->GetState()->GetGlobalPropertyAsBool(
+ "ALLOW_DUPLICATE_CUSTOM_TARGETS")) {
+ return true;
+ }
+
+ // Produce an error that tells the user how to work around the
+ // problem.
+ std::ostringstream e;
+ e << "cannot create target \"" << name
+ << "\" because another target with the same name already exists. "
+ << "The existing target is ";
+ switch (existing->GetType()) {
+ case cmState::EXECUTABLE:
+ e << "an executable ";
+ break;
+ case cmState::STATIC_LIBRARY:
+ e << "a static library ";
+ break;
+ case cmState::SHARED_LIBRARY:
+ e << "a shared library ";
+ break;
+ case cmState::MODULE_LIBRARY:
+ e << "a module library ";
+ break;
+ case cmState::UTILITY:
+ e << "a custom target ";
+ break;
+ case cmState::INTERFACE_LIBRARY:
+ e << "an interface library ";
+ break;
+ default:
+ break;
}
+ e << "created in source directory \""
+ << existing->GetMakefile()->GetCurrentSourceDirectory() << "\". "
+ << "See documentation for policy CMP0002 for more details.";
+ msg = e.str();
+ return false;
}
return true;
}
@@ -4246,15 +4242,15 @@ bool cmMakefile::HaveCStandardAvailable(cmTarget const* target,
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
cmArrayEnd(C_STANDARDS), cmStrCmp("11"))) {
return false;
- } else if (needC99 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS),
- cmStrCmp("99"))) {
+ }
+ if (needC99 && existingCStandard &&
+ existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
+ cmArrayEnd(C_STANDARDS), cmStrCmp("99"))) {
return false;
- } else if (needC90 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS),
- cmStrCmp("90"))) {
+ }
+ if (needC90 && existingCStandard &&
+ existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
+ cmArrayEnd(C_STANDARDS), cmStrCmp("90"))) {
return false;
}
return true;
@@ -4332,10 +4328,11 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
cmArrayEnd(CXX_STANDARDS),
cmStrCmp("11"))) {
return false;
- } else if (needCxx98 &&
- existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
- cmArrayEnd(CXX_STANDARDS),
- cmStrCmp("98"))) {
+ }
+ if (needCxx98 &&
+ existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
+ cmArrayEnd(CXX_STANDARDS),
+ cmStrCmp("98"))) {
return false;
}
return true;
diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx
index c03f60d..d64993a 100644
--- a/Source/cmNewLineStyle.cxx
+++ b/Source/cmNewLineStyle.cxx
@@ -34,19 +34,18 @@ bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args,
if (eol == "LF" || eol == "UNIX") {
NewLineStyle = LF;
return true;
- } else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") {
+ }
+ if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") {
NewLineStyle = CRLF;
return true;
- } else {
- errorString = "NEWLINE_STYLE sets an unknown style, only LF, "
- "CRLF, UNIX, DOS, and WIN32 are supported";
- return false;
}
- } else {
- errorString = "NEWLINE_STYLE must set a style: "
- "LF, CRLF, UNIX, DOS, or WIN32";
+ errorString = "NEWLINE_STYLE sets an unknown style, only LF, "
+ "CRLF, UNIX, DOS, and WIN32 are supported";
return false;
}
+ errorString = "NEWLINE_STYLE must set a style: "
+ "LF, CRLF, UNIX, DOS, or WIN32";
+ return false;
}
}
return true;
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 28bd992..f1da4d5 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -347,7 +347,8 @@ static std::string GetRccExecutable(cmGeneratorTarget const* target)
return std::string();
}
return qt5Rcc->ImportedGetLocation("");
- } else if (strcmp(qtVersion, "4") == 0) {
+ }
+ if (strcmp(qtVersion, "4") == 0) {
cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc");
if (!qt4Rcc) {
cmSystemTools::Error("Qt4::rcc target not found ", targetName.c_str());
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 04727b2..5869a01 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -295,9 +295,8 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
if (prop == "LOCATION") {
if (this->FullPath.empty()) {
return CM_NULLPTR;
- } else {
- return this->FullPath.c_str();
}
+ return this->FullPath.c_str();
}
const char* retVal = this->Properties.GetPropertyValue(prop);
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index d4eb90a..073c239 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -1702,7 +1702,8 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
return parent.GetDirectory().GetCurrentSource();
}
return "";
- } else if (prop == "LISTFILE_STACK") {
+ }
+ if (prop == "LISTFILE_STACK") {
std::vector<std::string> listFiles;
cmState::Snapshot snp = this->Snapshot_;
while (snp.IsValid()) {
@@ -1712,10 +1713,12 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
std::reverse(listFiles.begin(), listFiles.end());
output = cmJoin(listFiles, ";");
return output.c_str();
- } else if (prop == "CACHE_VARIABLES") {
+ }
+ if (prop == "CACHE_VARIABLES") {
output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
return output.c_str();
- } else if (prop == "VARIABLES") {
+ }
+ if (prop == "VARIABLES") {
std::vector<std::string> res = this->Snapshot_.ClosureKeys();
std::vector<std::string> cacheKeys =
this->Snapshot_.State->GetCacheEntryKeys();
@@ -1723,13 +1726,16 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
std::sort(res.begin(), res.end());
output = cmJoin(res, ";");
return output.c_str();
- } else if (prop == "INCLUDE_DIRECTORIES") {
+ }
+ if (prop == "INCLUDE_DIRECTORIES") {
output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
return output.c_str();
- } else if (prop == "COMPILE_OPTIONS") {
+ }
+ if (prop == "COMPILE_OPTIONS") {
output = cmJoin(this->GetCompileOptionsEntries(), ";");
return output.c_str();
- } else if (prop == "COMPILE_DEFINITIONS") {
+ }
+ if (prop == "COMPILE_DEFINITIONS") {
output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
return output.c_str();
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index f19f0f6..21a50cb 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -333,9 +333,8 @@ void cmSystemTools::Message(const char* m1, const char* title)
(*s_MessageCallback)(m1, title, s_DisableMessages,
s_MessageCallbackClientData);
return;
- } else {
- std::cerr << m1 << std::endl << std::flush;
}
+ std::cerr << m1 << std::endl << std::flush;
}
void cmSystemTools::ReportLastSystemError(const char* msg)
@@ -1688,7 +1687,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
if (pipe == cmsysProcess_Pipe_Timeout) {
// Timeout has been exceeded.
return pipe;
- } else if (pipe == cmsysProcess_Pipe_STDOUT) {
+ }
+ if (pipe == cmsysProcess_Pipe_STDOUT) {
// Append to the stdout buffer.
std::vector<char>::size_type size = out.size();
out.insert(out.end(), data, data + length);
@@ -1704,13 +1704,13 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
line.append(&out[0], outiter - out.begin());
out.erase(out.begin(), out.end());
return cmsysProcess_Pipe_STDOUT;
- } else if (!err.empty()) {
+ }
+ if (!err.empty()) {
line.append(&err[0], erriter - err.begin());
err.erase(err.begin(), err.end());
return cmsysProcess_Pipe_STDERR;
- } else {
- return cmsysProcess_Pipe_None;
}
+ return cmsysProcess_Pipe_None;
}
}
}
@@ -2218,13 +2218,12 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// The new rpath is empty and there is no rpath anyway so it is
// okay.
return true;
- } else {
- if (emsg) {
- *emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; ";
- *emsg += elf.GetErrorMessage();
- }
- return false;
}
+ if (emsg) {
+ *emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; ";
+ *emsg += elf.GetErrorMessage();
+ }
+ return false;
}
for (int i = 0; i < se_count; ++i) {
@@ -2382,7 +2381,8 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
if (lhs < rhs) {
// lhs < rhs, so true if operation is LESS
return (op & cmSystemTools::OP_LESS) != 0;
- } else if (lhs > rhs) {
+ }
+ if (lhs > rhs) {
// lhs > rhs, so true if operation is GREATER
return (op & cmSystemTools::OP_GREATER) != 0;
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 5681885..ed04d2f 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -774,12 +774,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
<< prop << "\" is not allowed.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
- } else if (prop == "NAME") {
+ }
+ if (prop == "NAME") {
std::ostringstream e;
e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
- } else if (prop == "INCLUDE_DIRECTORIES") {
+ }
+ if (prop == "INCLUDE_DIRECTORIES") {
this->Internal->IncludeDirectoriesEntries.clear();
this->Internal->IncludeDirectoriesBacktraces.clear();
if (value) {
@@ -856,12 +858,14 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
<< prop << "\" is not allowed.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
- } else if (prop == "NAME") {
+ }
+ if (prop == "NAME") {
std::ostringstream e;
e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
- } else if (prop == "INCLUDE_DIRECTORIES") {
+ }
+ if (prop == "INCLUDE_DIRECTORIES") {
if (value && *value) {
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
@@ -1230,9 +1234,10 @@ const char* cmTarget::GetProperty(const std::string& prop,
return output.c_str();
}
// the type property returns what type the target is
- else if (prop == propTYPE) {
+ if (prop == propTYPE) {
return cmState::GetTargetTypeName(this->GetType());
- } else if (prop == propINCLUDE_DIRECTORIES) {
+ }
+ if (prop == propINCLUDE_DIRECTORIES) {
if (this->Internal->IncludeDirectoriesEntries.empty()) {
return CM_NULLPTR;
}
@@ -1240,7 +1245,8 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output;
output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";");
return output.c_str();
- } else if (prop == propCOMPILE_FEATURES) {
+ }
+ if (prop == propCOMPILE_FEATURES) {
if (this->Internal->CompileFeaturesEntries.empty()) {
return CM_NULLPTR;
}
@@ -1248,7 +1254,8 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output;
output = cmJoin(this->Internal->CompileFeaturesEntries, ";");
return output.c_str();
- } else if (prop == propCOMPILE_OPTIONS) {
+ }
+ if (prop == propCOMPILE_OPTIONS) {
if (this->Internal->CompileOptionsEntries.empty()) {
return CM_NULLPTR;
}
@@ -1256,7 +1263,8 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output;
output = cmJoin(this->Internal->CompileOptionsEntries, ";");
return output.c_str();
- } else if (prop == propCOMPILE_DEFINITIONS) {
+ }
+ if (prop == propCOMPILE_DEFINITIONS) {
if (this->Internal->CompileDefinitionsEntries.empty()) {
return CM_NULLPTR;
}
@@ -1264,15 +1272,20 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output;
output = cmJoin(this->Internal->CompileDefinitionsEntries, ";");
return output.c_str();
- } else if (prop == propIMPORTED) {
+ }
+ if (prop == propIMPORTED) {
return this->IsImported() ? "TRUE" : "FALSE";
- } else if (prop == propNAME) {
+ }
+ if (prop == propNAME) {
return this->GetName().c_str();
- } else if (prop == propBINARY_DIR) {
+ }
+ if (prop == propBINARY_DIR) {
return this->GetMakefile()->GetCurrentBinaryDirectory();
- } else if (prop == propSOURCE_DIR) {
+ }
+ if (prop == propSOURCE_DIR) {
return this->GetMakefile()->GetCurrentSourceDirectory();
- } else if (prop == propSOURCES) {
+ }
+ if (prop == propSOURCES) {
if (this->Internal->SourceEntries.empty()) {
return CM_NULLPTR;
}
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx
index 7bfc109..b072964 100644
--- a/Source/cmUuid.cxx
+++ b/Source/cmUuid.cxx
@@ -180,13 +180,14 @@ bool cmUuid::IntFromHexDigit(char input, char& output) const
if (input >= '0' && input <= '9') {
output = char(input - '0');
return true;
- } else if (input >= 'a' && input <= 'f') {
+ }
+ if (input >= 'a' && input <= 'f') {
output = char(input - 'a' + 0xA);
return true;
- } else if (input >= 'A' && input <= 'F') {
+ }
+ if (input >= 'A' && input <= 'F') {
output = char(input - 'A' + 0xA);
return true;
- } else {
- return false;
}
+ return false;
}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 9e338e8..74c3f71 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1513,9 +1513,8 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
if (this->GetWorkingMode() != NORMAL_MODE) {
if (cmSystemTools::GetErrorOccuredFlag()) {
return -1;
- } else {
- return 0;
}
+ return 0;
}
// If MAKEFLAGS are given in the environment, remove the environment
@@ -2063,11 +2062,10 @@ cmInstalledFile* cmake::GetOrCreateInstalledFile(cmMakefile* mf,
if (i != this->InstalledFiles.end()) {
cmInstalledFile& file = i->second;
return &file;
- } else {
- cmInstalledFile& file = this->InstalledFiles[name];
- file.SetName(mf, name);
- return &file;
}
+ cmInstalledFile& file = this->InstalledFiles[name];
+ file.SetName(mf, name);
+ return &file;
}
cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const
@@ -2078,9 +2076,8 @@ cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const
if (i != this->InstalledFiles.end()) {
cmInstalledFile const& file = i->second;
return &file;
- } else {
- return CM_NULLPTR;
}
+ return CM_NULLPTR;
}
int cmake::GetSystemInformation(std::vector<std::string>& args)
@@ -2253,11 +2250,10 @@ static bool cmakeCheckStampFile(const char* stampName)
std::cout << "CMake does not need to re-run because " << stampName
<< " is up-to-date.\n";
return true;
- } else {
- cmSystemTools::RemoveFile(stampTemp);
- cmSystemTools::Error("Cannot restore timestamp ", stampName);
- return false;
}
+ cmSystemTools::RemoveFile(stampTemp);
+ cmSystemTools::Error("Cannot restore timestamp ", stampName);
+ return false;
}
static bool cmakeCheckStampList(const char* stampList)
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 8731b2b..1505d00 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -163,7 +163,8 @@ int main(int ac, char const* const* av)
if (ac > 1) {
if (strcmp(av[1], "--build") == 0) {
return do_build(ac, av);
- } else if (strcmp(av[1], "-E") == 0) {
+ }
+ if (strcmp(av[1], "-E") == 0) {
return do_command(ac, av);
}
}
@@ -237,7 +238,8 @@ int do_cmake(int ac, char const* const* av)
"Use cmake-gui or ccmake for an interactive dialog.\n";
/* clang-format on */
return 1;
- } else if (strcmp(av[i], "--system-information") == 0) {
+ }
+ if (strcmp(av[i], "--system-information") == 0) {
sysinfo = true;
} else if (strcmp(av[i], "-N") == 0) {
view_only = true;
@@ -313,9 +315,8 @@ int do_cmake(int ac, char const* const* av)
// interpret negative return values as errors.
if (res != 0) {
return 1;
- } else {
- return 0;
}
+ return 0;
}
static int do_build(int ac, char const* const* av)
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index be023b1..f25c085 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -262,7 +262,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// run include what you use command and then run the compile
// command. This is an internal undocumented option and should
// only be used by CMake itself when running iwyu.
- else if (args[1] == "__run_iwyu") {
+ if (args[1] == "__run_iwyu") {
if (args.size() < 3) {
std::cerr << "__run_iwyu Usage: -E __run_iwyu [--iwyu=/path/iwyu]"
" [--tidy=/path/tidy] -- compile command\n";
@@ -393,13 +393,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
// Echo string
- else if (args[1] == "echo") {
+ if (args[1] == "echo") {
std::cout << cmJoin(cmMakeRange(args).advance(2), " ") << std::endl;
return 0;
}
// Echo string no new line
- else if (args[1] == "echo_append") {
+ if (args[1] == "echo_append") {
std::cout << cmJoin(cmMakeRange(args).advance(2), " ");
return 0;
}
@@ -851,7 +851,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmSystemTools::Error("Can not use compression flags with format: ",
format.c_str());
return 1;
- } else if (nCompress > 1) {
+ }
+ if (nCompress > 1) {
cmSystemTools::Error("Can only compress a tar file one way; "
"at most one flag of z, j, or J may be used");
return 1;
@@ -995,12 +996,12 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num)
int count = 0;
if (!progFile) {
return;
- } else {
- if (1 != fscanf(progFile, "%i", &count)) {
- cmSystemTools::Message("Could not read from progress file.");
- }
- fclose(progFile);
}
+ if (1 != fscanf(progFile, "%i", &count)) {
+ cmSystemTools::Message("Could not read from progress file.");
+ }
+ fclose(progFile);
+
const char* last = num.c_str();
for (const char* c = last;; ++c) {
if (*c == ',' || *c == '\0') {