Merge topic 'else-after-return'

7b6349da CMake: don't use else after return
50ad1e0a CTest: don't use else after return
7f97a6c9 CPack: don't use else after return
4988b914 CursesDialog: don't use else after return
This commit is contained in:
Brad King 2016-08-23 09:00:00 -04:00 committed by CMake Topic Stage
commit 797f7ad87d
55 changed files with 470 additions and 518 deletions

View File

@ -231,11 +231,9 @@ int cmCPackArchiveGenerator::PackageFiles()
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else {
return PackageComponents(componentPackageMethod == return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT); ONE_PACKAGE_PER_COMPONENT);
} }
}
// CASE 3 : NON COMPONENT package. // CASE 3 : NON COMPONENT package.
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive); DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);

View File

@ -242,16 +242,12 @@ int cmCPackDebGenerator::PackageFiles()
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else {
return PackageComponents(componentPackageMethod == return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT); ONE_PACKAGE_PER_COMPONENT);
} }
}
// CASE 3 : NON COMPONENT package. // CASE 3 : NON COMPONENT package.
else {
return PackageComponentsAllInOne(""); return PackageComponentsAllInOne("");
} }
}
int cmCPackDebGenerator::createDeb() int cmCPackDebGenerator::createDeb()
{ {
@ -694,9 +690,8 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (CM_NULLPTR != GetOption(groupVar)) { if (CM_NULLPTR != GetOption(groupVar)) {
return std::string(GetOption(groupVar)); return std::string(GetOption(groupVar));
} else {
return componentName;
} }
return componentName;
} }
// The following code is taken from OpenBSD ar: // The following code is taken from OpenBSD ar:

View File

@ -67,7 +67,8 @@ int cmCPackGenerator::PrepareNames()
cmCPackLog::LOG_ERROR, "CPACK_SET_DESTDIR is set to ON but the '" cmCPackLog::LOG_ERROR, "CPACK_SET_DESTDIR is set to ON but the '"
<< Name << "' generator does NOT support it." << std::endl); << Name << "' generator does NOT support it." << std::endl);
return 0; return 0;
} else if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) { }
if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) {
cmCPackLogger(cmCPackLog::LOG_WARNING, cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPACK_SET_DESTDIR is set to ON but it is " "CPACK_SET_DESTDIR is set to ON but it is "
<< "usually a bad idea to do that with '" << Name << "usually a bad idea to do that with '" << Name

View File

@ -215,16 +215,12 @@ int cmCPackRPMGenerator::PackageFiles()
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else {
return PackageComponents(componentPackageMethod == return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT); ONE_PACKAGE_PER_COMPONENT);
} }
}
// CASE 3 : NON COMPONENT package. // CASE 3 : NON COMPONENT package.
else {
return PackageComponentsAllInOne(""); return PackageComponentsAllInOne("");
} }
}
bool cmCPackRPMGenerator::SupportsComponentInstallation() const bool cmCPackRPMGenerator::SupportsComponentInstallation() const
{ {
@ -247,7 +243,6 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (CM_NULLPTR != GetOption(groupVar)) { if (CM_NULLPTR != GetOption(groupVar)) {
return std::string(GetOption(groupVar)); return std::string(GetOption(groupVar));
} else { }
return componentName; return componentName;
} }
}

View File

@ -532,9 +532,8 @@ public:
if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) && if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
result != 0) { result != 0) {
return result < 0; return result < 0;
} else {
return l < r;
} }
return l < r;
} }
private: private:

View File

@ -216,11 +216,10 @@ std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
std::string flag = "-r"; std::string flag = "-r";
flag += tagLine.substr(1); flag += tagLine.substr(1);
return flag; return flag;
} else { }
// Use the default branch. // Use the default branch.
return "-b"; return "-b";
} }
}
void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag, void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag,
std::vector<Revision>& revisions) std::vector<Revision>& revisions)

View File

@ -763,12 +763,11 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
this->Quiet); this->Quiet);
cov.ReadCoverageFile(coverageFile.c_str()); cov.ReadCoverageFile(coverageFile.c_str());
return static_cast<int>(cont->TotalCoverage.size()); return static_cast<int>(cont->TotalCoverage.size());
} else { }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Cannot find GTM coverage file: " << coverageFile " Cannot find GTM coverage file: " << coverageFile
<< std::endl, << std::endl,
this->Quiet); this->Quiet);
}
cmParseCacheCoverage ccov(*cont, this->CTest); cmParseCacheCoverage ccov(*cont, this->CTest);
coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov"; coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov";
if (cmSystemTools::FileExists(coverageFile.c_str())) { if (cmSystemTools::FileExists(coverageFile.c_str())) {

View File

@ -126,13 +126,12 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv)
this->HandleRealArg(this->RealArgV[i]); this->HandleRealArg(this->RealArgV[i]);
} }
return true; return true;
} else { }
this->RealArgC = 0; this->RealArgC = 0;
this->RealArgV = CM_NULLPTR; this->RealArgV = CM_NULLPTR;
std::cerr << "No launch/command separator ('--') found!\n"; std::cerr << "No launch/command separator ('--') found!\n";
return false; return false;
} }
}
void cmCTestLaunch::HandleRealArg(const char* arg) void cmCTestLaunch::HandleRealArg(const char* arg)
{ {

View File

@ -638,28 +638,25 @@ bool cmCTestMemCheckHandler::ProcessMemCheckOutput(const std::string& str,
std::string& log, std::string& log,
std::vector<int>& results) std::vector<int>& results)
{ {
if (this->MemoryTesterStyle == cmCTestMemCheckHandler::VALGRIND) { switch (this->MemoryTesterStyle) {
case cmCTestMemCheckHandler::VALGRIND:
return this->ProcessMemCheckValgrindOutput(str, log, results); return this->ProcessMemCheckValgrindOutput(str, log, results);
} else if (this->MemoryTesterStyle == cmCTestMemCheckHandler::PURIFY) { case cmCTestMemCheckHandler::PURIFY:
return this->ProcessMemCheckPurifyOutput(str, log, results); return this->ProcessMemCheckPurifyOutput(str, log, results);
} else if (this->MemoryTesterStyle == case cmCTestMemCheckHandler::ADDRESS_SANITIZER:
cmCTestMemCheckHandler::ADDRESS_SANITIZER || case cmCTestMemCheckHandler::THREAD_SANITIZER:
this->MemoryTesterStyle == case cmCTestMemCheckHandler::MEMORY_SANITIZER:
cmCTestMemCheckHandler::THREAD_SANITIZER || case cmCTestMemCheckHandler::UB_SANITIZER:
this->MemoryTesterStyle ==
cmCTestMemCheckHandler::MEMORY_SANITIZER ||
this->MemoryTesterStyle == cmCTestMemCheckHandler::UB_SANITIZER) {
return this->ProcessMemCheckSanitizerOutput(str, log, results); return this->ProcessMemCheckSanitizerOutput(str, log, results);
} else if (this->MemoryTesterStyle == case cmCTestMemCheckHandler::BOUNDS_CHECKER:
cmCTestMemCheckHandler::BOUNDS_CHECKER) {
return this->ProcessMemCheckBoundsCheckerOutput(str, log, results); return this->ProcessMemCheckBoundsCheckerOutput(str, log, results);
} else { default:
log.append("\nMemory checking style used was: "); log.append("\nMemory checking style used was: ");
log.append("None that I know"); log.append("None that I know");
log = str; log = str;
}
return true; return true;
} }
}
std::vector<int>::size_type cmCTestMemCheckHandler::FindOrAddWarning( std::vector<int>::size_type cmCTestMemCheckHandler::FindOrAddWarning(
const std::string& warning) const std::string& warning)

View File

@ -824,9 +824,8 @@ bool cmCTestMultiProcessHandler::CheckCycles()
<< this->Properties[root]->Name << this->Properties[root]->Name
<< "\".\nPlease fix the cycle and run ctest again.\n"); << "\".\nPlease fix the cycle and run ctest again.\n");
return false; return false;
} else {
s.push(*d);
} }
s.push(*d);
} }
} }
} }

View File

@ -373,9 +373,8 @@ std::string cmCTestP4::GetWorkingRevision()
if (rev.empty()) { if (rev.empty()) {
return "0"; return "0";
} else {
return rev;
} }
return rev;
} }
void cmCTestP4::NoteOldRevision() void cmCTestP4::NoteOldRevision()

View File

