From b26577c92ae59fa23be49bcaa3404efe36646e1a Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 21 Apr 2017 10:06:12 +0200 Subject: clang-tidy: remove else after break and continue --- Source/CTest/cmCTestCoverageHandler.cxx | 3 +- Source/CTest/cmCTestLaunch.cxx | 3 +- Source/CTest/cmParseDelphiCoverage.cxx | 3 +- Source/CursesDialog/cmCursesLongMessageForm.cxx | 3 +- Source/CursesDialog/cmCursesMainForm.cxx | 5 +- Source/cmAddSubDirectoryCommand.cxx | 3 +- Source/cmFileCommand.cxx | 4 +- Source/cmGeneratorTarget.cxx | 66 +++++++++++-------------- Source/cmOutputRequiredFilesCommand.cxx | 3 +- Source/cmRST.cxx | 10 ++-- Source/cmSetTargetPropertiesCommand.cxx | 3 +- Source/cmSetTestsPropertiesCommand.cxx | 3 +- Source/cmSystemTools.cxx | 49 +++++++++--------- Source/cmcmd.cxx | 3 +- 14 files changed, 78 insertions(+), 83 deletions(-) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 4d970d5..87c532c 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2222,7 +2222,8 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir) if (line.empty() || line[0] == '#') { // Ignore blank and comment lines. continue; - } else if (line[0] == ' ') { + } + if (line[0] == ' ') { // Label lines appear indented by one space. std::string label = line.substr(1); int id = this->GetLabelId(label); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 7195bb3..a782150 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -306,7 +306,8 @@ void cmCTestLaunch::LoadLabels() if (line.empty() || line[0] == '#') { // Ignore blank and comment lines. continue; - } else if (line[0] == ' ') { + } + if (line[0] == ' ') { // Label lines appear indented by one space. if (inTarget || inSource) { this->Labels.insert(line.c_str() + 1); diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx index 9ae48d8..9cdd50b 100644 --- a/Source/CTest/cmParseDelphiCoverage.cxx +++ b/Source/CTest/cmParseDelphiCoverage.cxx @@ -46,7 +46,8 @@ public: beginSet.push_back("begin"); coverageVector.push_back(-1); continue; - } else if (line.find('{') != line.npos) { + } + if (line.find('{') != line.npos) { blockComFlag = true; } else if (line.find('}') != line.npos) { blockComFlag = false; diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index d299547..7fb065d 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -159,7 +159,8 @@ void cmCursesLongMessageForm::HandleInput() // quit if (key == 'o' || key == 'e') { break; - } else if (key == KEY_DOWN || key == ctrl('n')) { + } + if (key == KEY_DOWN || key == ctrl('n')) { form_driver(this->Form, REQ_SCR_FLINE); } else if (key == KEY_UP || key == ctrl('p')) { form_driver(this->Form, REQ_SCR_BLINE); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 939c736..ca824c0 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -764,9 +764,8 @@ void cmCursesMainForm::HandleInput() // quit if (key == 'q') { break; - } else { - continue; } + continue; } currentField = current_field(this->Form); @@ -826,7 +825,7 @@ void cmCursesMainForm::HandleInput() // (index always corresponds to the value field) // scroll down with arrow down, ctrl+n (emacs binding), or j (vim // binding) - else if (key == KEY_DOWN || key == ctrl('n') || key == 'j') { + if (key == KEY_DOWN || key == ctrl('n') || key == 'j') { FIELD* cur = current_field(this->Form); size_t findex = field_index(cur); if (findex == 3 * this->NumberOfVisibleEntries - 1) { diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 34ec0e3..dbd4dd1 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -32,7 +32,8 @@ bool cmAddSubDirectoryCommand::InitialPass( if (*i == "EXCLUDE_FROM_ALL") { excludeFromAll = true; continue; - } else if (binArg.empty()) { + } + if (binArg.empty()) { binArg = *i; } else { this->SetError("called with incorrect number of arguments"); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 034a266..fa166a0 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -613,8 +613,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) continue; } - else if ((c >= 0x20 && c < 0x7F) || c == '\t' || - (c == '\n' && newline_consume)) { + if ((c >= 0x20 && c < 0x7F) || c == '\t' || + (c == '\n' && newline_consume)) { // This is an ASCII character that may be part of a string. // Cast added to avoid compiler warning. Cast is ok because // c is guaranteed to fit in char by the above if... diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2799505..a38f968 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3933,15 +3933,14 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, << theTarget->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); break; - } else { - propContent = consistent.second; - continue; } - } else { - // Explicitly set on target and not set in iface. Can't disagree. + propContent = consistent.second; continue; } - } else if (impliedByUse) { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + if (impliedByUse) { propContent = impliedValue(propContent); if (ifaceIsSet) { @@ -3959,43 +3958,36 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); break; - } else { - propContent = consistent.second; - continue; } - } else { - // Implicitly set on target and not set in iface. Can't disagree. + propContent = consistent.second; continue; } - } else { - if (ifaceIsSet) { - if (propInitialized) { - std::pair consistent = - consistentProperty(propContent, ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " - << p << " already determined\nfor \"" << tgt->GetName() - << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } else { - propContent = consistent.second; - continue; - } - } else { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + if (ifaceIsSet) { + if (propInitialized) { + std::pair consistent = + consistentProperty(propContent, ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value of " + << p << " already determined\nfor \"" << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; } - } else { - // Not set. Nothing to agree on. + propContent = consistent.second; continue; } + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } else { + // Not set. Nothing to agree on. + continue; } } diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 8b8cf07..2339d68 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -188,9 +188,8 @@ protected: if (qstart == std::string::npos) { cmSystemTools::Error("unknown include directive ", line.c_str()); continue; - } else { - qend = line.find('>', qstart + 1); } + qend = line.find('>', qstart + 1); } else { qend = line.find('\"', qstart + 1); } diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 70ffc7d..938cad9 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -96,14 +96,14 @@ void cmRST::ProcessModule(std::istream& is) if (line == "#") { this->ProcessLine(""); continue; - } else if (line.substr(0, 2) == "# ") { + } + if (line.substr(0, 2) == "# ") { this->ProcessLine(line.substr(2, line.npos)); continue; - } else { - rst = ""; - this->Reset(); - this->OutputLinePending = true; } + rst = ""; + this->Reset(); + this->OutputLinePending = true; } if (line == "#.rst:") { rst = "#"; diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index da26972..6425913 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -32,9 +32,8 @@ bool cmSetTargetPropertiesCommand::InitialPass( } propertyPairs.insert(propertyPairs.end(), j, args.end()); break; - } else { - numFiles++; } + numFiles++; } if (propertyPairs.empty()) { this->SetError("called with illegal arguments, maybe missing " diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index 4fd379f..e27c675 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -32,9 +32,8 @@ bool cmSetTestsPropertiesCommand::InitialPass( } propertyPairs.insert(propertyPairs.end(), j, args.end()); break; - } else { - numFiles++; } + numFiles++; } if (propertyPairs.empty()) { this->SetError("called with illegal arguments, maybe " diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7ace0a3..9d3d91f 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1667,7 +1667,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, for (; outiter != out.end(); ++outiter) { if ((*outiter == '\r') && ((outiter + 1) == out.end())) { break; - } else if (*outiter == '\n' || *outiter == '\0') { + } + if (*outiter == '\n' || *outiter == '\0') { std::vector::size_type length = outiter - out.begin(); if (length > 1 && *(outiter - 1) == '\r') { --length; @@ -1684,7 +1685,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, for (; erriter != err.end(); ++erriter) { if ((*erriter == '\r') && ((erriter + 1) == err.end())) { break; - } else if (*erriter == '\n' || *erriter == '\0') { + } + if (*erriter == '\n' || *erriter == '\0') { std::vector::size_type length = erriter - err.begin(); if (length > 1 && *(erriter - 1) == '\r') { --length; @@ -2583,29 +2585,28 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, it = dentries.erase(it); entriesErased++; continue; - } else { - if (cmELF::TagMipsRldMapRel != 0 && - it->first == cmELF::TagMipsRldMapRel) { - // Background: debuggers need to know the "linker map" which contains - // the addresses each dynamic object is loaded at. Most arches use - // the DT_DEBUG tag which the dynamic linker writes to (directly) and - // contain the location of the linker map, however on MIPS the - // .dynamic section is always read-only so this is not possible. MIPS - // objects instead contain a DT_MIPS_RLD_MAP tag which contains the - // address where the dyanmic linker will write to (an indirect - // version of DT_DEBUG). Since this doesn't work when using PIE, a - // relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this - // version contains a relative offset, moving it changes the - // calculated address. This may cause the dyanmic linker to write - // into memory it should not be changing. - // - // To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If - // we move it up by n bytes, we add n bytes to the value of this tag. - it->second += entriesErased * sizeof_dentry; - } - - it++; } + if (cmELF::TagMipsRldMapRel != 0 && + it->first == cmELF::TagMipsRldMapRel) { + // Background: debuggers need to know the "linker map" which contains + // the addresses each dynamic object is loaded at. Most arches use + // the DT_DEBUG tag which the dynamic linker writes to (directly) and + // contain the location of the linker map, however on MIPS the + // .dynamic section is always read-only so this is not possible. MIPS + // objects instead contain a DT_MIPS_RLD_MAP tag which contains the + // address where the dyanmic linker will write to (an indirect + // version of DT_DEBUG). Since this doesn't work when using PIE, a + // relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this + // version contains a relative offset, moving it changes the + // calculated address. This may cause the dyanmic linker to write + // into memory it should not be changing. + // + // To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If + // we move it up by n bytes, we add n bytes to the value of this tag. + it->second += entriesErased * sizeof_dentry; + } + + it++; } // Encode new entries list diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 974dd5f..cc954e6 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1450,7 +1450,8 @@ bool cmVSLink::Parse(std::vector::const_iterator argBeg, if (*arg == "--") { ++arg; break; - } else if (*arg == "--manifests") { + } + if (*arg == "--manifests") { for (++arg; arg != argEnd && !cmHasLiteralPrefix(*arg, "-"); ++arg) { this->UserManifests.push_back(*arg); } -- cgit v0.12