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,10 +231,8 @@ int cmCPackArchiveGenerator::PackageFiles()
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
else {
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
}
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
}
// CASE 3 : NON COMPONENT package.

View File

@ -242,15 +242,11 @@ int cmCPackDebGenerator::PackageFiles()
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
else {
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
}
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
}
// CASE 3 : NON COMPONENT package.
else {
return PackageComponentsAllInOne("");
}
return PackageComponentsAllInOne("");
}
int cmCPackDebGenerator::createDeb()
@ -694,9 +690,8 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (CM_NULLPTR != GetOption(groupVar)) {
return std::string(GetOption(groupVar));
} else {
return componentName;
}
return componentName;
}
// 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 '"
<< Name << "' generator does NOT support it." << std::endl);
return 0;
} else if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) {
}
if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) {
cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPACK_SET_DESTDIR is set to ON but it is "
<< "usually a bad idea to do that with '" << Name

View File

@ -215,15 +215,11 @@ int cmCPackRPMGenerator::PackageFiles()
// There will be 1 package for each component group
// however one may require to ignore component group and
// in this case you'll get 1 package for each component.
else {
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
}
return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT);
}
// CASE 3 : NON COMPONENT package.
else {
return PackageComponentsAllInOne("");
}
return PackageComponentsAllInOne("");
}
bool cmCPackRPMGenerator::SupportsComponentInstallation() const
@ -247,7 +243,6 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (CM_NULLPTR != 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) &&
result != 0) {
return result < 0;
} else {
return l < r;
}
return l < r;
}
private:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -54,7 +54,8 @@ bool cmCTestRunTest::CheckOutput()
if (p == cmsysProcess_Pipe_None) {
// Process has terminated and all output read.
return false;
} else if (p == cmsysProcess_Pipe_STDOUT) {
}
if (p == cmsysProcess_Pipe_STDOUT) {
// Store this line of output.
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
<< ": " << line << std::endl);
@ -82,8 +83,7 @@ bool cmCTestRunTest::CheckOutput()
}
}
}
} else // if(p == cmsysProcess_Pipe_Timeout)
{
} else { // if(p == cmsysProcess_Pipe_Timeout)
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?
if (p1.size() == p2.size()) {
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)
@ -295,9 +295,8 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
if (strcmp(parameters[0], "update") == 0) {
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,

View File

@ -284,14 +284,13 @@ inline int GetNextNumber(std::string const& in, int& val,
}
pos = pos2 + 1;
return 1;
} else {
if (in.size() - pos == 0) {
val = -1;
} else {
val = atoi(in.substr(pos, in.size() - pos).c_str());
}
return 0;
}
if (in.size() - pos == 0) {
val = -1;
} else {
val = atoi(in.substr(pos, in.size() - pos).c_str());
}
return 0;
}
// get the next number in a string with numbers separated by ,
@ -311,14 +310,13 @@ inline int GetNextRealNumber(std::string const& in, double& val,
}
pos = pos2 + 1;
return 1;
} else {
if (in.size() - pos == 0) {
val = -1;
} else {
val = atof(in.substr(pos, in.size() - pos).c_str());
}
return 0;
}
if (in.size() - pos == 0) {
val = -1;
} else {
val = atof(in.substr(pos, in.size() - pos).c_str());
}
return 0;
}
cmCTestTestHandler::cmCTestTestHandler()

View File

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

View File

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

View File

@ -128,16 +128,15 @@ bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
if (i != this->RoutineToDirectory.end()) {
filepath = i->second;
return true;
} else {
// try some alternate names
const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR };
for (int k = 0; tryname[k] != CM_NULLPTR; k++) {
std::string routine2 = routine + tryname[k];
i = this->RoutineToDirectory.find(routine2);
if (i != this->RoutineToDirectory.end()) {
filepath = i->second;
return true;
}
}
// try some alternate names
const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR };
for (int k = 0; tryname[k] != CM_NULLPTR; k++) {
std::string routine2 = routine + tryname[k];
i = this->RoutineToDirectory.find(routine2);
if (i != this->RoutineToDirectory.end()) {
filepath = i->second;
return true;
}
}
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);
if (p == 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);
} else // p == cmsysProcess_Pipe_None
{
} else { // p == cmsysProcess_Pipe_None
// The process will provide no more data.
break;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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()

View File

@ -576,7 +576,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);

View File

@ -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)

View File

@ -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) {
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)
@ -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;
}

View File

@ -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)) {

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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)

View File

@ -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

View File

@ -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(

View File

@ -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) {
return (t1 - t2) >= bil;
} else {
return false;
}
if (t2 < t1) {
return (t1 - t2) >= bil;
}
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;
}

View File

@ -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,

View File

@ -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);
}

View File

@ -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();
}
}
parameters.push_back(parameter);
}
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);
}
}

View File

@ -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(

View File

@ -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")) {
return tversion;
} else {
return "A";
}
if (const char* tversion = this->GetProperty("VERSION")) {
return tversion;
}
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;
}

View File

@ -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)

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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")) {
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;
}
// 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")) {
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;

View File

@ -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;

View File

@ -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());

View File

@ -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);

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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)

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
// 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') {