@ -54,7 +54,8 @@ bool cmCTestRunTest::CheckOutput()
if (p == cmsysProcess_Pipe_None) { if (p == cmsysProcess_Pipe_None) {
// Process has terminated and all output read. // Process has terminated and all output read.
return false; return false;
} else if (p == cmsysProcess_Pipe_STDOUT) { }
if (p == cmsysProcess_Pipe_STDOUT) {
// Store this line of output. // Store this line of output.
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex() cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
<< ": " << line << std::endl); << ": " << line << std::endl);
@ -82,8 +83,7 @@ bool cmCTestRunTest::CheckOutput()
} }
} }
} }
} else // if(p == cmsysProcess_Pipe_Timeout) } else { // if(p == cmsysProcess_Pipe_Timeout)
{
break; break;
} }
} }

View File

@ -80,11 +80,11 @@ static bool cmCTestSVNPathStarts(std::string const& p1, std::string const& p2)
// Does path p1 start with path p2? // Does path p1 start with path p2?
if (p1.size() == p2.size()) { if (p1.size() == p2.size()) {
return p1 == p2; return p1 == p2;
} else if (p1.size() > p2.size() && p1[p2.size()] == '/') {
return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0;
} else {
return false;
} }
if (p1.size() > p2.size() && p1[p2.size()] == '/') {
return strncmp(p1.c_str(), p2.c_str(), p2.size()) == 0;
}
return false;
} }
std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo) std::string cmCTestSVN::LoadInfo(SVNInfo& svninfo)
@ -295,9 +295,8 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
if (strcmp(parameters[0], "update") == 0) { if (strcmp(parameters[0], "update") == 0) {
return RunUpdateCommand(&args[0], out, err); return RunUpdateCommand(&args[0], out, err);
} else {
return RunChild(&args[0], out, err);
} }
return RunChild(&args[0], out, err);
} }
class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger, class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger,

View File

@ -284,7 +284,7 @@ inline int GetNextNumber(std::string const& in, int& val,
} }
pos = pos2 + 1; pos = pos2 + 1;
return 1; return 1;
} else { }
if (in.size() - pos == 0) { if (in.size() - pos == 0) {
val = -1; val = -1;
} else { } else {
@ -292,7 +292,6 @@ inline int GetNextNumber(std::string const& in, int& val,
} }
return 0; return 0;
} }
}
// get the next number in a string with numbers separated by , // get the next number in a string with numbers separated by ,
// pos is the start of the search and pos2 is the end of the search // pos is the start of the search and pos2 is the end of the search
@ -311,7 +310,7 @@ inline int GetNextRealNumber(std::string const& in, double& val,
} }
pos = pos2 + 1; pos = pos2 + 1;
return 1; return 1;
} else { }
if (in.size() - pos == 0) { if (in.size() - pos == 0) {
val = -1; val = -1;
} else { } else {
@ -319,7 +318,6 @@ inline int GetNextRealNumber(std::string const& in, double& val,
} }
return 0; return 0;
} }
}
cmCTestTestHandler::cmCTestTestHandler() cmCTestTestHandler::cmCTestTestHandler()
{ {

View File

@ -49,7 +49,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
if (cmSystemTools::FileExists(arg.c_str())) { if (cmSystemTools::FileExists(arg.c_str())) {
this->Files.insert(arg); this->Files.insert(arg);
return true; return true;
} else { }
std::ostringstream e; std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit " e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file."; << "a non-existent file.";
@ -57,7 +57,6 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
this->ArgumentDoing = ArgumentDoingError; this->ArgumentDoing = ArgumentDoingError;
return false; return false;
} }
}
// Look for other arguments. // Look for other arguments.
return this->Superclass::CheckArgumentValue(arg); return this->Superclass::CheckArgumentValue(arg);

View File

@ -42,9 +42,8 @@ public:
std::string foundFileName = std::string foundFileName =
line.substr(begIndex + 3, endIndex - (begIndex + 4)); line.substr(begIndex + 3, endIndex - (begIndex + 4));
return foundFileName; return foundFileName;
} else {
return line.substr(begIndex, line.npos);
} }
return line.substr(begIndex, line.npos);
} }
bool ParseFile(std::string const& file) bool ParseFile(std::string const& file)
{ {

View File

@ -128,7 +128,7 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
if (i != this->RoutineToDirectory.end()) { if (i != this->RoutineToDirectory.end()) {
filepath = i->second; filepath = i->second;
return true; return true;
} else { }
// try some alternate names // try some alternate names
const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR }; const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR };
for (int k = 0; tryname[k] != CM_NULLPTR; k++) { for (int k = 0; tryname[k] != CM_NULLPTR; k++) {
@ -139,6 +139,5 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
return true; return true;
} }
} }
}
return false; return false;
} }

View File

@ -124,10 +124,10 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
int p = cmsysProcess_WaitForData(this->Process, &data, &length, &timeout); int p = cmsysProcess_WaitForData(this->Process, &data, &length, &timeout);
if (p == cmsysProcess_Pipe_Timeout) { if (p == cmsysProcess_Pipe_Timeout) {
return cmsysProcess_Pipe_Timeout; return cmsysProcess_Pipe_Timeout;
} else if (p == cmsysProcess_Pipe_STDOUT) { }
if (p == cmsysProcess_Pipe_STDOUT) {
this->Output.insert(this->Output.end(), data, data + length); this->Output.insert(this->Output.end(), data, data + length);
} else // p == cmsysProcess_Pipe_None } else { // p == cmsysProcess_Pipe_None
{
// The process will provide no more data. // The process will provide no more data.
break; break;
} }

View File

@ -40,9 +40,8 @@ bool cmCursesBoolWidget::HandleInput(int& key, cmCursesMainForm* /*fm*/,
touchwin(w); touchwin(w);
wrefresh(w); wrefresh(w);
return true; return true;
} else {
return false;
} }
return false;
} }
void cmCursesBoolWidget::SetValueAsBool(bool value) void cmCursesBoolWidget::SetValueAsBool(bool value)

View File

@ -110,7 +110,6 @@ const char* cmCursesCacheEntryComposite::GetValue()
{ {
if (this->Label) { if (this->Label) {
return this->Label->GetValue(); return this->Label->GetValue();
} else { }
return CM_NULLPTR; return CM_NULLPTR;
} }
}

View File

@ -13,10 +13,7 @@
#include "cmCursesMainForm.h" #include "cmCursesMainForm.h"
inline int ctrl(int z) #define ctrl(z) ((z)&037)
{
return (z & 037);
}
cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left, cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left,
int top) int top)
@ -34,24 +31,26 @@ cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left,
bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm* /*fm*/, bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm* /*fm*/,
WINDOW* w) WINDOW* w)
{ {
switch (key) {
// 10 == enter case 10: // 10 == enter
if (key == 10 || key == KEY_ENTER) { case KEY_ENTER:
this->NextOption(); this->NextOption();
touchwin(w); touchwin(w);
wrefresh(w); wrefresh(w);
return true; return true;
} else if (key == KEY_LEFT || key == ctrl('b')) { case KEY_LEFT:
case ctrl('b'):
touchwin(w); touchwin(w);
wrefresh(w); wrefresh(w);
this->PreviousOption(); this->PreviousOption();
return true; return true;
} else if (key == KEY_RIGHT || key == ctrl('f')) { case KEY_RIGHT:
case ctrl('f'):
this->NextOption(); this->NextOption();
touchwin(w); touchwin(w);
wrefresh(w); wrefresh(w);
return true; return true;
} else { default:
return false; return false;
} }
} }

View File

@ -94,11 +94,10 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
// quit // quit
if (key == 'q') { if (key == 'q') {
return false; return false;
} else { }
key = getch(); key = getch();
continue; continue;
} }
}
// If resize occurred during edit, move out of edit mode // If resize occurred during edit, move out of edit mode
if (!this->InEdit && (key != 10 && key != KEY_ENTER && key != 'i')) { if (!this->InEdit && (key != 10 && key != KEY_ENTER && key != 'i')) {
@ -207,7 +206,6 @@ bool cmCursesStringWidget::PrintKeys()
curses_move(y - 3, 0); curses_move(y - 3, 0);
printw(fmt_s, "Editing option, press [enter] to leave edit."); printw(fmt_s, "Editing option, press [enter] to leave edit.");
return true; return true;
} else { }
return false; return false;
} }
}

View File

@ -75,9 +75,8 @@ struct cmArchiveWrite::Callback
if (self->Stream.write(static_cast<const char*>(b), if (self->Stream.write(static_cast<const char*>(b),
static_cast<std::streamsize>(n))) { static_cast<std::streamsize>(n))) {
return static_cast<__LA_SSIZE_T>(n); return static_cast<__LA_SSIZE_T>(n);
} else {
return static_cast<__LA_SSIZE_T>(-1);
} }
return static_cast<__LA_SSIZE_T>(-1);
} }
}; };

View File

