diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2022-11-22 19:11:07 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2022-11-29 17:39:45 (GMT) |
commit | 4deab0a75c0da66938c230a446af5ecd6f3c5ca3 (patch) | |
tree | da2a018bdb2564934dbea62c60111c5f55c5dbce | |
parent | 714a466eeb42809fa56d78d6aef6cde70d938af5 (diff) | |
download | CMake-4deab0a75c0da66938c230a446af5ecd6f3c5ca3.zip CMake-4deab0a75c0da66938c230a446af5ecd6f3c5ca3.tar.gz CMake-4deab0a75c0da66938c230a446af5ecd6f3c5ca3.tar.bz2 |
clang-tidy: fix `readability-braces-around-statements` lints
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 3 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 6 | ||||
-rw-r--r-- | Source/cmVSSetupHelper.cxx | 27 | ||||
-rw-r--r-- | Source/cmVSSetupHelper.h | 12 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmVisualStudioSlnData.cxx | 21 | ||||
-rw-r--r-- | Source/cmVisualStudioSlnParser.cxx | 132 |
7 files changed, 132 insertions, 78 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 1582207..e83ed7a 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1109,8 +1109,9 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand( // Decide if a restore is performed, based on a cache variable. if (cmValue cached = this->CMakeInstance->GetState()->GetCacheEntryValue( - "CMAKE_VS_NUGET_PACKAGE_RESTORE")) + "CMAKE_VS_NUGET_PACKAGE_RESTORE")) { restorePackages = cached.IsOn(); + } } if (restorePackages) { diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 69b3c22..d6eceb1 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -546,8 +546,9 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( } else if (cmHasLiteralPrefix(name, "POST_")) { name = name.substr(5); sectionType = "postSolution"; - } else + } else { continue; + } if (!name.empty()) { bool addGuid = false; if (name == "ExtensibilityGlobals" && sectionType == "postSolution") { @@ -585,9 +586,10 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( << "\t\tSolutionGuid = {" << guid << "}\n" << "\tEndGlobalSection\n"; } - if (!extensibilityAddInsOverridden) + if (!extensibilityAddInsOverridden) { fout << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" << "\tEndGlobalSection\n"; + } } // Standard end of dsw file diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index db85e86..e4cbe49 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -104,8 +104,9 @@ cmVSSetupAPIHelper::~cmVSSetupAPIHelper() setupHelper = nullptr; setupConfig2 = nullptr; setupConfig = nullptr; - if (SUCCEEDED(comInitialized)) + if (SUCCEEDED(comInitialized)) { CoUninitialize(); + } } bool cmVSSetupAPIHelper::SetVSInstance(std::string const& vsInstallLocation, @@ -176,8 +177,9 @@ bool cmVSSetupAPIHelper::CheckInstalledComponent( bool cmVSSetupAPIHelper::GetVSInstanceInfo( SmartCOMPtr<ISetupInstance2> pInstance, VSInstanceInfo& vsInstanceInfo) { - if (pInstance == nullptr) + if (pInstance == nullptr) { return false; + } InstanceState state; if (FAILED(pInstance->GetState(&state))) { @@ -229,8 +231,9 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo( SmartCOMPtr<ISetupPackageReference> package = nullptr; if (FAILED(ppData[i]->QueryInterface(IID_ISetupPackageReference, (void**)&package)) || - package == nullptr) + package == nullptr) { continue; + } bool win10SDKInstalled = false; bool win81SDkInstalled = false; @@ -368,8 +371,9 @@ bool cmVSSetupAPIHelper::EnumerateVSInstancesWithCOM( std::vector<VSInstanceInfo>& VSInstances) { if (initializationFailure || setupConfig == nullptr || - setupConfig2 == nullptr || setupHelper == nullptr) + setupConfig2 == nullptr || setupHelper == nullptr) { return false; + } SmartCOMPtr<IEnumSetupInstances> enumInstances = nullptr; if (FAILED( @@ -391,8 +395,9 @@ bool cmVSSetupAPIHelper::EnumerateVSInstancesWithCOM( VSInstanceInfo instanceInfo; bool isInstalled = GetVSInstanceInfo(instance2, instanceInfo); instance = instance2 = nullptr; - if (isInstalled) + if (isInstalled) { VSInstances.push_back(instanceInfo); + } } return true; } @@ -410,8 +415,9 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() cmSystemTools::GetEnv("WindowsSdkDir_81", envWindowsSdkDir81); cmSystemTools::GetEnv("VisualStudioVersion", envVSVersion); cmSystemTools::GetEnv("VSINSTALLDIR", envVsInstallDir); - if (envVSVersion.empty() || envVsInstallDir.empty()) + if (envVSVersion.empty() || envVsInstallDir.empty()) { return false; + } chosenInstanceInfo.VSInstallLocation = envVsInstallDir; chosenInstanceInfo.Version = envVSVersion; @@ -508,11 +514,13 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance() int cmVSSetupAPIHelper::ChooseVSInstance( const std::vector<VSInstanceInfo>& vecVSInstances) { - if (vecVSInstances.empty()) + if (vecVSInstances.empty()) { return -1; + } - if (vecVSInstances.size() == 1) + if (vecVSInstances.size() == 1) { return 0; + } unsigned int chosenIndex = 0; for (unsigned int i = 1; i < vecVSInstances.size(); i++) { @@ -586,8 +594,9 @@ bool cmVSSetupAPIHelper::LoadSpecifiedVSInstanceFromDisk() bool cmVSSetupAPIHelper::Initialize() { - if (initializationFailure) + if (initializationFailure) { return false; + } if (FAILED(comInitialized)) { initializationFailure = true; diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h index 4ef7e15..b8be9b9 100644 --- a/Source/cmVSSetupHelper.h +++ b/Source/cmVSSetupHelper.h @@ -21,14 +21,16 @@ public: SmartCOMPtr(T* p) { ptr = p; - if (ptr != nullptr) + if (ptr != nullptr) { ptr->AddRef(); + } } SmartCOMPtr(const SmartCOMPtr<T>& sptr) { ptr = sptr.ptr; - if (ptr != nullptr) + if (ptr != nullptr) { ptr->AddRef(); + } } T** operator&() { return &ptr; } T* operator->() { return ptr; } @@ -36,8 +38,9 @@ public: { if (*this != p) { ptr = p; - if (ptr != nullptr) + if (ptr != nullptr) { ptr->AddRef(); + } } return *this; } @@ -59,8 +62,9 @@ public: } ~SmartCOMPtr() { - if (ptr != nullptr) + if (ptr != nullptr) { ptr->Release(); + } } private: diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 28df926..810e587 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1031,8 +1031,9 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1) std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys(); for (std::string const& keyIt : keys) { static const cm::string_view prefix = "VS_GLOBAL_"; - if (!cmHasPrefix(keyIt, prefix)) + if (!cmHasPrefix(keyIt, prefix)) { continue; + } cm::string_view globalKey = cm::string_view(keyIt).substr(prefix.length()); // Skip invalid or separately-handled properties. if (globalKey.empty() || globalKey == "PROJECT_TYPES" || @@ -1040,8 +1041,9 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1) continue; } cmValue value = this->GeneratorTarget->GetProperty(keyIt); - if (!value) + if (!value) { continue; + } e1.Element(globalKey, *value); } } @@ -2399,8 +2401,9 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2, // added with the plain filename without any path. This means the file will // show up at root-level of the csproj (where CMakeLists.txt etc. are). std::string link = this->GetCSharpSourceLink(sf); - if (link.empty()) + if (link.empty()) { link = cmsys::SystemTools::GetFilenameName(sf->GetFullPath()); + } e2.Element("Link", link); } diff --git a/Source/cmVisualStudioSlnData.cxx b/Source/cmVisualStudioSlnData.cxx index 98bbc34..fe261dd 100644 --- a/Source/cmVisualStudioSlnData.cxx +++ b/Source/cmVisualStudioSlnData.cxx @@ -24,8 +24,9 @@ const cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByGUID( const std::string& projectGUID) const { auto it(ProjectsByGUID.find(projectGUID)); - if (it != ProjectsByGUID.end()) + if (it != ProjectsByGUID.end()) { return it->second; + } return cm::nullopt; } @@ -33,8 +34,9 @@ const cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByName( const std::string& projectName) const { auto it(ProjectNameIndex.find(projectName)); - if (it != ProjectNameIndex.end()) + if (it != ProjectNameIndex.end()) { return it->second->second; + } return cm::nullopt; } @@ -42,8 +44,9 @@ std::vector<cmSlnProjectEntry> cmSlnData::GetProjects() const { auto it(this->ProjectNameIndex.begin()), itEnd(this->ProjectNameIndex.end()); std::vector<cmSlnProjectEntry> result; - for (; it != itEnd; ++it) + for (; it != itEnd; ++it) { result.push_back(it->second->second); + } return result; } @@ -52,8 +55,9 @@ cmSlnProjectEntry* cmSlnData::AddProject( const std::string& projectRelativePath) { auto it(ProjectsByGUID.find(projectGUID)); - if (it != ProjectsByGUID.end()) + if (it != ProjectsByGUID.end()) { return nullptr; + } it = ProjectsByGUID .insert(ProjectStorage::value_type( projectGUID, @@ -69,17 +73,20 @@ std::string cmSlnData::GetConfigurationTarget( { std::string solutionTarget = solutionConfiguration + "|" + platformName; cm::optional<cmSlnProjectEntry> project = GetProjectByName(projectName); - if (!project) + if (!project) { return platformName; + } std::string projectTarget = project->GetProjectConfiguration(solutionTarget); - if (projectTarget.empty()) + if (projectTarget.empty()) { return platformName; + } std::vector<std::string> targetElements = cmSystemTools::SplitString(projectTarget, '|'); - if (targetElements.size() != 2) + if (targetElements.size() != 2) { return platformName; + } return targetElements[1]; } diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 0c92a96..756245d 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -80,16 +80,18 @@ bool cmVisualStudioSlnParser::ParsedLine::IsKeyValuePair() const std::string cmVisualStudioSlnParser::ParsedLine::GetArgVerbatim() const { - if (this->Arg.second) + if (this->Arg.second) { return Quote + this->Arg.first + Quote; + } return this->Arg.first; } const std::string& cmVisualStudioSlnParser::ParsedLine::GetValue( size_t idxValue) const { - if (idxValue < this->Values.size()) + if (idxValue < this->Values.size()) { return this->Values[idxValue].first; + } return BadString; } @@ -98,8 +100,9 @@ std::string cmVisualStudioSlnParser::ParsedLine::GetValueVerbatim( { if (idxValue < this->Values.size()) { const StringData& data = this->Values[idxValue]; - if (data.second) + if (data.second) { return Quote + data.first + Quote; + } return data.first; } return BadString; @@ -145,8 +148,9 @@ private: cmVisualStudioSlnParser::State::State(DataGroupSet requestedData) : RequestedData(requestedData) { - if (this->RequestedData.test(DataGroupProjectDependenciesBit)) + if (this->RequestedData.test(DataGroupProjectDependenciesBit)) { this->RequestedData.set(DataGroupProjectsBit); + } this->Stack.push(FileStateStart); } @@ -214,8 +218,9 @@ bool cmVisualStudioSlnParser::State::Process( return false; } this->Stack.push(FileStateProject); - } else + } else { this->IgnoreUntilTag("EndProject"); + } } else if (line.GetTag().compare("Global") == 0) { this->Stack.push(FileStateGlobal); @@ -229,69 +234,76 @@ bool cmVisualStudioSlnParser::State::Process( } break; case FileStateProject: - if (line.GetTag().compare("EndProject") == 0) + if (line.GetTag().compare("EndProject") == 0) { this->Stack.pop(); - else if (line.GetTag().compare("ProjectSection") == 0) { + } else if (line.GetTag().compare("ProjectSection") == 0) { if (line.GetArg().compare("ProjectDependencies") == 0 && line.GetValue(0).compare("postProject") == 0) { - if (this->RequestedData.test(DataGroupProjectDependenciesBit)) + if (this->RequestedData.test(DataGroupProjectDependenciesBit)) { this->Stack.push(FileStateProjectDependencies); - else + } else { this->IgnoreUntilTag("EndProjectSection"); - } else + } + } else { this->IgnoreUntilTag("EndProjectSection"); + } } else { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } break; case FileStateProjectDependencies: - if (line.GetTag().compare("EndProjectSection") == 0) + if (line.GetTag().compare("EndProjectSection") == 0) { this->Stack.pop(); - else if (line.IsKeyValuePair()) + } else if (line.IsKeyValuePair()) { // implement dependency storing here, once needed ; - else { + } else { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } break; case FileStateGlobal: - if (line.GetTag().compare("EndGlobal") == 0) + if (line.GetTag().compare("EndGlobal") == 0) { this->Stack.pop(); - else if (line.GetTag().compare("GlobalSection") == 0) { + } else if (line.GetTag().compare("GlobalSection") == 0) { if (line.GetArg().compare("SolutionConfigurationPlatforms") == 0 && line.GetValue(0).compare("preSolution") == 0) { - if (this->RequestedData.test(DataGroupSolutionConfigurationsBit)) + if (this->RequestedData.test(DataGroupSolutionConfigurationsBit)) { this->Stack.push(FileStateSolutionConfigurations); - else + } else { this->IgnoreUntilTag("EndGlobalSection"); + } } else if (line.GetArg().compare("ProjectConfigurationPlatforms") == 0 && line.GetValue(0).compare("postSolution") == 0) { - if (this->RequestedData.test(DataGroupProjectConfigurationsBit)) + if (this->RequestedData.test(DataGroupProjectConfigurationsBit)) { this->Stack.push(FileStateProjectConfigurations); - else + } else { this->IgnoreUntilTag("EndGlobalSection"); + } } else if (line.GetArg().compare("NestedProjects") == 0 && line.GetValue(0).compare("preSolution") == 0) { - if (this->RequestedData.test(DataGroupSolutionFiltersBit)) + if (this->RequestedData.test(DataGroupSolutionFiltersBit)) { this->Stack.push(FileStateSolutionFilters); - else + } else { this->IgnoreUntilTag("EndGlobalSection"); - } else if (this->RequestedData.test(DataGroupGenericGlobalSectionsBit)) + } + } else if (this->RequestedData.test( + DataGroupGenericGlobalSectionsBit)) { this->Stack.push(FileStateGlobalSection); - else + } else { this->IgnoreUntilTag("EndGlobalSection"); + } } else { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } break; case FileStateSolutionConfigurations: - if (line.GetTag().compare("EndGlobalSection") == 0) + if (line.GetTag().compare("EndGlobalSection") == 0) { this->Stack.pop(); - else if (line.IsKeyValuePair()) { + } else if (line.IsKeyValuePair()) { output.AddConfiguration(line.GetValue(0)); } else { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); @@ -299,9 +311,9 @@ bool cmVisualStudioSlnParser::State::Process( } break; case FileStateProjectConfigurations: - if (line.GetTag().compare("EndGlobalSection") == 0) + if (line.GetTag().compare("EndGlobalSection") == 0) { this->Stack.pop(); - else if (line.IsKeyValuePair()) { + } else if (line.IsKeyValuePair()) { std::vector<std::string> tagElements = cmSystemTools::SplitString(line.GetTag(), '.'); if (tagElements.size() != 3 && tagElements.size() != 4) { @@ -330,23 +342,23 @@ bool cmVisualStudioSlnParser::State::Process( } break; case FileStateSolutionFilters: - if (line.GetTag().compare("EndGlobalSection") == 0) + if (line.GetTag().compare("EndGlobalSection") == 0) { this->Stack.pop(); - else if (line.IsKeyValuePair()) + } else if (line.IsKeyValuePair()) { // implement filter storing here, once needed ; - else { + } else { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } break; case FileStateGlobalSection: - if (line.GetTag().compare("EndGlobalSection") == 0) + if (line.GetTag().compare("EndGlobalSection") == 0) { this->Stack.pop(); - else if (line.IsKeyValuePair()) + } else if (line.IsKeyValuePair()) { // implement section storing here, once needed ; - else { + } else { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } @@ -479,34 +491,41 @@ bool cmVisualStudioSlnParser::ParseImpl(std::istream& input, cmSlnData& output, { std::string line; // Does the .sln start with a Byte Order Mark? - if (!this->ParseBOM(input, line, state)) + if (!this->ParseBOM(input, line, state)) { return false; + } do { line = cmTrimWhitespace(line); - if (line.empty()) + if (line.empty()) { continue; + } ParsedLine parsedLine; switch (state.NextLineFormat()) { case LineMultiValueTag: - if (!this->ParseMultiValueTag(line, parsedLine, state)) + if (!this->ParseMultiValueTag(line, parsedLine, state)) { return false; + } break; case LineSingleValueTag: - if (!this->ParseSingleValueTag(line, parsedLine, state)) + if (!this->ParseSingleValueTag(line, parsedLine, state)) { return false; + } break; case LineKeyValuePair: - if (!this->ParseKeyValuePair(line, parsedLine, state)) + if (!this->ParseKeyValuePair(line, parsedLine, state)) { return false; + } break; case LineVerbatim: parsedLine.CopyVerbatim(line); break; } - if (parsedLine.IsComment()) + if (parsedLine.IsComment()) { continue; - if (!state.Process(parsedLine, output, this->LastResult)) + } + if (!state.Process(parsedLine, output, this->LastResult)) { return false; + } } while (state.ReadLine(input, line)); return state.Finished(this->LastResult); } @@ -525,8 +544,9 @@ bool cmVisualStudioSlnParser::ParseBOM(std::istream& input, std::string& line, this->LastResult.SetError(ResultErrorReadingInput, 1); return false; } - if (!this->LastResult.HadBOM) + if (!this->LastResult.HadBOM) { line = bom + line; // it wasn't a BOM, prepend it to first line + } return true; } @@ -536,8 +556,9 @@ bool cmVisualStudioSlnParser::ParseMultiValueTag(const std::string& line, { size_t idxEqualSign = line.find('='); auto fullTag = cm::string_view(line).substr(0, idxEqualSign); - if (!this->ParseTag(fullTag, parsedLine, state)) + if (!this->ParseTag(fullTag, parsedLine, state)) { return false; + } if (idxEqualSign != std::string::npos) { size_t idxFieldStart = idxEqualSign + 1; if (idxFieldStart < line.size()) { @@ -553,17 +574,20 @@ bool cmVisualStudioSlnParser::ParseMultiValueTag(const std::string& line, state.GetCurrentLine()); return false; } - } else if (line[idxParsing] == ',' && !inQuotes) + } else if (line[idxParsing] == ',' && !inQuotes) { fieldOver = true; - else if (line[idxParsing] == '"') + } else if (line[idxParsing] == '"') { inQuotes = !inQuotes; + } if (fieldOver) { if (!this->ParseValue( line.substr(idxFieldStart, idxParsing - idxFieldStart), - parsedLine)) + parsedLine)) { return false; - if (idxParsing == std::string::npos) + } + if (idxParsing == std::string::npos) { break; // end of last field + } idxFieldStart = idxParsing + 1; } ++idxParsing; @@ -579,11 +603,13 @@ bool cmVisualStudioSlnParser::ParseSingleValueTag(const std::string& line, { size_t idxEqualSign = line.find('='); auto fullTag = cm::string_view(line).substr(0, idxEqualSign); - if (!this->ParseTag(fullTag, parsedLine, state)) + if (!this->ParseTag(fullTag, parsedLine, state)) { return false; + } if (idxEqualSign != std::string::npos) { - if (!this->ParseValue(line.substr(idxEqualSign + 1), parsedLine)) + if (!this->ParseValue(line.substr(idxEqualSign + 1), parsedLine)) { return false; + } } return true; } @@ -628,8 +654,9 @@ bool cmVisualStudioSlnParser::ParseTag(cm::string_view fullTag, return false; } parsedLine.SetQuotedArg(arg.substr(1, arg.size() - 2)); - } else + } else { parsedLine.SetArg(arg); + } return true; } @@ -637,11 +664,12 @@ bool cmVisualStudioSlnParser::ParseValue(const std::string& value, ParsedLine& parsedLine) { const std::string& trimmed = cmTrimWhitespace(value); - if (trimmed.empty()) + if (trimmed.empty()) { parsedLine.AddValue(trimmed); - else if (trimmed.front() == '"' && trimmed.back() == '"') + } else if (trimmed.front() == '"' && trimmed.back() == '"') { parsedLine.AddQuotedValue(trimmed.substr(1, trimmed.size() - 2)); - else + } else { parsedLine.AddValue(trimmed); + } return true; } |