From a16bf141bc5d393b27d13d8235d95a1b034052c2 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Fri, 10 Jun 2016 18:36:24 +0200 Subject: [PATCH] Add missing braces around statements. Apply fixits of clang-tidy's readability-braces-around-statements checker. --- Source/CPack/IFW/cmCPackIFWGenerator.cxx | 24 +++++++++++------ Source/CPack/IFW/cmCPackIFWInstaller.cxx | 3 ++- Source/CPack/IFW/cmCPackIFWPackage.cxx | 15 +++++++---- Source/CPack/IFW/cmCPackIFWRepository.cxx | 13 ++++++--- Source/CPack/cmCPackDebGenerator.cxx | 25 ++++++++++------- Source/CTest/cmCTestBZR.cxx | 9 ++++--- Source/CTest/cmCTestHG.cxx | 3 ++- Source/CTest/cmCTestMultiProcessHandler.cxx | 12 ++++++--- Source/CTest/cmCTestP4.cxx | 3 ++- Source/CTest/cmCTestSVN.cxx | 3 ++- .../CursesDialog/cmCursesLongMessageForm.cxx | 4 +-- Source/cmCacheManager.cxx | 3 ++- Source/cmDependsC.cxx | 3 ++- Source/cmGeneratorTarget.cxx | 21 ++++++++++----- Source/cmGlobalNinjaGenerator.cxx | 27 ++++++++++++------- Source/cmLocalNinjaGenerator.cxx | 21 ++++++++++----- Source/cmMakefile.cxx | 3 ++- Source/cmMakefileLibraryTargetGenerator.cxx | 3 ++- Source/cmNinjaNormalTargetGenerator.cxx | 15 ++++++----- Source/cmNinjaTargetGenerator.cxx | 24 +++++++++++------ Source/cmNinjaUtilityTargetGenerator.cxx | 11 +++++--- Source/cmOSXBundleGenerator.cxx | 18 ++++++++----- Source/cmSystemTools.cxx | 10 ++++--- Source/cmTarget.cxx | 3 ++- .../CMakeLib/PseudoMemcheck/memtester.cxx.in | 12 +++++---- Tests/CMakeLib/run_compile_commands.cxx | 15 +++++++---- 26 files changed, 198 insertions(+), 105 deletions(-) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index c1ff526cf..b47d46e56 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -345,18 +345,21 @@ cmCPackComponent* cmCPackIFWGenerator::GetComponent( const std::string& projectName, const std::string& componentName) { ComponentsMap::iterator cit = Components.find(componentName); - if (cit != Components.end()) + if (cit != Components.end()) { return &(cit->second); + } cmCPackComponent* component = cmCPackGenerator::GetComponent(projectName, componentName); - if (!component) + if (!component) { return component; + } std::string name = GetComponentPackageName(component); PackagesMap::iterator pit = Packages.find(name); - if (pit != Packages.end()) + if (pit != Packages.end()) { return component; + } cmCPackIFWPackage* package = &Packages[name]; package->Name = name; @@ -387,13 +390,15 @@ cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup( { cmCPackComponentGroup* group = cmCPackGenerator::GetComponentGroup(projectName, groupName); - if (!group) + if (!group) { return group; + } std::string name = GetGroupPackageName(group); PackagesMap::iterator pit = Packages.find(name); - if (pit != Packages.end()) + if (pit != Packages.end()) { return group; + } cmCPackIFWPackage* package = &Packages[name]; package->Name = name; @@ -462,8 +467,9 @@ std::string cmCPackIFWGenerator::GetGroupPackageName( cmCPackComponentGroup* group) const { std::string name; - if (!group) + if (!group) { return name; + } if (cmCPackIFWPackage* package = GetGroupPackage(group)) { return package->Name; } @@ -488,8 +494,9 @@ std::string cmCPackIFWGenerator::GetComponentPackageName( cmCPackComponent* component) const { std::string name; - if (!component) + if (!component) { return name; + } if (cmCPackIFWPackage* package = GetComponentPackage(component)) { return package->Name; } @@ -534,8 +541,9 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( const std::string& repositoryName) { RepositoriesMap::iterator rit = Repositories.find(repositoryName); - if (rit != Repositories.end()) + if (rit != Repositories.end()) { return &(rit->second); + } cmCPackIFWRepository* repository = &Repositories[repositoryName]; repository->Name = repositoryName; diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index dfc509bc6..74f6da671 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -343,6 +343,7 @@ void cmCPackIFWInstaller::GeneratePackageFiles() void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout) { - if (Generator) + if (Generator) { Generator->WriteGeneratedByToStrim(xout); + } } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index ad153d1aa..c44e3897f 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -71,8 +71,9 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct( std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const { - if (Compare.Type == CompareNone) + if (Compare.Type == CompareNone) { return Name; + } std::string result = Name; @@ -128,8 +129,9 @@ bool cmCPackIFWPackage::IsVersionEqual(const char* version) std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component) { - if (!component) + if (!component) { return ""; + } const char* option = GetOption("CPACK_IFW_COMPONENT_" + cmsys::SystemTools::UpperCase(component->Name) + "_NAME"); @@ -189,8 +191,9 @@ int cmCPackIFWPackage::ConfigureFromOptions() int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) { - if (!component) + if (!component) { return 0; + } // Restore defaul configuration DefaultConfiguration(); @@ -284,8 +287,9 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) { - if (!group) + if (!group) { return 0; + } // Restore defaul configuration DefaultConfiguration(); @@ -474,6 +478,7 @@ void cmCPackIFWPackage::GeneratePackageFile() void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout) { - if (Generator) + if (Generator) { Generator->WriteGeneratedByToStrim(xout); + } } diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 18380054d..b8a10c64a 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -89,8 +89,9 @@ bool cmCPackIFWRepository::IsVersionEqual(const char* version) bool cmCPackIFWRepository::ConfigureFromOptions() { // Name; - if (Name.empty()) + if (Name.empty()) { return false; + } std::string prefix = "CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(Name) + "_"; @@ -198,8 +199,9 @@ protected: patched = true; } xout.EndElement(); - if (patched) + if (patched) { return; + } if (name == "Checksum") { repository->WriteRepositoryUpdates(xout); patched = true; @@ -209,8 +211,10 @@ protected: virtual void CharacterDataHandler(const char* data, int length) { std::string content(data, data + length); - if (content == "" || content == " " || content == " " || content == "\n") + if (content == "" || content == " " || content == " " || + content == "\n") { return; + } xout.Content(content); } }; @@ -332,6 +336,7 @@ void cmCPackIFWRepository::WriteRepositoryUpdates(cmXMLWriter& xout) void cmCPackIFWRepository::WriteGeneratedByToStrim(cmXMLWriter& xout) { - if (Generator) + if (Generator) { Generator->WriteGeneratedByToStrim(xout); + } } diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index bef0fb4ff..b659359c0 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -826,8 +826,9 @@ static int copy_ar(CF* cfp, off_t size) size_t nr, nw; char buf[8 * 1024]; - if (sz == 0) + if (sz == 0) { return 0; + } FILE* from = cfp->rFile; FILE* to = cfp->wFile; @@ -837,16 +838,20 @@ static int copy_ar(CF* cfp, off_t size) : sizeof(buf), from)) > 0) { sz -= nr; - for (size_t off = 0; off < nr; nr -= off, off += nw) - if ((nw = fwrite(buf + off, 1, nr, to)) < nr) + for (size_t off = 0; off < nr; nr -= off, off += nw) { + if ((nw = fwrite(buf + off, 1, nr, to)) < nr) { return -1; + } + } } - if (sz) + if (sz) { return -2; + } if (cfp->flags & WPAD && (size + ar_already_written) & 1 && - fwrite(&pad, 1, 1, to) != 1) + fwrite(&pad, 1, 1, to) != 1) { return -4; + } return 0; } @@ -874,11 +879,11 @@ static int put_arobj(CF* cfp, struct stat* sb) if (gid > USHRT_MAX) { gid = USHRT_MAX; } - if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) + if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) { (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size + lname, ARFMAG); - else { + } else { lname = 0; (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size, @@ -886,12 +891,14 @@ static int put_arobj(CF* cfp, struct stat* sb) } off_t size = sb->st_size; - if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR)) + if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR)) { return -1; + } if (lname) { - if (fwrite(name, 1, lname, cfp->wFile) != lname) + if (fwrite(name, 1, lname, cfp->wFile) != lname) { return -2; + } ar_already_written = lname; } result = copy_ar(cfp, size); diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index dd53be849..92eb570f5 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -61,8 +61,9 @@ extern "C" int cmBZRXMLParserUnknownEncodingHandler(void*, // workaround for these unknown encodings. if (name == std::string("ascii") || name == std::string("cp1252") || name == std::string("ANSI_X3.4-1968")) { - for (unsigned int i = 0; i < 256; ++i) + for (unsigned int i = 0; i < 256; ++i) { info->map[i] = latin1[i]; + } return 1; } @@ -336,8 +337,9 @@ private: void DoPath(char c0, char c1, char c2, std::string path) { - if (path.empty()) + if (path.empty()) { return; + } cmSystemTools::ConvertToUnixSlashes(path); const std::string dir = cmSystemTools::GetFilenamePath(path); @@ -441,8 +443,9 @@ private: void DoPath(char c0, char c1, char c2, std::string path) { - if (path.empty()) + if (path.empty()) { return; + } cmSystemTools::ConvertToUnixSlashes(path); if (c0 == 'C') { diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index c6cfa44bb..f1fe3774c 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -75,8 +75,9 @@ private: void DoPath(char status, std::string const& path) { - if (path.empty()) + if (path.empty()) { return; + } // See "hg help status". Note that there is no 'conflict' status. switch (status) { diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 7b384addb..ae97d3209 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -413,12 +413,14 @@ void cmCTestMultiProcessHandler::UpdateCostData() std::string line; while (std::getline(fin, line)) { - if (line == "---") + if (line == "---") { break; + } std::vector parts = cmSystemTools::SplitString(line, ' '); // Format: - if (parts.size() < 3) + if (parts.size() < 3) { break; + } std::string name = parts[0]; int prev = atoi(parts[1].c_str()); @@ -464,8 +466,9 @@ void cmCTestMultiProcessHandler::ReadCostData() fin.open(fname.c_str()); std::string line; while (std::getline(fin, line)) { - if (line == "---") + if (line == "---") { break; + } std::vector parts = cmSystemTools::SplitString(line, ' '); @@ -480,8 +483,9 @@ void cmCTestMultiProcessHandler::ReadCostData() float cost = static_cast(atof(parts[2].c_str())); int index = this->SearchByName(name); - if (index == -1) + if (index == -1) { continue; + } this->Properties[index]->PreviousRuns = prev; // When not running in parallel mode, don't use cost data diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 07f9dadc5..ede11c990 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -426,8 +426,9 @@ void cmCTestP4::LoadRevisions() ChangeLists.clear(); this->RunChild(&p4_changes[0], &out, &err); - if (ChangeLists.empty()) + if (ChangeLists.empty()) { return; + } // p4 describe -s ...@1111111,2222222 std::vector p4_describe; diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index a6885aa26..fa014111b 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -271,8 +271,9 @@ bool cmCTestSVN::UpdateImpl() bool cmCTestSVN::RunSVNCommand(std::vector const& parameters, OutputParser* out, OutputParser* err) { - if (parameters.empty()) + if (parameters.empty()) { return false; + } std::vector args; args.push_back(this->CommandLineTool.c_str()); diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 84672ae07..d03d3300d 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -54,9 +54,9 @@ void cmCursesLongMessageForm::UpdateStatusBar() size = cmCursesMainForm::MAX_WIDTH - 1; } strncpy(bar, this->Title.c_str(), size); - for (size_t i = size - 1; i < cmCursesMainForm::MAX_WIDTH; i++) + for (size_t i = size - 1; i < cmCursesMainForm::MAX_WIDTH; i++) { bar[i] = ' '; - + } int width; if (x < cmCursesMainForm::MAX_WIDTH) { width = x; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 676e84a2a..9adfdafae 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -71,8 +71,9 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, while (*realbuffer != '0' && (*realbuffer == ' ' || *realbuffer == '\t' || *realbuffer == '\r' || *realbuffer == '\n')) { - if (*realbuffer == '\n') + if (*realbuffer == '\n') { lineno++; + } realbuffer++; } // skip blank lines and comment lines diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index f81bf068d..57e719cc8 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -158,7 +158,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, this->HeaderLocationCache.find(current.FileName); if (headerLocationIt != this->HeaderLocationCache.end()) { fullName = headerLocationIt->second; - } else + } else { for (std::vector::const_iterator i = this->IncludePath.begin(); i != this->IncludePath.end(); ++i) { @@ -175,6 +175,7 @@ bool cmDependsC::WriteDependencies(const std::set& sources, break; } } + } } // Complain if the file cannot be found and matches the complain diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1607dd937..de02395bc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1348,8 +1348,9 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, fpath += ".app"; if (!this->Makefile->PlatformIsAppleIos()) { fpath += "/Contents"; - if (!contentOnly) + if (!contentOnly) { fpath += "/MacOS"; + } } return fpath; } @@ -1377,8 +1378,9 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, fpath += ext; if (!this->Makefile->PlatformIsAppleIos()) { fpath += "/Contents"; - if (!contentOnly) + if (!contentOnly) { fpath += "/MacOS"; + } } return fpath; } @@ -3336,11 +3338,13 @@ static std::string intersect(const std::set& s1, { std::string result; result = intersect(s1, s2); - if (!result.empty()) + if (!result.empty()) { return result; + } result = intersect(s1, s3); - if (!result.empty()) + if (!result.empty()) { return result; + } return intersect(s2, s3); } @@ -3351,14 +3355,17 @@ static std::string intersect(const std::set& s1, { std::string result; result = intersect(s1, s2); - if (!result.empty()) + if (!result.empty()) { return result; + } result = intersect(s1, s3); - if (!result.empty()) + if (!result.empty()) { return result; + } result = intersect(s1, s4); - if (!result.empty()) + if (!result.empty()) { return result; + } return intersect(s2, s3, s4); } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 3abcba398..f74e83562 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -30,8 +30,9 @@ const char* cmGlobalNinjaGenerator::INDENT = " "; void cmGlobalNinjaGenerator::Indent(std::ostream& os, int count) { - for (int i = 0; i < count; ++i) + for (int i = 0; i < count; ++i) { os << cmGlobalNinjaGenerator::INDENT; + } } void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os) @@ -43,8 +44,9 @@ void cmGlobalNinjaGenerator::WriteDivider(std::ostream& os) void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, const std::string& comment) { - if (comment.empty()) + if (comment.empty()) { return; + } std::string::size_type lpos = 0; std::string::size_type rpos; @@ -165,16 +167,18 @@ void cmGlobalNinjaGenerator::WriteBuild( if (!implicitDeps.empty()) { arguments += " |"; for (cmNinjaDeps::const_iterator i = implicitDeps.begin(); - i != implicitDeps.end(); ++i) + i != implicitDeps.end(); ++i) { arguments += " " + EncodeIdent(EncodePath(*i), os); + } } // Write order-only dependencies. if (!orderOnlyDeps.empty()) { arguments += " ||"; for (cmNinjaDeps::const_iterator i = orderOnlyDeps.begin(); - i != orderOnlyDeps.end(); ++i) + i != orderOnlyDeps.end(); ++i) { arguments += " " + EncodeIdent(EncodePath(*i), os); + } } arguments += "\n"; @@ -198,9 +202,10 @@ void cmGlobalNinjaGenerator::WriteBuild( // Write the variables bound to this build statement. std::ostringstream variable_assignments; for (cmNinjaVars::const_iterator i = variables.begin(); i != variables.end(); - ++i) + ++i) { cmGlobalNinjaGenerator::WriteVariable(variable_assignments, i->first, i->second, "", 1); + } // check if a response file rule should be used std::string buildstr = build; @@ -430,8 +435,9 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os, cmGlobalNinjaGenerator::WriteComment(os, comment); os << "default"; for (cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end(); - ++i) + ++i) { os << " " << *i; + } os << "\n"; } @@ -907,15 +913,17 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, this->AppendTargetOutputs(target, outputs); // Mark the target's outputs as ambiguous to ensure that no other target uses // the output as an alias. - for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) + for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) { TargetAliases[*i] = 0; + } // Insert the alias into the map. If the alias was already present in the // map and referred to another target, mark it as ambiguous. std::pair newAlias = TargetAliases.insert(std::make_pair(buildAlias, target)); - if (newAlias.second && newAlias.first->second != target) + if (newAlias.second && newAlias.first->second != target) { newAlias.first->second = 0; + } } void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) @@ -926,8 +934,9 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os) for (TargetAliasMap::const_iterator i = TargetAliases.begin(); i != TargetAliases.end(); ++i) { // Don't write ambiguous aliases. - if (!i->second) + if (!i->second) { continue; + } cmNinjaDeps deps; this->AppendTargetOutputs(i->second, deps); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 6c231c3ec..6e676f1d3 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -81,8 +81,9 @@ void cmLocalNinjaGenerator::Generate() tg->Generate(); // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( - this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], *t)) + this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], *t)) { this->GetGlobalNinjaGenerator()->AddDependencyToAll(*t); + } delete tg; } } @@ -257,8 +258,9 @@ void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) os << "# Write statements declared in CMakeLists.txt:" << std::endl << "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE") << std::endl; - if (this->IsRootMakefile()) + if (this->IsRootMakefile()) { os << "# Which is the root file." << std::endl; + } cmGlobalNinjaGenerator::WriteDivider(os); os << std::endl; } @@ -282,9 +284,10 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps( for (std::vector::const_iterator i = deps.begin(); i != deps.end(); ++i) { std::string dep; - if (this->GetRealDependency(*i, this->GetConfigName(), dep)) + if (this->GetRealDependency(*i, this->GetConfigName(), dep)) { ninjaDeps.push_back( this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep)); + } } } @@ -294,12 +297,13 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( // If we have no commands but we need to build a command anyway, use ":". // This happens when building a POST_BUILD value for link targets that // don't use POST_BUILD. - if (cmdLines.empty()) + if (cmdLines.empty()) { #ifdef _WIN32 return "cd ."; #else return ":"; #endif + } std::ostringstream cmd; for (std::vector::const_iterator li = cmdLines.begin(); @@ -332,8 +336,9 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines( { if (ccg.GetNumberOfCommands() > 0) { std::string wd = ccg.GetWorkingDirectory(); - if (wd.empty()) + if (wd.empty()) { wd = this->GetCurrentBinaryDirectory(); + } std::ostringstream cdCmd; #ifdef _WIN32 @@ -361,8 +366,9 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines( void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( cmCustomCommand const* cc, const cmNinjaDeps& orderOnlyDeps) { - if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) + if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) { return; + } cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this); @@ -391,8 +397,9 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( this->AppendCustomCommandDeps(ccg, ninjaDeps); for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end(); - ++i) + ++i) { this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i); + } std::vector cmdLines; this->AppendCustomCommandLines(ccg, cmdLines); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ca30b3d66..e3d66148c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3620,8 +3620,9 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name, bool cmMakefile::IsAlias(const std::string& name) const { - if (this->AliasTargets.find(name) != this->AliasTargets.end()) + if (this->AliasTargets.find(name) != this->AliasTargets.end()) { return true; + } return this->GetGlobalGenerator()->IsAlias(name); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 0998eb811..438f90f3d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -329,8 +329,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( buildEcho += " shared library "; break; case cmState::MODULE_LIBRARY: - if (this->GeneratorTarget->IsCFBundleOnApple()) + if (this->GeneratorTarget->IsCFBundleOnApple()) { buildEcho += " CFBundle"; + } buildEcho += " shared module "; break; default: diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index fdce542cc..5225e3ff0 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -41,15 +41,16 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( , TargetLinkLanguage("") { this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); - if (target->GetType() == cmState::EXECUTABLE) + if (target->GetType() == cmState::EXECUTABLE) { this->GetGeneratorTarget()->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); - else + } else { this->GetGeneratorTarget()->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); + } if (target->GetType() != cmState::OBJECT_LIBRARY) { // on Windows the output dir is already needed at compile time @@ -125,10 +126,11 @@ const char* cmNinjaNormalTargetGenerator::GetVisibleTypeName() const case cmState::SHARED_LIBRARY: return "shared library"; case cmState::MODULE_LIBRARY: - if (this->GetGeneratorTarget()->IsCFBundleOnApple()) + if (this->GetGeneratorTarget()->IsCFBundleOnApple()) { return "CFBundle shared module"; - else + } else { return "shared module"; + } case cmState::EXECUTABLE: return "executable"; default: @@ -271,7 +273,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); - if (targetType == cmState::EXECUTABLE) + if (targetType == cmState::EXECUTABLE) { this->GetGlobalGenerator()->AddRule( "CMAKE_SYMLINK_EXECUTABLE", cmakeCommand + " -E cmake_symlink_executable" @@ -284,7 +286,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) /*rspcontent*/ "", /*restat*/ "", /*generator*/ false); - else + } else { this->GetGlobalGenerator()->AddRule( "CMAKE_SYMLINK_LIBRARY", cmakeCommand + " -E cmake_symlink_library" @@ -297,6 +299,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) /*rspcontent*/ "", /*restat*/ "", /*generator*/ false); + } } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b0f0d9b47..05a0a6392 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -46,8 +46,9 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target) // (i.e. top-level) directory. CMake creates copies of these targets // in every directory, which we don't need. if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(), - target->GetLocalGenerator()->GetSourceDirectory()) == 0) + target->GetLocalGenerator()->GetSourceDirectory()) == 0) { return new cmNinjaUtilityTargetGenerator(target); + } // else fallthrough } @@ -132,8 +133,9 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags, includes, this->GeneratorTarget, language, language == "RC", // full include paths for RC needed by cmcldeps false, this->GetConfigName()); - if (this->GetGlobalGenerator()->IsGCCOnWindows()) + if (this->GetGlobalGenerator()->IsGCCOnWindows()) { std::replace(includeFlags.begin(), includeFlags.end(), '\\', '/'); + } this->LocalGenerator->AppendFlags(languageFlags, includeFlags); } @@ -170,13 +172,15 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { // Static libraries never depend on other targets for linking. if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || - this->GeneratorTarget->GetType() == cmState::OBJECT_LIBRARY) + this->GeneratorTarget->GetType() == cmState::OBJECT_LIBRARY) { return cmNinjaDeps(); + } cmComputeLinkInformation* cli = this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); - if (!cli) + if (!cli) { return cmNinjaDeps(); + } const std::vector& deps = cli->GetDepends(); cmNinjaDeps result(deps.size()); @@ -218,8 +222,9 @@ std::string cmNinjaTargetGenerator::GetObjectFilePath( cmSourceFile const* source) const { std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); - if (!path.empty()) + if (!path.empty()) { path += "/"; + } std::string const& objectName = this->GeneratorTarget->GetObjectName(source); path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path += "/"; @@ -237,8 +242,9 @@ std::string cmNinjaTargetGenerator::GetTargetFilePath( const std::string& name) const { std::string path = this->GetTargetOutputDir(); - if (path.empty() || path == ".") + if (path.empty() || path == ".") { return name; + } path += "/"; path += name; return path; @@ -420,8 +426,9 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) } for (std::vector::iterator i = compileCmds.begin(); - i != compileCmds.end(); ++i) + i != compileCmds.end(); ++i) { this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); + } std::string cmdLine = this->GetLocalGenerator()->BuildCommandLine(compileCmds); @@ -653,8 +660,9 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( cmSystemTools::ExpandListArgument(compileCmd, compileCmds); for (std::vector::iterator i = compileCmds.begin(); - i != compileCmds.end(); ++i) + i != compileCmds.end(); ++i) { this->GetLocalGenerator()->ExpandRuleVariables(*i, compileObjectVars); + } std::string cmdLine = this->GetLocalGenerator()->BuildCommandLine(compileCmds); diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index f7a7f38c8..c54964671 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -57,8 +57,9 @@ void cmNinjaUtilityTargetGenerator::Generate() std::vector const& ccByproducts = ccg.GetByproducts(); std::transform(ccByproducts.begin(), ccByproducts.end(), std::back_inserter(util_outputs), MapToNinjaPath()); - if (ci->GetUsesTerminal()) + if (ci->GetUsesTerminal()) { uses_terminal = true; + } } } @@ -99,10 +100,11 @@ void cmNinjaUtilityTargetGenerator::Generate() const char* echoStr = this->GetGeneratorTarget()->GetProperty("EchoString"); std::string desc; - if (echoStr) + if (echoStr) { desc = echoStr; - else + } else { desc = "Running utility command for " + this->GetTargetName(); + } // TODO: fix problematic global targets. For now, search and replace the // makefile vars. @@ -122,8 +124,9 @@ void cmNinjaUtilityTargetGenerator::Generate() .c_str()); cmSystemTools::ReplaceString(command, "$(ARGS)", ""); - if (command.find('$') != std::string::npos) + if (command.find('$') != std::string::npos) { return; + } for (cmNinjaDeps::const_iterator oi = util_outputs.begin(), oe = util_outputs.end(); diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index f62ba40cc..c19cae0d0 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -25,8 +25,9 @@ cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target, , ConfigName(configName) , MacContentFolders(0) { - if (this->MustSkip()) + if (this->MustSkip()) { return; + } } bool cmOSXBundleGenerator::MustSkip() @@ -37,8 +38,9 @@ bool cmOSXBundleGenerator::MustSkip() void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, std::string& outpath) { - if (this->MustSkip()) + if (this->MustSkip()) { return; + } // Compute bundle directory names. std::string out = outpath; @@ -64,8 +66,9 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, void cmOSXBundleGenerator::CreateFramework(const std::string& targetName, const std::string& outpath) { - if (this->MustSkip()) + if (this->MustSkip()) { return; + } assert(this->MacContentFolders); @@ -92,8 +95,9 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName, plist.c_str()); // Generate Versions directory only for MacOSX frameworks - if (this->Makefile->PlatformIsAppleIos()) + if (this->Makefile->PlatformIsAppleIos()) { return; + } // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to // drive rules to create these files at build time. @@ -162,8 +166,9 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName, void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, const std::string& root) { - if (this->MustSkip()) + if (this->MustSkip()) { return; + } // Compute bundle directory names. std::string out = root; @@ -186,8 +191,9 @@ void cmOSXBundleGenerator::GenerateMacOSXContentStatements( std::vector const& sources, MacOSXContentGeneratorType* generator) { - if (this->MustSkip()) + if (this->MustSkip()) { return; + } for (std::vector::const_iterator si = sources.begin(); si != sources.end(); ++si) { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 10c68d193..26cbfb6bf 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -228,14 +228,16 @@ std::string cmSystemTools::HelpFileName(std::string name) std::string cmSystemTools::TrimWhitespace(const std::string& s) { std::string::const_iterator start = s.begin(); - while (start != s.end() && cm_isspace(*start)) + while (start != s.end() && cm_isspace(*start)) { ++start; - if (start == s.end()) + } + if (start == s.end()) { return ""; - + } std::string::const_iterator stop = s.end() - 1; - while (cm_isspace(*stop)) + while (cm_isspace(*stop)) { --stop; + } return std::string(start, stop + 1); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index da2a64993..55da611f8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -287,8 +287,9 @@ cmListFileBacktrace const* cmTarget::GetUtilityBacktrace( { std::map::const_iterator i = this->UtilityBacktraces.find(u); - if (i == this->UtilityBacktraces.end()) + if (i == this->UtilityBacktraces.end()) { return 0; + } return &i->second; } diff --git a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in index 9958021a9..e2cdec89a 100644 --- a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in +++ b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in @@ -15,15 +15,15 @@ int main(int ac, char** av) std::string logarg; bool nextarg = false; - if (exename.find("valgrind") != exename.npos) + if (exename.find("valgrind") != exename.npos) { logarg = "--log-file="; - else if (exename.find("purify") != exename.npos) + } else if (exename.find("purify") != exename.npos) { #ifdef _WIN32 logarg = "/SAVETEXTDATA="; #else logarg = "-log-file="; #endif - else if (exename.find("BC") != exename.npos) { + } else if (exename.find("BC") != exename.npos) { nextarg = true; logarg = "/X"; } @@ -34,8 +34,9 @@ int main(int ac, char** av) std::string arg = argv[i]; if (arg.find(logarg) == 0) { if (nextarg) { - if (i == argc - 1) + if (i == argc - 1) { return 1; // invalid command line + } logfile = argv[i + 1]; } else { logfile = arg.substr(logarg.length()); @@ -44,8 +45,9 @@ int main(int ac, char** av) } } - if (!logfile.empty()) + if (!logfile.empty()) { cmSystemTools::Touch(logfile, true); + } } return RETVAL; diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 1cfd3815a..b811c7fd5 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -46,10 +46,12 @@ private: void ParseTranslationUnit() { this->Command = CommandType(); - if (!Expect('{')) + if (!Expect('{')) { return; - if (Expect('}')) + } + if (Expect('}')) { return; + } do { ParseString(); std::string name = this->String; @@ -64,8 +66,9 @@ private: void ParseString() { this->String = ""; - if (!Expect('"')) + if (!Expect('"')) { return; + } while (!Expect('"')) { Expect('\\'); this->String.append(1, C); @@ -84,8 +87,9 @@ private: void ExpectOrDie(char c, const std::string& message) { - if (!Expect(c)) + if (!Expect(c)) { ErrorExit(std::string("'") + c + "' expected " + message + "."); + } } void NextNonWhitespace() @@ -98,8 +102,9 @@ private: void Next() { this->C = char(Input->get()); - if (this->Input->bad()) + if (this->Input->bad()) { ErrorExit("Unexpected end of file."); + } } void ErrorExit(const std::string& message)