From 6ff03d463f40176389943100690cf1ca8593d739 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 17 May 2022 13:10:30 -0400 Subject: clang-tidy: address `google-readability-casting` lints At least those involving `static_cast`. --- Source/CPack/cmCPackDebGenerator.cxx | 2 +- Source/CTest/cmCTestBinPacker.cxx | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 2 +- Source/CTest/cmCTestGIT.cxx | 3 +- Source/CTest/cmCTestMemCheckHandler.cxx | 3 +- Source/CTest/cmCTestP4.cxx | 3 +- Source/CTest/cmCTestSubmitHandler.cxx | 6 +-- Source/CTest/cmCTestTestHandler.cxx | 3 +- Source/CursesDialog/cmCursesMainForm.cxx | 2 +- Source/cmCTest.cxx | 17 +++++---- Source/cmConditionEvaluator.cxx | 43 +++++++++++++--------- Source/cmCryptoHash.cxx | 6 +-- Source/cmFileAPI.cxx | 2 +- Source/cmFileInstaller.cxx | 2 +- Source/cmForEachCommand.cxx | 4 +- Source/cmGeneratedFileStream.cxx | 3 +- Source/cmListCommand.cxx | 11 +++--- Source/cmMakefile.cxx | 2 +- Source/cmMakefileProfilingData.cxx | 4 +- Source/cmPolicies.cxx | 4 +- Source/cmProcessTools.cxx | 8 ++-- Source/cmProjectCommand.cxx | 4 +- Source/cmTargetIncludeDirectoriesCommand.cxx | 2 +- Source/cmTimestamp.cxx | 2 +- Source/cmTransformDepfile.cxx | 4 +- Source/cmUuid.cxx | 13 ++++--- Source/cmake.cxx | 2 +- Source/cmakemain.cxx | 4 +- Tests/CMakeLib/run_compile_commands.cxx | 2 +- .../CTestResourceAllocation/ctresalloc.cxx | 3 +- 30 files changed, 95 insertions(+), 73 deletions(-) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 8e5e637..a3b9434 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -707,7 +707,7 @@ bool cmCPackDebGenerator::createDebPackages() &cmCPackDebGenerator::createDbgsymDDeb) && retval; } - return int(retval); + return static_cast(retval); } bool cmCPackDebGenerator::createDeb() diff --git a/Source/CTest/cmCTestBinPacker.cxx b/Source/CTest/cmCTestBinPacker.cxx index e21b14d..239499c 100644 --- a/Source/CTest/cmCTestBinPacker.cxx +++ b/Source/CTest/cmCTestBinPacker.cxx @@ -108,7 +108,7 @@ static bool AllocateCTestResources( // Do the actual allocation return AllocateCTestResources( - resources, resourcesSorted, std::size_t(0), allocationsPtr); + resources, resourcesSorted, static_cast(0), allocationsPtr); } class RoundRobinAllocationStrategy diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index aef58c5..f7c6a9c 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2210,7 +2210,7 @@ int cmCTestCoverageHandler::GetLabelId(std::string const& label) { auto i = this->LabelIdMap.find(label); if (i == this->LabelIdMap.end()) { - int n = int(this->Labels.size()); + int n = static_cast(this->Labels.size()); this->Labels.push_back(label); LabelIdMapType::value_type entry(label, n); i = this->LabelIdMap.insert(entry).first; diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 0b09f47..b2fb069 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -535,7 +535,8 @@ private: void NextSection() { - this->Section = SectionType((this->Section + 1) % SectionCount); + this->Section = + static_cast((this->Section + 1) % SectionCount); this->Separator = SectionSep[this->Section]; if (this->Section == SectionHeader) { this->GIT->DoRevision(this->Rev, this->Changes); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 2d8276a..788845b 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -1207,7 +1207,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckCudaOutput( if (failure >= 0) { ostr << "" << this->ResultStrings[failure] << " "; - if (results.empty() || unsigned(failure) > results.size() - 1) { + if (results.empty() || + static_cast(failure) > results.size() - 1) { results.push_back(1); } else { results[failure]++; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index ce8b7c7..0e67c41 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -248,7 +248,8 @@ private: this->Rev = Revision(); } - this->Section = SectionType((this->Section + 1) % SectionCount); + this->Section = + static_cast((this->Section + 1) % SectionCount); } void DoHeaderLine() diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index e5b18f4..da085a6 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -124,7 +124,7 @@ void cmCTestSubmitHandler::Initialize() { // We submit all available parts by default. for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount; - p = cmCTest::Part(p + 1)) { + p = static_cast(p + 1)) { this->SubmitPart[p] = true; } this->HasWarnings = false; @@ -810,7 +810,7 @@ int cmCTestSubmitHandler::ProcessHandler() // Query parts for files to submit. for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount; - p = cmCTest::Part(p + 1)) { + p = static_cast(p + 1)) { // Skip parts we are not submitting. if (!this->SubmitPart[p]) { continue; @@ -894,7 +894,7 @@ void cmCTestSubmitHandler::SelectParts(std::set const& parts) { // Check whether each part is selected. for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount; - p = cmCTest::Part(p + 1)) { + p = static_cast(p + 1)) { this->SubmitPart[p] = parts.find(p) != parts.end(); } } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 696a5ea..248533a 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -586,7 +586,8 @@ void cmCTestTestHandler::LogTestSummary(const std::vector& passed, { std::size_t total = passed.size() + failed.size(); - float percent = float(passed.size()) * 100.0f / float(total); + float percent = + static_cast(passed.size()) * 100.0f / static_cast(total); if (!failed.empty() && percent > 99) { percent = 99; } diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 8381e86..5b1a433 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -973,7 +973,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) } } } - if (size_t(findex) >= 3 * this->NumberOfVisibleEntries - 1) { + if (static_cast(findex) >= 3 * this->NumberOfVisibleEntries - 1) { set_current_field(this->Form, this->Fields[2]); } else if (new_page(this->Fields[findex + 1])) { form_driver(this->Form, REQ_NEXT_PAGE); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 3673dfb..d4c0e77 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -322,7 +322,7 @@ std::string cmCTest::DecodeURL(const std::string& in) for (const char* c = in.c_str(); *c; ++c) { if (*c == '%' && isxdigit(*(c + 1)) && isxdigit(*(c + 2))) { char buf[3] = { *(c + 1), *(c + 2), 0 }; - out.append(1, char(strtoul(buf, nullptr, 16))); + out.append(1, static_cast(strtoul(buf, nullptr, 16))); c += 2; } else { out.append(1, *c); @@ -357,7 +357,7 @@ cmCTest::cmCTest() this->Impl->Parts[PartDone].SetName("Done"); // Fill the part name-to-id map. - for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; p != PartCount; p = static_cast(p + 1)) { this->Impl ->PartMap[cmSystemTools::LowerCase(this->Impl->Parts[p].GetName())] = p; } @@ -643,7 +643,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) std::string src_dir = this->GetCTestConfiguration("SourceDirectory"); std::string bld_dir = this->GetCTestConfiguration("BuildDirectory"); this->Impl->BuildID = ""; - for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; p != PartCount; p = static_cast(p + 1)) { this->Impl->Parts[p].SubmitFiles.clear(); } @@ -797,7 +797,7 @@ int cmCTest::GetTestModel() const bool cmCTest::SetTest(const std::string& ttype, bool report) { if (cmSystemTools::LowerCase(ttype) == "all") { - for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; p != PartCount; p = static_cast(p + 1)) { this->Impl->Parts[p].Enable(); } return true; @@ -935,7 +935,8 @@ int cmCTest::ProcessSteps() bool notest = true; int update_count = 0; - for (Part p = PartStart; notest && p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; notest && p != PartCount; + p = static_cast(p + 1)) { notest = !this->Impl->Parts[p]; } if (this->Impl->Parts[PartUpdate] && @@ -2019,7 +2020,8 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i++; long outputSize; if (cmStrToLong(args[i], &outputSize)) { - this->Impl->TestHandler.SetTestOutputSizePassed(int(outputSize)); + this->Impl->TestHandler.SetTestOutputSizePassed( + static_cast(outputSize)); } else { cmCTestLog(this, WARNING, "Invalid value for '--test-output-size-passed': " << args[i] @@ -2030,7 +2032,8 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i++; long outputSize; if (cmStrToLong(args[i], &outputSize)) { - this->Impl->TestHandler.SetTestOutputSizeFailed(int(outputSize)); + this->Impl->TestHandler.SetTestOutputSizeFailed( + static_cast(outputSize)); } else { cmCTestLog(this, WARNING, "Invalid value for '--test-output-size-failed': " << args[i] diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 8e479c5..8df4704 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -95,7 +95,8 @@ struct cmRt2CtSelector std::string bool2string(bool const value) { - return std::string(std::size_t(1), static_cast('0' + int(value))); + return std::string(static_cast(1), + static_cast('0' + static_cast(value))); } bool looksLikeSpecialVariable(const std::string& var, @@ -141,15 +142,17 @@ public: { this->current = std::next(this->current); this->next = - std::next(this->current, difference_type(this->current != args.end())); + std::next(this->current, + static_cast(this->current != args.end())); return *this; } private: CurrentAndNextIter(base_t& args) : current(args.begin()) - , next(std::next(this->current, - difference_type(this->current != args.end()))) + , next( + std::next(this->current, + static_cast(this->current != args.end()))) { } }; @@ -167,19 +170,21 @@ public: { this->current = std::next(this->current); this->next = - std::next(this->current, difference_type(this->current != args.end())); - this->nextnext = - std::next(this->next, difference_type(this->next != args.end())); + std::next(this->current, + static_cast(this->current != args.end())); + this->nextnext = std::next( + this->next, static_cast(this->next != args.end())); return *this; } private: CurrentAndTwoMoreIter(base_t& args) : current(args.begin()) - , next(std::next(this->current, - difference_type(this->current != args.end()))) - , nextnext( - std::next(this->next, difference_type(this->next != args.end()))) + , next( + std::next(this->current, + static_cast(this->current != args.end()))) + , nextnext(std::next( + this->next, static_cast(this->next != args.end()))) { } }; @@ -580,7 +585,8 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, // does a command exist else if (this->IsKeyword(keyCOMMAND, *args.current)) { newArgs.ReduceOneArg( - bool(this->Makefile.GetState()->GetCommand(args.next->GetValue())), + static_cast( + this->Makefile.GetState()->GetCommand(args.next->GetValue())), args); } // does a policy exist @@ -591,8 +597,9 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, } // does a target exist else if (this->IsKeyword(keyTARGET, *args.current)) { - newArgs.ReduceOneArg( - bool(this->Makefile.FindTargetToUse(args.next->GetValue())), args); + newArgs.ReduceOneArg(static_cast(this->Makefile.FindTargetToUse( + args.next->GetValue())), + args); } // is a variable defined else if (this->IsKeyword(keyDEFINED, *args.current)) { @@ -607,7 +614,8 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, else if (looksLikeSpecialVariable(var, "CACHE"_s, varNameLen)) { const auto cache = args.next->GetValue().substr(6, varNameLen - 7); - result = bool(this->Makefile.GetState()->GetCacheEntryValue(cache)); + result = static_cast( + this->Makefile.GetState()->GetCacheEntryValue(cache)); } else { @@ -620,8 +628,9 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, if (policy64IsOld) { continue; } - newArgs.ReduceOneArg(bool(this->Makefile.GetTest(args.next->GetValue())), - args); + newArgs.ReduceOneArg( + static_cast(this->Makefile.GetTest(args.next->GetValue())), + args); } } return true; diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 9f369b9..ff9ab0f 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -83,15 +83,15 @@ std::unique_ptr cmCryptoHash::New(cm::string_view algo) bool cmCryptoHash::IntFromHexDigit(char input, char& output) { if (input >= '0' && input <= '9') { - output = char(input - '0'); + output = static_cast(input - '0'); return true; } if (input >= 'a' && input <= 'f') { - output = char(input - 'a' + 0xA); + output = static_cast(input - 'a' + 0xA); return true; } if (input >= 'A' && input <= 'F') { - output = char(input - 'A' + 0xA); + output = static_cast(input - 'A' + 0xA); return true; } return false; diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index c1df992..7f8374d 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -417,7 +417,7 @@ const char* cmFileAPI::ObjectKindName(ObjectKind kind) "toolchains", // "__test" // }; - return objectKindNames[size_t(kind)]; + return objectKindNames[static_cast(kind)]; } std::string cmFileAPI::ObjectName(Object const& o) diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx index b0a9ecc..5cfb2cf 100644 --- a/Source/cmFileInstaller.cxx +++ b/Source/cmFileInstaller.cxx @@ -433,7 +433,7 @@ bool cmFileInstaller::HandleInstallDestination() } } destination = sdestdir + destination.substr(skip); - this->DestDirLength = int(sdestdir.size()); + this->DestDirLength = static_cast(sdestdir.size()); } // check if default dir creation permissions were set diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index dcb3626..da82675 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -460,8 +460,8 @@ bool cmForEachCommand(std::vector const& args, // in the `fb->Args` vector. The first item is the iteration variable // name... const std::size_t iter_cnt = 2u + - int(start < stop) * (stop - start) / std::abs(step) + - int(start > stop) * (start - stop) / std::abs(step); + static_cast(start < stop) * (stop - start) / std::abs(step) + + static_cast(start > stop) * (start - stop) / std::abs(step); fb->Args.resize(iter_cnt); fb->Args.front() = args.front(); auto cc = start; diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index a52e66a..b529b8f 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -44,7 +44,8 @@ cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name, #endif if (encoding == codecvt::UTF8_WITH_BOM) { // Write the BOM encoding header into the file - char magic[] = { char(0xEF), char(0xBB), char(0xBF) }; + char magic[] = { static_cast(0xEF), static_cast(0xBB), + static_cast(0xBF) }; this->write(magic, 3); } } diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 56345df..ebd089b 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -229,7 +229,7 @@ bool HandleAppendCommand(std::vector const& args, // If `listString` or `args` is empty, no need to append `;`, // then index is going to be `1` and points to the end-of-string ";" auto const offset = - std::string::size_type(listString.empty() || args.empty()); + static_cast(listString.empty() || args.empty()); listString += &";"[offset] + cmJoin(cmMakeRange(args).advance(2), ";"); makefile.AddDefinition(listName, listString); @@ -255,7 +255,7 @@ bool HandlePrependCommand(std::vector const& args, // If `listString` or `args` is empty, no need to append `;`, // then `offset` is going to be `1` and points to the end-of-string ";" auto const offset = - std::string::size_type(listString.empty() || args.empty()); + static_cast(listString.empty() || args.empty()); listString.insert(0, cmJoin(cmMakeRange(args).advance(2), ";") + &";"[offset]); @@ -1346,7 +1346,7 @@ bool HandleSublistCommand(std::vector const& args, using size_type = decltype(varArgsExpanded)::size_type; - if (start < 0 || size_type(start) >= varArgsExpanded.size()) { + if (start < 0 || static_cast(start) >= varArgsExpanded.size()) { status.SetError(cmStrCat("begin index: ", start, " is out of range 0 - ", varArgsExpanded.size() - 1)); return false; @@ -1357,9 +1357,10 @@ bool HandleSublistCommand(std::vector const& args, } const size_type end = - (length == -1 || size_type(start + length) > varArgsExpanded.size()) + (length == -1 || + static_cast(start + length) > varArgsExpanded.size()) ? varArgsExpanded.size() - : size_type(start + length); + : static_cast(start + length); std::vector sublist(varArgsExpanded.begin() + start, varArgsExpanded.begin() + end); status.GetMakefile().AddDefinition(variableName, cmJoin(sublist, ";")); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4bc563f..b5df459 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4507,7 +4507,7 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm) const /* Record the setting of every policy. */ using PolicyID = cmPolicies::PolicyID; for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT; - pid = PolicyID(pid + 1)) { + pid = static_cast(pid + 1)) { pm.Set(pid, this->GetPolicyStatus(pid)); } } diff --git a/Source/cmMakefileProfilingData.cxx b/Source/cmMakefileProfilingData.cxx index 337f78b..1cd97c9 100644 --- a/Source/cmMakefileProfilingData.cxx +++ b/Source/cmMakefileProfilingData.cxx @@ -60,7 +60,7 @@ void cmMakefileProfilingData::StartEntry(const cmListFileFunction& lff, v["ph"] = "B"; v["name"] = lff.LowerCaseName(); v["cat"] = "cmake"; - v["ts"] = Json::Value::UInt64( + v["ts"] = static_cast( std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()) .count()); @@ -98,7 +98,7 @@ void cmMakefileProfilingData::StopEntry() cmsys::SystemInformation info; Json::Value v; v["ph"] = "E"; - v["ts"] = Json::Value::UInt64( + v["ts"] = static_cast( std::chrono::duration_cast( std::chrono::steady_clock::now().time_since_epoch()) .count()); diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index e31de1c..03ae44e 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -43,7 +43,7 @@ static bool stringToId(const char* input, cmPolicies::PolicyID& pid) if (id >= cmPolicies::CMPCOUNT) { return false; } - pid = cmPolicies::PolicyID(id); + pid = static_cast(id); return true; } @@ -279,7 +279,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, // now loop over all the policies and set them as appropriate std::vector ancientPolicies; for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT; - pid = PolicyID(pid + 1)) { + pid = static_cast(pid + 1)) { if (isPolicyNewerThan(pid, majorVer, minorVer, patchVer)) { if (cmPolicies::GetPolicyStatus(pid) == cmPolicies::REQUIRED_ALWAYS) { ancientPolicies.push_back(pid); diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index 9ebf5b7..9e7854b 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -21,12 +21,12 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) { if (out && p == cmsysProcess_Pipe_STDOUT) { processOutput.DecodeText(data, length, strdata, 1); - if (!out->Process(strdata.c_str(), int(strdata.size()))) { + if (!out->Process(strdata.c_str(), static_cast(strdata.size()))) { out = nullptr; } } else if (err && p == cmsysProcess_Pipe_STDERR) { processOutput.DecodeText(data, length, strdata, 2); - if (!err->Process(strdata.c_str(), int(strdata.size()))) { + if (!err->Process(strdata.c_str(), static_cast(strdata.size()))) { err = nullptr; } } @@ -34,13 +34,13 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, if (out) { processOutput.DecodeText(std::string(), strdata, 1); if (!strdata.empty()) { - out->Process(strdata.c_str(), int(strdata.size())); + out->Process(strdata.c_str(), static_cast(strdata.size())); } } if (err) { processOutput.DecodeText(std::string(), strdata, 2); if (!strdata.empty()) { - err->Process(strdata.c_str(), int(strdata.size())); + err->Process(strdata.c_str(), static_cast(strdata.size())); } } cmsysProcess_WaitForExit(cp, nullptr); diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 04d99c9..4b65fb9 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -242,9 +242,9 @@ bool cmProjectCommand(std::vector const& args, const int vc = std::sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1], &v[2], &v[3]); for (auto i = 0u; i < MAX_VERSION_COMPONENTS; ++i) { - if (int(i) < vc) { + if (static_cast(i) < vc) { std::snprintf(vb[i], maxIntLength, "%u", v[i]); - version_string += &"."[std::size_t(i == 0)]; + version_string += &"."[static_cast(i == 0)]; version_string += vb[i]; version_components[i] = vb[i]; } else { diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index f31501e..b4b4319 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -99,7 +99,7 @@ bool cmTargetIncludeDirectoriesCommand(std::vector const& args, { return TargetIncludeDirectoriesImpl(status).HandleArguments( args, "INCLUDE_DIRECTORIES", - TargetIncludeDirectoriesImpl::ArgumentFlags( + static_cast( TargetIncludeDirectoriesImpl::PROCESS_BEFORE | TargetIncludeDirectoriesImpl::PROCESS_AFTER | TargetIncludeDirectoriesImpl::PROCESS_SYSTEM)); diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index e2b6c20..677fdb6 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -50,7 +50,7 @@ std::string cmTimestamp::CurrentTime(const std::string& formatString, // SOURCE_DATE_EPOCH has only a resolution in the seconds range microseconds = 0; } - if (currentTimeT == time_t(-1)) { + if (currentTimeT == static_cast(-1)) { return std::string(); } diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx index 81a6507..12c121f 100644 --- a/Source/cmTransformDepfile.cxx +++ b/Source/cmTransformDepfile.cxx @@ -89,7 +89,9 @@ void WriteMSBuildAdditionalInputs(cmsys::ofstream& fout, } // Write a UTF-8 BOM so MSBuild knows the encoding when reading the file. - static const char utf8bom[] = { char(0xEF), char(0xBB), char(0xBF) }; + static const char utf8bom[] = { static_cast(0xEF), + static_cast(0xBB), + static_cast(0xBF) }; fout.write(utf8bom, sizeof(utf8bom)); // Write the format expected by MSBuild CustomBuild AdditionalInputs. diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx index dc018b1..6688668 100644 --- a/Source/cmUuid.cxx +++ b/Source/cmUuid.cxx @@ -59,7 +59,7 @@ std::string cmUuid::FromDigest(const unsigned char* digest, memcpy(uuid, digest, 16); uuid[6] &= 0xF; - uuid[6] |= byte_t(version << 4); + uuid[6] |= static_cast(version << 4); uuid[8] &= 0x3F; uuid[8] |= 0x80; @@ -118,7 +118,8 @@ std::string cmUuid::ByteToHex(unsigned char byte) const for (int i = 0; i < 2; ++i) { unsigned char rest = byte % 16; byte /= 16; - char c = (rest < 0xA) ? char('0' + rest) : char('a' + (rest - 0xA)); + char c = (rest < 0xA) ? static_cast('0' + rest) + : static_cast('a' + (rest - 0xA)); result.at(1 - i) = c; } @@ -143,7 +144,7 @@ bool cmUuid::StringToBinaryImpl(std::string const& input, return false; } - output.push_back(char(c1 << 4 | c2)); + output.push_back(static_cast(c1 << 4 | c2)); } return true; @@ -152,15 +153,15 @@ bool cmUuid::StringToBinaryImpl(std::string const& input, bool cmUuid::IntFromHexDigit(char input, char& output) const { if (input >= '0' && input <= '9') { - output = char(input - '0'); + output = static_cast(input - '0'); return true; } if (input >= 'a' && input <= 'f') { - output = char(input - 'a' + 0xA); + output = static_cast(input - 'a' + 0xA); return true; } if (input >= 'A' && input <= 'F') { - output = char(input - 'A' + 0xA); + output = static_cast(input - 'A' + 0xA); return true; } return false; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6d99a3c..d9ae75a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2551,7 +2551,7 @@ void cmake::AddCacheEntry(const std::string& key, cmValue value, const char* helpString, int type) { this->State->AddCacheEntry(key, value, helpString, - cmStateEnums::CacheEntryType(type)); + static_cast(type)); this->UnwatchUnusedCli(key); if (key == "CMAKE_WARN_DEPRECATED"_s) { diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 19b922b..97c275e 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -409,7 +409,7 @@ int extract_job_number(std::string const& command, } else if (numJobs > INT_MAX) { std::cerr << "The value is too large.\n\n"; } else { - jobs = int(numJobs); + jobs = static_cast(numJobs); } } else { std::cerr << "'" << command << "' invalid number '" << jobString @@ -594,7 +594,7 @@ int do_build(int ac, char const* const* av) "is too large.\n\n"; dir.clear(); } else { - jobs = int(numJobs); + jobs = static_cast(numJobs); } } else { std::cerr << "'CMAKE_BUILD_PARALLEL_LEVEL' environment variable\n" diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 0ebe00e..0585774 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -115,7 +115,7 @@ private: void Next() { - this->C = char(this->Input.get()); + this->C = static_cast(this->Input.get()); if (this->Input.bad()) { this->ErrorExit("Unexpected end of file."); } diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx index daf8a2d..5c6c8d8 100644 --- a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx +++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx @@ -89,7 +89,8 @@ static int doWrite(int argc, char const* const* argv) return 1; } int resourceGroupCount = std::atoi(resourceGroupCountEnv); - if (resourceGroups.size() != std::size_t(resourceGroupCount)) { + if (resourceGroups.size() != + static_cast(resourceGroupCount)) { std::cout << "CTEST_RESOURCE_GROUP_COUNT does not match expected resource groups" << std::endl -- cgit v0.12