@ -781,14 +781,13 @@ bool cmCTest::SetTest(const char* ttype, bool report)
if (p != PartCount) { if (p != PartCount) {
this->Parts[p].Enable(); this->Parts[p].Enable();
return true; return true;
} else { }
if (report) { if (report) {
cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \"" cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \""
<< ttype << "\" yet..." << std::endl); << ttype << "\" yet..." << std::endl);
} }
return false; return false;
} }
}
void cmCTest::Finalize() void cmCTest::Finalize()
{ {

View File

@ -576,7 +576,8 @@ const char* cmCacheManager::CacheEntry::GetProperty(
{ {
if (prop == "TYPE") { if (prop == "TYPE") {
return cmState::CacheEntryTypeToString(this->Type); return cmState::CacheEntryTypeToString(this->Type);
} else if (prop == "VALUE") { }
if (prop == "VALUE") {
return this->Value.c_str(); return this->Value.c_str();
} }
return this->Properties.GetPropertyValue(prop); return this->Properties.GetPropertyValue(prop);

View File

@ -75,9 +75,8 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
if (cmSystemTools::GetEnv(var, str)) { if (cmSystemTools::GetEnv(var, str)) {
if (this->EscapeQuotes) { if (this->EscapeQuotes) {
return this->AddString(cmSystemTools::EscapeQuotes(str.c_str())); return this->AddString(cmSystemTools::EscapeQuotes(str.c_str()));
} else {
return this->AddString(str);
} }
return this->AddString(str);
} }
return this->EmptyVariable; return this->EmptyVariable;
} }
@ -86,9 +85,8 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
this->Makefile->GetState()->GetInitializedCacheValue(var)) { this->Makefile->GetState()->GetInitializedCacheValue(var)) {
if (this->EscapeQuotes) { if (this->EscapeQuotes) {
return this->AddString(cmSystemTools::EscapeQuotes(c)); return this->AddString(cmSystemTools::EscapeQuotes(c));
} else {
return this->AddString(c);
} }
return this->AddString(c);
} }
return this->EmptyVariable; return this->EmptyVariable;
} }
@ -162,7 +160,8 @@ char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
{ {
if (!in1) { if (!in1) {
return in2; return in2;
} else if (!in2) { }
if (!in2) {
return in1; return in1;
} }
size_t len = strlen(in1) + strlen(in2) + 1; size_t len = strlen(in1) + strlen(in2) + 1;
@ -282,11 +281,10 @@ int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen)
this->CurrentLine++; this->CurrentLine++;
} }
return (1); return (1);
} else { }
buf[0] = '\n'; buf[0] = '\n';
return (0); return (0);
} }
}
void cmCommandArgumentParserHelper::Error(const char* str) void cmCommandArgumentParserHelper::Error(const char* str)
{ {

View File

@ -19,19 +19,23 @@ CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo)
{ {
if (strcmp(algo, "MD5") == 0) { if (strcmp(algo, "MD5") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashMD5); return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashMD5);
} else if (strcmp(algo, "SHA1") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA1);
} else if (strcmp(algo, "SHA224") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA224);
} else if (strcmp(algo, "SHA256") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA256);
} else if (strcmp(algo, "SHA384") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA384);
} else if (strcmp(algo, "SHA512") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA512);
} else {
return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR);
} }
if (strcmp(algo, "SHA1") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA1);
}
if (strcmp(algo, "SHA224") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA224);
}
if (strcmp(algo, "SHA256") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA256);
}
if (strcmp(algo, "SHA384") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA384);
}
if (strcmp(algo, "SHA512") == 0) {
return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHashSHA512);
}
return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR);
} }
bool cmCryptoHash::IntFromHexDigit(char input, char& output) bool cmCryptoHash::IntFromHexDigit(char input, char& output)
@ -39,10 +43,12 @@ bool cmCryptoHash::IntFromHexDigit(char input, char& output)
if (input >= '0' && input <= '9') { if (input >= '0' && input <= '9') {
output = char(input - '0'); output = char(input - '0');
return true; return true;
} else if (input >= 'a' && input <= 'f') { }
if (input >= 'a' && input <= 'f') {
output = char(input - 'a' + 0xA); output = char(input - 'a' + 0xA);
return true; return true;
} else if (input >= 'A' && input <= 'F') { }
if (input >= 'A' && input <= 'F') {
output = char(input - 'A' + 0xA); output = char(input - 'A' + 0xA);
return true; return true;
} }

View File

@ -521,7 +521,8 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
} }
} }
return true; 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(), if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
compilerId.c_str())) { compilerId.c_str())) {
if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) { if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {

View File

@ -719,9 +719,8 @@ const char* cmDocumentation::GetNameString() const
{ {
if (!this->NameString.empty()) { if (!this->NameString.empty()) {
return this->NameString.c_str(); return this->NameString.c_str();
} else {
return "CMake";
} }
return "CMake";
} }
bool cmDocumentation::IsOption(const char* arg) const bool cmDocumentation::IsOption(const char* arg) const

View File

@ -832,45 +832,40 @@ cmELF::FileType cmELF::GetFileType() const
{ {
if (this->Valid()) { if (this->Valid()) {
return this->Internal->GetFileType(); return this->Internal->GetFileType();
} else {
return FileTypeInvalid;
} }
return FileTypeInvalid;
} }
unsigned int cmELF::GetNumberOfSections() const unsigned int cmELF::GetNumberOfSections() const
{ {
if (this->Valid()) { if (this->Valid()) {
return this->Internal->GetNumberOfSections(); return this->Internal->GetNumberOfSections();
} else {
return 0;
} }
return 0;
} }
unsigned int cmELF::GetDynamicEntryCount() const unsigned int cmELF::GetDynamicEntryCount() const
{ {
if (this->Valid()) { if (this->Valid()) {
return this->Internal->GetDynamicEntryCount(); return this->Internal->GetDynamicEntryCount();
} else {
return 0;
} }
return 0;
} }
unsigned long cmELF::GetDynamicEntryPosition(int index) const unsigned long cmELF::GetDynamicEntryPosition(int index) const
{ {
if (this->Valid()) { if (this->Valid()) {
return this->Internal->GetDynamicEntryPosition(index); return this->Internal->GetDynamicEntryPosition(index);
} else {
return 0;
} }
return 0;
} }
bool cmELF::ReadBytes(unsigned long pos, unsigned long size, char* buf) const bool cmELF::ReadBytes(unsigned long pos, unsigned long size, char* buf) const
{ {
if (this->Valid()) { if (this->Valid()) {
return this->Internal->ReadBytes(pos, size, buf); return this->Internal->ReadBytes(pos, size, buf);
} else {
return false;
} }
return false;
} }
bool cmELF::GetSOName(std::string& soname) bool cmELF::GetSOName(std::string& soname)
@ -878,9 +873,8 @@ bool cmELF::GetSOName(std::string& soname)
if (StringEntry const* se = this->GetSOName()) { if (StringEntry const* se = this->GetSOName()) {
soname = se->Value; soname = se->Value;
return true; return true;
} else {
return false;
} }
return false;
} }
cmELF::StringEntry const* cmELF::GetSOName() cmELF::StringEntry const* cmELF::GetSOName()
@ -888,9 +882,8 @@ cmELF::StringEntry const* cmELF::GetSOName()
if (this->Valid() && if (this->Valid() &&
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) { this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) {
return this->Internal->GetSOName(); return this->Internal->GetSOName();
} else {
return CM_NULLPTR;
} }
return CM_NULLPTR;
} }
cmELF::StringEntry const* cmELF::GetRPath() cmELF::StringEntry const* cmELF::GetRPath()
@ -899,9 +892,8 @@ cmELF::StringEntry const* cmELF::GetRPath()
(this->Internal->GetFileType() == cmELF::FileTypeExecutable || (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) { this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRPath(); return this->Internal->GetRPath();
} else {
return CM_NULLPTR;
} }
return CM_NULLPTR;
} }
cmELF::StringEntry const* cmELF::GetRunPath() cmELF::StringEntry const* cmELF::GetRunPath()
@ -910,9 +902,8 @@ cmELF::StringEntry const* cmELF::GetRunPath()
(this->Internal->GetFileType() == cmELF::FileTypeExecutable || (this->Internal->GetFileType() == cmELF::FileTypeExecutable ||
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) { this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRunPath(); return this->Internal->GetRunPath();
} else {
return CM_NULLPTR;
} }
return CM_NULLPTR;
} }
void cmELF::PrintInfo(std::ostream& os) const void cmELF::PrintInfo(std::ostream& os) const

View File

@ -211,12 +211,11 @@ void cmExportBuildFileGenerator::HandleMissingTarget(
link_libs += missingTarget; link_libs += missingTarget;
missingTargets.push_back(missingTarget); missingTargets.push_back(missingTarget);
return; return;
} else { }
// We are not appending, so all exported targets should be // We are not appending, so all exported targets should be
// known here. This is probably user-error. // known here. This is probably user-error.
this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences); this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
} }
}
// Assume the target will be exported by another command. // Assume the target will be exported by another command.
// Append it with the export namespace. // Append it with the export namespace.
link_libs += this->Namespace; link_libs += this->Namespace;

View File

@ -81,11 +81,10 @@ int cmExprParserHelper::LexInput(char* buf, int maxlen)
this->CurrentLine++; this->CurrentLine++;
} }
return (1); return (1);
} else { }
buf[0] = '\n'; buf[0] = '\n';
return (0); return (0);
} }
}
void cmExprParserHelper::Error(const char* str) void cmExprParserHelper::Error(const char* str)
{ {

View File

@ -124,13 +124,12 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
if (start + 1 < splitted.size()) { if (start + 1 < splitted.size()) {
it->InsertPath(splitted, start + 1, fileName); it->InsertPath(splitted, start + 1, fileName);
return; return;
} else { }
// last part of splitted // last part of splitted
it->files.push_back(fileName); it->files.push_back(fileName);
return; return;
} }
} }
}
// Not found in folders, thus insert // Not found in folders, thus insert
Tree newFolder; Tree newFolder;
newFolder.path = splitted[start]; newFolder.path = splitted[start];
@ -138,13 +137,12 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
newFolder.InsertPath(splitted, start + 1, fileName); newFolder.InsertPath(splitted, start + 1, fileName);
folders.push_back(newFolder); folders.push_back(newFolder);
return; return;
} else { }
// last part of splitted // last part of splitted
newFolder.files.push_back(fileName); newFolder.files.push_back(fileName);
folders.push_back(newFolder); folders.push_back(newFolder);
return; return;
} }
}
void Tree::BuildVirtualFolder(cmXMLWriter& xml) const void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
{ {
@ -717,22 +715,23 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
// Translate the cmake target type into the CodeBlocks target type id // Translate the cmake target type into the CodeBlocks target type id
int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target) int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target)
{ {
if (target->GetType() == cmState::EXECUTABLE) { switch (target->GetType()) {
case cmState::EXECUTABLE:
if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) || if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) ||
(target->GetPropertyAsBool("MACOSX_BUNDLE"))) { (target->GetPropertyAsBool("MACOSX_BUNDLE"))) {
return 0; return 0;
} else { }
return 1; return 1;
} case cmState::STATIC_LIBRARY:
} else if ((target->GetType() == cmState::STATIC_LIBRARY) || case cmState::OBJECT_LIBRARY:
(target->GetType() == cmState::OBJECT_LIBRARY)) {
return 2; return 2;
} else if ((target->GetType() == cmState::SHARED_LIBRARY) || case cmState::SHARED_LIBRARY:
(target->GetType() == cmState::MODULE_LIBRARY)) { case cmState::MODULE_LIBRARY:
return 3; return 3;
} default:
return 4; return 4;
} }
}
// Create the command line for building the given target using the selected // Create the command line for building the given target using the selected
// make // make

View File

@ -140,11 +140,10 @@ cmFileLockResult cmFileLockPool::ScopePool::Lock(const std::string& filename,
if (result.IsOk()) { if (result.IsOk()) {
this->Locks.push_back(lock); this->Locks.push_back(lock);
return cmFileLockResult::MakeOk(); return cmFileLockResult::MakeOk();
} else { }
delete lock; delete lock;
return result; return result;
} }
}
cmFileLockResult cmFileLockPool::ScopePool::Release( cmFileLockResult cmFileLockPool::ScopePool::Release(
const std::string& filename) const std::string& filename)

View File

@ -140,11 +140,14 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1,
// Compare using nanosecond resolution. // Compare using nanosecond resolution.
if (s1->st_mtim.tv_sec < s2->st_mtim.tv_sec) { if (s1->st_mtim.tv_sec < s2->st_mtim.tv_sec) {
return -1; 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; 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; 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; return 1;
} }
#elif CMake_STAT_HAS_ST_MTIMESPEC #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; long long t2 = s2->st_mtim.tv_sec * bil + s2->st_mtim.tv_nsec;
if (t1 < t2) { if (t1 < t2) {
return (t2 - t1) >= bil; return (t2 - t1) >= bil;
} else if (t2 < t1) {
return (t1 - t2) >= bil;
} else {
return false;
} }
if (t2 < t1) {
return (t1 - t2) >= bil;
}
return false;
#elif CMake_STAT_HAS_ST_MTIMESPEC #elif CMake_STAT_HAS_ST_MTIMESPEC
// Times are integers in units of 1ns. // Times are integers in units of 1ns.
long long bil = 1000000000; long long bil = 1000000000;
@ -240,12 +243,11 @@ bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
// Compare the two modification times. // Compare the two modification times.
*result = this->Compare(&s1, &s2); *result = this->Compare(&s1, &s2);
return true; return true;
} else { }
// No comparison available. Default to the same time. // No comparison available. Default to the same time.
*result = 0; *result = 0;
return false; return false;
} }
}
bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1, bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
const char* f2) const char* f2)
@ -256,8 +258,7 @@ bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
if (this->Stat(f1, &s1) && this->Stat(f2, &s2)) { if (this->Stat(f1, &s1) && this->Stat(f2, &s2)) {
// Compare the two modification times. // Compare the two modification times.
return this->TimesDiffer(&s1, &s2); return this->TimesDiffer(&s1, &s2);
} else { }
// No comparison available. Default to different times. // No comparison available. Default to different times.
return true; return true;
} }
}

View File

@ -22,7 +22,7 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
if (cmSystemTools::FileIsFullPath(includeName)) { if (cmSystemTools::FileIsFullPath(includeName)) {
fileName = includeName; fileName = includeName;
return cmSystemTools::FileExists(fileName.c_str(), true); return cmSystemTools::FileExists(fileName.c_str(), true);
} else { }
// Check for the file in the directory containing the including // Check for the file in the directory containing the including
// file. // file.
std::string fullName = dir; std::string fullName = dir;
@ -34,8 +34,7 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
} }
// Search the include path for the file. // Search the include path for the file.
for (std::vector<std::string>::const_iterator i = for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
this->IncludePath.begin();
i != this->IncludePath.end(); ++i) { i != this->IncludePath.end(); ++i) {
fullName = *i; fullName = *i;
fullName += "/"; fullName += "/";
@ -45,7 +44,6 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
return true; return true;
} }
} }
}
return false; return false;
} }
@ -88,9 +86,8 @@ bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname)
cmFortran_yy_switch_to_buffer(buffer, parser->Scanner); cmFortran_yy_switch_to_buffer(buffer, parser->Scanner);
parser->FileStack.push(f); parser->FileStack.push(f);
return 1; return 1;
} else {
return 0;
} }
return 0;
} }
bool cmFortranParser_FilePop(cmFortranParser* parser) bool cmFortranParser_FilePop(cmFortranParser* parser)
@ -99,7 +96,7 @@ bool cmFortranParser_FilePop(cmFortranParser* parser)
// to the next one on the stack. // to the next one on the stack.
if (parser->FileStack.empty()) { if (parser->FileStack.empty()) {
return 0; return 0;
} else { }
cmFortranFile f = parser->FileStack.top(); cmFortranFile f = parser->FileStack.top();
parser->FileStack.pop(); parser->FileStack.pop();
fclose(f.File); fclose(f.File);
@ -108,7 +105,6 @@ bool cmFortranParser_FilePop(cmFortranParser* parser)
cmFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner); cmFortran_yy_switch_to_buffer(f.Buffer, parser->Scanner);
return 1; return 1;
} }
}
int cmFortranParser_Input(cmFortranParser* parser, char* buffer, int cmFortranParser_Input(cmFortranParser* parser, char* buffer,
size_t bufferSize) size_t bufferSize)

View File

@ -352,7 +352,8 @@ std::string cmGeneratorExpression::Preprocess(const std::string& input,
{ {
if (context == StripAllGeneratorExpressions) { if (context == StripAllGeneratorExpressions) {
return stripAllGeneratorExpressions(input); return stripAllGeneratorExpressions(input);
} else if (context == BuildInterface || context == InstallInterface) { }
if (context == BuildInterface || context == InstallInterface) {
return stripExportInterface(input, context, resolveRelative); return stripExportInterface(input, context, resolveRelative);
} }

View File

@ -154,12 +154,12 @@ std::string GeneratorExpressionContent::EvaluateParameters(
node, identifier, context, dagChecker, pit); node, identifier, context, dagChecker, pit);
parameters.push_back(lastParam); parameters.push_back(lastParam);
return std::string(); return std::string();
} else { }
std::string parameter; std::string parameter;
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it = std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
pit->begin(); pit->begin();
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
end = pit->end(); pit->end();
for (; it != end; ++it) { for (; it != end; ++it) {
parameter += (*it)->Evaluate(context, dagChecker); parameter += (*it)->Evaluate(context, dagChecker);
if (context->HadError) { if (context->HadError) {
@ -169,7 +169,6 @@ std::string GeneratorExpressionContent::EvaluateParameters(
parameters.push_back(parameter); parameters.push_back(parameter);
} }
} }
}
if ((numExpected > cmGeneratorExpressionNode::DynamicParameters && if ((numExpected > cmGeneratorExpressionNode::DynamicParameters &&
(unsigned int)numExpected != parameters.size())) { (unsigned int)numExpected != parameters.size())) {

View File

@ -92,7 +92,8 @@ static const struct ZeroNode installInterfaceNode;
for (; it != end; ++it) { \ for (; it != end; ++it) { \
if (*it == #FAILURE_VALUE) { \ if (*it == #FAILURE_VALUE) { \
return #FAILURE_VALUE; \ return #FAILURE_VALUE; \
} else if (*it != #SUCCESS_VALUE) { \ } \
if (*it != #SUCCESS_VALUE) { \
reportError(context, content->GetOriginalExpression(), \ reportError(context, content->GetOriginalExpression(), \
"Parameters to $<" #OP \ "Parameters to $<" #OP \
"> must resolve to either '0' or '1'."); \ "> 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 " "$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
"generators."); "generators.");
return std::string(); return std::string();
} else if (genName.find("Xcode") != std::string::npos) { }
if (genName.find("Xcode") != std::string::npos) {
if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() || if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
dagChecker->EvaluatingIncludeDirectories())) { dagChecker->EvaluatingIncludeDirectories())) {
reportError( reportError(

View File

@ -361,10 +361,9 @@ const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const
if (implib) { if (implib) {
// A DLL import library is treated as an archive target. // A DLL import library is treated as an archive target.
return "ARCHIVE"; return "ARCHIVE";
} else { }
// A DLL shared library is treated as a runtime target. // A DLL shared library is treated as a runtime target.
return "RUNTIME"; return "RUNTIME";
}
} else { } else {
// For non-DLL platforms shared libraries are treated as // For non-DLL platforms shared libraries are treated as
// library targets. // library targets.
@ -1324,17 +1323,15 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const
// The imported library has no builtin soname so the name // The imported library has no builtin soname so the name
// searched at runtime will be just the filename. // searched at runtime will be just the filename.
return cmSystemTools::GetFilenameName(info->Location); return cmSystemTools::GetFilenameName(info->Location);
} else { }
// Use the soname given if any. // Use the soname given if any.
if (info->SOName.find("@rpath/") == 0) { if (info->SOName.find("@rpath/") == 0) {
return info->SOName.substr(6); return info->SOName.substr(6);
} }
return info->SOName; return info->SOName;
} }
} else {
return ""; return "";
} }
} else {
// Compute the soname that will be built. // Compute the soname that will be built.
std::string name; std::string name;
std::string soName; std::string soName;
@ -1344,7 +1341,6 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const
this->GetLibraryNames(name, soName, realName, impName, pdbName, config); this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
return soName; return soName;
} }
}
std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config,
bool contentOnly) const bool contentOnly) const
@ -1418,9 +1414,8 @@ std::string cmGeneratorTarget::GetFullName(const std::string& config,
{ {
if (this->IsImported()) { if (this->IsImported()) {
return this->GetFullNameImported(config, implib); return this->GetFullNameImported(config, implib);
} else {
return this->GetFullNameInternal(config, implib);
} }
return this->GetFullNameInternal(config, implib);
} }
std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
@ -1444,9 +1439,8 @@ std::string cmGeneratorTarget::GetInstallNameDirForBuildTree(
} }
dir += "/"; dir += "/";
return dir; return dir;
} else {
return "";
} }
return "";
} }
std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
@ -1468,9 +1462,8 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
} }
} }
return dir; return dir;
} else {
return "";
} }
return "";
} }
cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
@ -1516,9 +1509,8 @@ const char* cmGeneratorTarget::GetExportMacro() const
this->ExportMacro = cmSystemTools::MakeCidentifier(in); this->ExportMacro = cmSystemTools::MakeCidentifier(in);
} }
return this->ExportMacro.c_str(); return this->ExportMacro.c_str();
} else {
return CM_NULLPTR;
} }
return CM_NULLPTR;
} }
class cmTargetCollectLinkLanguages class cmTargetCollectLinkLanguages
@ -1642,7 +1634,8 @@ public:
{ {
if (this->Preferred.empty()) { if (this->Preferred.empty()) {
return ""; return "";
} else if (this->Preferred.size() > 1) { }
if (this->Preferred.size() > 1) {
std::ostringstream e; std::ostringstream e;
e << "Target " << this->Target->GetName() e << "Target " << this->Target->GetName()
<< " contains multiple languages with the highest linker preference" << " contains multiple languages with the highest linker preference"
@ -2723,9 +2716,8 @@ std::string cmGeneratorTarget::GetFullPath(const std::string& config,
{ {
if (this->IsImported()) { if (this->IsImported()) {
return this->Target->ImportedGetFullPath(config, implib); 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, std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config,
@ -2770,7 +2762,7 @@ std::string cmGeneratorTarget::NormalGetRealName(
std::string pdbName; std::string pdbName;
this->GetExecutableNames(name, realName, impName, pdbName, config); this->GetExecutableNames(name, realName, impName, pdbName, config);
return realName; return realName;
} else { }
// Compute the real name that will be built. // Compute the real name that will be built.
std::string name; std::string name;
std::string soName; std::string soName;
@ -2780,7 +2772,6 @@ std::string cmGeneratorTarget::NormalGetRealName(
this->GetLibraryNames(name, soName, realName, impName, pdbName, config); this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
return realName; return realName;
} }
}
void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
std::string& realName, std::string& realName,
@ -3587,9 +3578,8 @@ std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
if (t == NumberMaxType) { if (t == NumberMaxType) {
return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); 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 <> template <>
@ -3906,11 +3896,11 @@ std::string cmGeneratorTarget::GetFrameworkVersion() const
if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) { if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) {
return fversion; return fversion;
} else if (const char* tversion = this->GetProperty("VERSION")) {
return tversion;
} else {
return "A";
} }
if (const char* tversion = this->GetProperty("VERSION")) {
return tversion;
}
return "A";
} }
void cmGeneratorTarget::ComputeVersionedName(std::string& vName, 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 the directory from which the target is imported.
return cmSystemTools::GetFilenamePath( return cmSystemTools::GetFilenamePath(
this->Target->ImportedGetFullPath(config, implib)); 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 the directory in which the target will be built.
return implib ? info->ImpDir : info->OutDir; return implib ? info->ImpDir : info->OutDir;
} }

View File

@ -93,13 +93,12 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string& ident,
names << "ident" << VarNum++; names << "ident" << VarNum++;
vars << names.str() << " = " << ident << "\n"; vars << names.str() << " = " << ident << "\n";
return "$" + names.str(); return "$" + names.str();
} else { }
std::string result = ident; std::string result = ident;
cmSystemTools::ReplaceString(result, " ", "$ "); cmSystemTools::ReplaceString(result, " ", "$ ");
cmSystemTools::ReplaceString(result, ":", "$:"); cmSystemTools::ReplaceString(result, ":", "$:");
return result; return result;
} }
}
std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit) std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit)
{ {

View File

@ -63,9 +63,8 @@ void cmInstallExportGenerator::ComputeTempDir()
this->TempDir += "/Export"; this->TempDir += "/Export";
if (this->Destination.empty()) { if (this->Destination.empty()) {
return; return;
} else {
this->TempDir += "/";
} }
this->TempDir += "/";
// Enforce a maximum length. // Enforce a maximum length.
bool useMD5 = false; bool useMD5 = false;

View File

@ -259,11 +259,10 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
if (isError) { if (isError) {
this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
return false; return false;
} else { }
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str()); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
return true; return true;
} }
}
struct cmListFileBacktrace::Entry : public cmListFileContext struct cmListFileBacktrace::Entry : public cmListFileContext
{ {
@ -377,11 +376,10 @@ cmListFileContext const& cmListFileBacktrace::Top() const
{ {
if (this->Cur) { if (this->Cur) {
return *this->Cur; return *this->Cur;
} else { }
static cmListFileContext const empty; static cmListFileContext const empty;
return empty; return empty;
} }
}
void cmListFileBacktrace::PrintTitle(std::ostream& out) const void cmListFileBacktrace::PrintTitle(std::ostream& out) const
{ {

View File

@ -626,16 +626,14 @@ std::string cmLocalGenerator::ExpandRuleVariable(
if (variable == "TARGET_VERSION_MAJOR") { if (variable == "TARGET_VERSION_MAJOR") {
if (replaceValues.TargetVersionMajor) { if (replaceValues.TargetVersionMajor) {
return replaceValues.TargetVersionMajor; return replaceValues.TargetVersionMajor;
} else {
return "0";
} }
return "0";
} }
if (variable == "TARGET_VERSION_MINOR") { if (variable == "TARGET_VERSION_MINOR") {
if (replaceValues.TargetVersionMinor) { if (replaceValues.TargetVersionMinor) {
return replaceValues.TargetVersionMinor; return replaceValues.TargetVersionMinor;
} else {
return "0";
} }
return "0";
} }
if (replaceValues.Target) { if (replaceValues.Target) {
if (variable == "TARGET_BASE") { if (variable == "TARGET_BASE") {
@ -644,9 +642,8 @@ std::string cmLocalGenerator::ExpandRuleVariable(
std::string::size_type pos = targetBase.rfind('.'); std::string::size_type pos = targetBase.rfind('.');
if (pos != targetBase.npos) { if (pos != targetBase.npos) {
return targetBase.substr(0, pos); return targetBase.substr(0, pos);
} else {
return targetBase;
} }
return targetBase;
} }
} }
} }
@ -813,9 +810,8 @@ const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
{ {
if (target) { if (target) {
return target->GetProperty(prop); return target->GetProperty(prop);
} else {
return this->Makefile->GetProperty(prop);
} }
return this->Makefile->GetProperty(prop);
} }
void cmLocalGenerator::InsertRuleLauncher(std::string& s, void cmLocalGenerator::InsertRuleLauncher(std::string& s,
@ -2365,11 +2361,10 @@ static bool cmLocalGeneratorShortenObjectName(std::string& objName,
// The object name is now short enough. // The object name is now short enough.
return true; return true;
} else { }
// The object name could not be shortened enough. // The object name could not be shortened enough.
return false; return false;
} }
}
bool cmLocalGeneratorCheckObjectName(std::string& objName, bool cmLocalGeneratorCheckObjectName(std::string& objName,
std::string::size_type dir_len, std::string::size_type dir_len,
@ -2382,16 +2377,14 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName,
if (objName.size() > max_obj_len) { if (objName.size() > max_obj_len) {
// The current object file name is too long. Try to shorten it. // The current object file name is too long. Try to shorten it.
return cmLocalGeneratorShortenObjectName(objName, max_obj_len); return cmLocalGeneratorShortenObjectName(objName, max_obj_len);
} else { }
// The object file name is short enough. // The object file name is short enough.
return true; return true;
} }
} else {
// The build directory in which the object will be stored is // The build directory in which the object will be stored is
// already too deep. // already too deep.
return false; return false;
} }
}
#endif #endif
std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName( std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName(

View File

@ -813,11 +813,10 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
// The existing custom command is identical. Silently ignore // The existing custom command is identical. Silently ignore
// the duplicate. // the duplicate.
return file; return file;
} else { }
// The existing custom command is different. We need to // The existing custom command is different. We need to
// generate a rule file for this new command. // generate a rule file for this new command.
file = CM_NULLPTR; file = CM_NULLPTR;
}
} else if (!file) { } else if (!file) {
file = this->CreateSource(main_dependency); file = this->CreateSource(main_dependency);
} }
@ -2029,7 +2028,8 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
sg->SetGroupRegex(regex); sg->SetGroupRegex(regex);
} }
return; return;
} else if (i == -1) { }
if (i == -1) {
// group does not exist nor belong to any existing group // group does not exist nor belong to any existing group
// add its first component // add its first component
this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex)); this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex));
@ -2817,14 +2817,13 @@ std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
cmSystemTools::ExpandListArgument(configTypes, configs); cmSystemTools::ExpandListArgument(configTypes, configs);
} }
return ""; return "";
} else { }
const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
if (singleConfig && !buildType.empty()) { if (singleConfig && !buildType.empty()) {
configs.push_back(buildType); configs.push_back(buildType);
} }
return buildType; return buildType;
} }
}
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)
/** /**
@ -3129,9 +3128,8 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
{ {
if (cmSourceFile* esf = this->GetSource(sourceName)) { if (cmSourceFile* esf = this->GetSource(sourceName)) {
return esf; return esf;
} else {
return this->CreateSource(sourceName, generated);
} }
return this->CreateSource(sourceName, generated);
} }
void cmMakefile::EnableLanguage(std::vector<std::string> const& lang, void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
@ -3756,12 +3754,11 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
<< "\" because an imported target with the same name already exists."; << "\" because an imported target with the same name already exists.";
msg = e.str(); msg = e.str();
return false; return false;
} else { }
// target names must be globally unique // target names must be globally unique
switch (this->GetPolicyStatus(cmPolicies::CMP0002)) { switch (this->GetPolicyStatus(cmPolicies::CMP0002)) {
case cmPolicies::WARN: case cmPolicies::WARN:
this->IssueMessage( this->IssueMessage(cmake::AUTHOR_WARNING,
cmake::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0002)); cmPolicies::GetPolicyWarning(cmPolicies::CMP0002));
case cmPolicies::OLD: case cmPolicies::OLD:
return true; return true;
@ -3819,7 +3816,6 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
msg = e.str(); msg = e.str();
return false; return false;
} }
}
return true; return true;
} }
@ -4246,15 +4242,15 @@ bool cmMakefile::HaveCStandardAvailable(cmTarget const* target,
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS), existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
cmArrayEnd(C_STANDARDS), cmStrCmp("11"))) { cmArrayEnd(C_STANDARDS), cmStrCmp("11"))) {
return false; return false;
} else if (needC99 && existingCStandard && }
if (needC99 && existingCStandard &&
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS), existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
cmArrayEnd(C_STANDARDS), cmArrayEnd(C_STANDARDS), cmStrCmp("99"))) {
cmStrCmp("99"))) {
return false; return false;
} else if (needC90 && existingCStandard && }
if (needC90 && existingCStandard &&
existingCIt < std::find_if(cmArrayBegin(C_STANDARDS), existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
cmArrayEnd(C_STANDARDS), cmArrayEnd(C_STANDARDS), cmStrCmp("90"))) {
cmStrCmp("90"))) {
return false; return false;
} }
return true; return true;
@ -4332,7 +4328,8 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
cmArrayEnd(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
cmStrCmp("11"))) { cmStrCmp("11"))) {
return false; return false;
} else if (needCxx98 && }
if (needCxx98 &&
existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS), existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
cmArrayEnd(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
cmStrCmp("98"))) { cmStrCmp("98"))) {

View File

@ -34,21 +34,20 @@ bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args,
if (eol == "LF" || eol == "UNIX") { if (eol == "LF" || eol == "UNIX") {
NewLineStyle = LF; NewLineStyle = LF;
return true; return true;
} else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") { }
if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") {
NewLineStyle = CRLF; NewLineStyle = CRLF;
return true; return true;
} else { }
errorString = "NEWLINE_STYLE sets an unknown style, only LF, " errorString = "NEWLINE_STYLE sets an unknown style, only LF, "
"CRLF, UNIX, DOS, and WIN32 are supported"; "CRLF, UNIX, DOS, and WIN32 are supported";
return false; return false;
} }
} else {
errorString = "NEWLINE_STYLE must set a style: " errorString = "NEWLINE_STYLE must set a style: "
"LF, CRLF, UNIX, DOS, or WIN32"; "LF, CRLF, UNIX, DOS, or WIN32";
return false; return false;
} }
} }
}
return true; return true;
} }

View File

@ -347,7 +347,8 @@ static std::string GetRccExecutable(cmGeneratorTarget const* target)
return std::string(); return std::string();
} }
return qt5Rcc->ImportedGetLocation(""); return qt5Rcc->ImportedGetLocation("");
} else if (strcmp(qtVersion, "4") == 0) { }
if (strcmp(qtVersion, "4") == 0) {
cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc"); cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc");
if (!qt4Rcc) { if (!qt4Rcc) {
cmSystemTools::Error("Qt4::rcc target not found ", targetName.c_str()); cmSystemTools::Error("Qt4::rcc target not found ", targetName.c_str());

View File

@ -295,9 +295,8 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
if (prop == "LOCATION") { if (prop == "LOCATION") {
if (this->FullPath.empty()) { if (this->FullPath.empty()) {
return CM_NULLPTR; return CM_NULLPTR;
} else {
return this->FullPath.c_str();
} }
return this->FullPath.c_str();
} }
const char* retVal = this->Properties.GetPropertyValue(prop); const char* retVal = this->Properties.GetPropertyValue(prop);

View File

@ -1702,7 +1702,8 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
return parent.GetDirectory().GetCurrentSource(); return parent.GetDirectory().GetCurrentSource();
} }
return ""; return "";
} else if (prop == "LISTFILE_STACK") { }
if (prop == "LISTFILE_STACK") {
std::vector<std::string> listFiles; std::vector<std::string> listFiles;
cmState::Snapshot snp = this->Snapshot_; cmState::Snapshot snp = this->Snapshot_;
while (snp.IsValid()) { while (snp.IsValid()) {
@ -1712,10 +1713,12 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
std::reverse(listFiles.begin(), listFiles.end()); std::reverse(listFiles.begin(), listFiles.end());
output = cmJoin(listFiles, ";"); output = cmJoin(listFiles, ";");
return output.c_str(); return output.c_str();
} else if (prop == "CACHE_VARIABLES") { }
if (prop == "CACHE_VARIABLES") {
output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";"); output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";");
return output.c_str(); return output.c_str();
} else if (prop == "VARIABLES") { }
if (prop == "VARIABLES") {
std::vector<std::string> res = this->Snapshot_.ClosureKeys(); std::vector<std::string> res = this->Snapshot_.ClosureKeys();
std::vector<std::string> cacheKeys = std::vector<std::string> cacheKeys =
this->Snapshot_.State->GetCacheEntryKeys(); this->Snapshot_.State->GetCacheEntryKeys();
@ -1723,13 +1726,16 @@ const char* cmState::Directory::GetProperty(const std::string& prop,
std::sort(res.begin(), res.end()); std::sort(res.begin(), res.end());
output = cmJoin(res, ";"); output = cmJoin(res, ";");
return output.c_str(); return output.c_str();
} else if (prop == "INCLUDE_DIRECTORIES") { }
if (prop == "INCLUDE_DIRECTORIES") {
output = cmJoin(this->GetIncludeDirectoriesEntries(), ";"); output = cmJoin(this->GetIncludeDirectoriesEntries(), ";");
return output.c_str(); return output.c_str();
} else if (prop == "COMPILE_OPTIONS") { }
if (prop == "COMPILE_OPTIONS") {
output = cmJoin(this->GetCompileOptionsEntries(), ";"); output = cmJoin(this->GetCompileOptionsEntries(), ";");
return output.c_str(); return output.c_str();
} else if (prop == "COMPILE_DEFINITIONS") { }
if (prop == "COMPILE_DEFINITIONS") {
output = cmJoin(this->GetCompileDefinitionsEntries(), ";"); output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
return output.c_str(); return output.c_str();
} }

View File

@ -333,9 +333,8 @@ void cmSystemTools::Message(const char* m1, const char* title)
(*s_MessageCallback)(m1, title, s_DisableMessages, (*s_MessageCallback)(m1, title, s_DisableMessages,
s_MessageCallbackClientData); s_MessageCallbackClientData);
return; return;
} else {
std::cerr << m1 << std::endl << std::flush;
} }
std::cerr << m1 << std::endl << std::flush;
} }
void cmSystemTools::ReportLastSystemError(const char* msg) void cmSystemTools::ReportLastSystemError(const char* msg)
@ -1688,7 +1687,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
if (pipe == cmsysProcess_Pipe_Timeout) { if (pipe == cmsysProcess_Pipe_Timeout) {
// Timeout has been exceeded. // Timeout has been exceeded.
return pipe; return pipe;
} else if (pipe == cmsysProcess_Pipe_STDOUT) { }
if (pipe == cmsysProcess_Pipe_STDOUT) {
// Append to the stdout buffer. // Append to the stdout buffer.
std::vector<char>::size_type size = out.size(); std::vector<char>::size_type size = out.size();
out.insert(out.end(), data, data + length); 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()); line.append(&out[0], outiter - out.begin());
out.erase(out.begin(), out.end()); out.erase(out.begin(), out.end());
return cmsysProcess_Pipe_STDOUT; return cmsysProcess_Pipe_STDOUT;
} else if (!err.empty()) { }
if (!err.empty()) {
line.append(&err[0], erriter - err.begin()); line.append(&err[0], erriter - err.begin());
err.erase(err.begin(), err.end()); err.erase(err.begin(), err.end());
return cmsysProcess_Pipe_STDERR; return cmsysProcess_Pipe_STDERR;
} else {
return cmsysProcess_Pipe_None;
} }
return cmsysProcess_Pipe_None;
} }
} }
} }
@ -2218,14 +2218,13 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// The new rpath is empty and there is no rpath anyway so it is // The new rpath is empty and there is no rpath anyway so it is
// okay. // okay.
return true; return true;
} else { }
if (emsg) { if (emsg) {
*emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; "; *emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; ";
*emsg += elf.GetErrorMessage(); *emsg += elf.GetErrorMessage();
} }
return false; return false;
} }
}
for (int i = 0; i < se_count; ++i) { for (int i = 0; i < se_count; ++i) {
// If both RPATH and RUNPATH refer to the same string literal it // If both RPATH and RUNPATH refer to the same string literal it
@ -2382,7 +2381,8 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
if (lhs < rhs) { if (lhs < rhs) {
// lhs < rhs, so true if operation is LESS // lhs < rhs, so true if operation is LESS
return (op & cmSystemTools::OP_LESS) != 0; return (op & cmSystemTools::OP_LESS) != 0;
} else if (lhs > rhs) { }
if (lhs > rhs) {
// lhs > rhs, so true if operation is GREATER // lhs > rhs, so true if operation is GREATER
return (op & cmSystemTools::OP_GREATER) != 0; return (op & cmSystemTools::OP_GREATER) != 0;
} }

View File

@ -774,12 +774,14 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
<< prop << "\" is not allowed."; << prop << "\" is not allowed.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return; return;
} else if (prop == "NAME") { }
if (prop == "NAME") {
std::ostringstream e; std::ostringstream e;
e << "NAME property is read-only\n"; e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return; return;
} else if (prop == "INCLUDE_DIRECTORIES") { }
if (prop == "INCLUDE_DIRECTORIES") {
this->Internal->IncludeDirectoriesEntries.clear(); this->Internal->IncludeDirectoriesEntries.clear();
this->Internal->IncludeDirectoriesBacktraces.clear(); this->Internal->IncludeDirectoriesBacktraces.clear();
if (value) { if (value) {
@ -856,12 +858,14 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
<< prop << "\" is not allowed."; << prop << "\" is not allowed.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return; return;
} else if (prop == "NAME") { }
if (prop == "NAME") {
std::ostringstream e; std::ostringstream e;
e << "NAME property is read-only\n"; e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return; return;
} else if (prop == "INCLUDE_DIRECTORIES") { }
if (prop == "INCLUDE_DIRECTORIES") {
if (value && *value) { if (value && *value) {
this->Internal->IncludeDirectoriesEntries.push_back(value); this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
@ -1230,9 +1234,10 @@ const char* cmTarget::GetProperty(const std::string& prop,
return output.c_str(); return output.c_str();
} }
// the type property returns what type the target is // the type property returns what type the target is
else if (prop == propTYPE) { if (prop == propTYPE) {
return cmState::GetTargetTypeName(this->GetType()); return cmState::GetTargetTypeName(this->GetType());
} else if (prop == propINCLUDE_DIRECTORIES) { }
if (prop == propINCLUDE_DIRECTORIES) {
if (this->Internal->IncludeDirectoriesEntries.empty()) { if (this->Internal->IncludeDirectoriesEntries.empty()) {
return CM_NULLPTR; return CM_NULLPTR;
} }
@ -1240,7 +1245,8 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output; static std::string output;
output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";"); output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";");
return output.c_str(); return output.c_str();
} else if (prop == propCOMPILE_FEATURES) { }
if (prop == propCOMPILE_FEATURES) {
if (this->Internal->CompileFeaturesEntries.empty()) { if (this->Internal->CompileFeaturesEntries.empty()) {
return CM_NULLPTR; return CM_NULLPTR;
} }
@ -1248,7 +1254,8 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output; static std::string output;
output = cmJoin(this->Internal->CompileFeaturesEntries, ";"); output = cmJoin(this->Internal->CompileFeaturesEntries, ";");
return output.c_str(); return output.c_str();
} else if (prop == propCOMPILE_OPTIONS) { }
if (prop == propCOMPILE_OPTIONS) {
if (this->Internal->CompileOptionsEntries.empty()) { if (this->Internal->CompileOptionsEntries.empty()) {
return CM_NULLPTR; return CM_NULLPTR;
} }
@ -1256,7 +1263,8 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output; static std::string output;
output = cmJoin(this->Internal->CompileOptionsEntries, ";"); output = cmJoin(this->Internal->CompileOptionsEntries, ";");
return output.c_str(); return output.c_str();
} else if (prop == propCOMPILE_DEFINITIONS) { }
if (prop == propCOMPILE_DEFINITIONS) {
if (this->Internal->CompileDefinitionsEntries.empty()) { if (this->Internal->CompileDefinitionsEntries.empty()) {
return CM_NULLPTR; return CM_NULLPTR;
} }
@ -1264,15 +1272,20 @@ const char* cmTarget::GetProperty(const std::string& prop,
static std::string output; static std::string output;
output = cmJoin(this->Internal->CompileDefinitionsEntries, ";"); output = cmJoin(this->Internal->CompileDefinitionsEntries, ";");
return output.c_str(); return output.c_str();
} else if (prop == propIMPORTED) { }
if (prop == propIMPORTED) {
return this->IsImported() ? "TRUE" : "FALSE"; return this->IsImported() ? "TRUE" : "FALSE";
} else if (prop == propNAME) { }
if (prop == propNAME) {
return this->GetName().c_str(); return this->GetName().c_str();
} else if (prop == propBINARY_DIR) { }
if (prop == propBINARY_DIR) {
return this->GetMakefile()->GetCurrentBinaryDirectory(); return this->GetMakefile()->GetCurrentBinaryDirectory();
} else if (prop == propSOURCE_DIR) { }
if (prop == propSOURCE_DIR) {
return this->GetMakefile()->GetCurrentSourceDirectory(); return this->GetMakefile()->GetCurrentSourceDirectory();
} else if (prop == propSOURCES) { }
if (prop == propSOURCES) {
if (this->Internal->SourceEntries.empty()) { if (this->Internal->SourceEntries.empty()) {
return CM_NULLPTR; return CM_NULLPTR;
} }

View File

@ -180,13 +180,14 @@ bool cmUuid::IntFromHexDigit(char input, char& output) const
if (input >= '0' && input <= '9') { if (input >= '0' && input <= '9') {
output = char(input - '0'); output = char(input - '0');
return true; return true;
} else if (input >= 'a' && input <= 'f') { }
if (input >= 'a' && input <= 'f') {
output = char(input - 'a' + 0xA); output = char(input - 'a' + 0xA);
return true; return true;
} else if (input >= 'A' && input <= 'F') { }
if (input >= 'A' && input <= 'F') {
output = char(input - 'A' + 0xA); output = char(input - 'A' + 0xA);
return true; return true;
} else { }
return false; return false;
} }
}

View File

@ -1513,9 +1513,8 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
if (this->GetWorkingMode() != NORMAL_MODE) { if (this->GetWorkingMode() != NORMAL_MODE) {
if (cmSystemTools::GetErrorOccuredFlag()) { if (cmSystemTools::GetErrorOccuredFlag()) {
return -1; return -1;
} else {
return 0;
} }
return 0;
} }
// If MAKEFLAGS are given in the environment, remove the environment // If MAKEFLAGS are given in the environment, remove the environment
@ -2063,12 +2062,11 @@ cmInstalledFile* cmake::GetOrCreateInstalledFile(cmMakefile* mf,
if (i != this->InstalledFiles.end()) { if (i != this->InstalledFiles.end()) {
cmInstalledFile& file = i->second; cmInstalledFile& file = i->second;
return &file; return &file;
} else { }
cmInstalledFile& file = this->InstalledFiles[name]; cmInstalledFile& file = this->InstalledFiles[name];
file.SetName(mf, name); file.SetName(mf, name);
return &file; return &file;
} }
}
cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const 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()) { if (i != this->InstalledFiles.end()) {
cmInstalledFile const& file = i->second; cmInstalledFile const& file = i->second;
return &file; return &file;
} else {
return CM_NULLPTR;
} }
return CM_NULLPTR;
} }
int cmake::GetSystemInformation(std::vector<std::string>& args) int cmake::GetSystemInformation(std::vector<std::string>& args)
@ -2253,12 +2250,11 @@ static bool cmakeCheckStampFile(const char* stampName)
std::cout << "CMake does not need to re-run because " << stampName std::cout << "CMake does not need to re-run because " << stampName
<< " is up-to-date.\n"; << " is up-to-date.\n";
return true; return true;
} else { }
cmSystemTools::RemoveFile(stampTemp); cmSystemTools::RemoveFile(stampTemp);
cmSystemTools::Error("Cannot restore timestamp ", stampName); cmSystemTools::Error("Cannot restore timestamp ", stampName);
return false; return false;
} }
}
static bool cmakeCheckStampList(const char* stampList) static bool cmakeCheckStampList(const char* stampList)
{ {

View File

@ -163,7 +163,8 @@ int main(int ac, char const* const* av)
if (ac > 1) { if (ac > 1) {
if (strcmp(av[1], "--build") == 0) { if (strcmp(av[1], "--build") == 0) {
return do_build(ac, av); return do_build(ac, av);
} else if (strcmp(av[1], "-E") == 0) { }
if (strcmp(av[1], "-E") == 0) {
return do_command(ac, av); 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"; "Use cmake-gui or ccmake for an interactive dialog.\n";
/* clang-format on */ /* clang-format on */
return 1; return 1;
} else if (strcmp(av[i], "--system-information") == 0) { }
if (strcmp(av[i], "--system-information") == 0) {
sysinfo = true; sysinfo = true;
} else if (strcmp(av[i], "-N") == 0) { } else if (strcmp(av[i], "-N") == 0) {
view_only = true; view_only = true;
@ -313,9 +315,8 @@ int do_cmake(int ac, char const* const* av)
// interpret negative return values as errors. // interpret negative return values as errors.
if (res != 0) { if (res != 0) {
return 1; return 1;
} else {
return 0;
} }
return 0;
} }
static int do_build(int ac, char const* const* av) static int do_build(int ac, char const* const* av)

View File

@ -262,7 +262,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// run include what you use command and then run the compile // run include what you use command and then run the compile
// command. This is an internal undocumented option and should // command. This is an internal undocumented option and should
// only be used by CMake itself when running iwyu. // only be used by CMake itself when running iwyu.
else if (args[1] == "__run_iwyu") { if (args[1] == "__run_iwyu") {
if (args.size() < 3) { if (args.size() < 3) {
std::cerr << "__run_iwyu Usage: -E __run_iwyu [--iwyu=/path/iwyu]" std::cerr << "__run_iwyu Usage: -E __run_iwyu [--iwyu=/path/iwyu]"
" [--tidy=/path/tidy] -- compile command\n"; " [--tidy=/path/tidy] -- compile command\n";
@ -393,13 +393,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
} }
// Echo string // Echo string
else if (args[1] == "echo") { if (args[1] == "echo") {
std::cout << cmJoin(cmMakeRange(args).advance(2), " ") << std::endl; std::cout << cmJoin(cmMakeRange(args).advance(2), " ") << std::endl;
return 0; return 0;
} }
// Echo string no new line // Echo string no new line
else if (args[1] == "echo_append") { if (args[1] == "echo_append") {
std::cout << cmJoin(cmMakeRange(args).advance(2), " "); std::cout << cmJoin(cmMakeRange(args).advance(2), " ");
return 0; return 0;
} }
@ -851,7 +851,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmSystemTools::Error("Can not use compression flags with format: ", cmSystemTools::Error("Can not use compression flags with format: ",
format.c_str()); format.c_str());
return 1; return 1;
} else if (nCompress > 1) { }
if (nCompress > 1) {
cmSystemTools::Error("Can only compress a tar file one way; " cmSystemTools::Error("Can only compress a tar file one way; "
"at most one flag of z, j, or J may be used"); "at most one flag of z, j, or J may be used");
return 1; return 1;
@ -995,12 +996,12 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num)
int count = 0; int count = 0;
if (!progFile) { if (!progFile) {
return; return;
} else { }
if (1 != fscanf(progFile, "%i", &count)) { if (1 != fscanf(progFile, "%i", &count)) {
cmSystemTools::Message("Could not read from progress file."); cmSystemTools::Message("Could not read from progress file.");
} }
fclose(progFile); fclose(progFile);
}
const char* last = num.c_str(); const char* last = num.c_str();
for (const char* c = last;; ++c) { for (const char* c = last;; ++c) {
if (*c == ',' || *c == '\0') { if (*c == ',' || *c == '\0') {