summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-05-17 17:10:30 (GMT)
committerBrad King <brad.king@kitware.com>2022-05-24 13:09:43 (GMT)
commit6ff03d463f40176389943100690cf1ca8593d739 (patch)
tree09ad876ecf9d635108df5374f8c0f5ebb4400506 /Source
parent9409e5c04f0a534b53ce2f0e0a81c5e7e70c38f1 (diff)
downloadCMake-6ff03d463f40176389943100690cf1ca8593d739.zip
CMake-6ff03d463f40176389943100690cf1ca8593d739.tar.gz
CMake-6ff03d463f40176389943100690cf1ca8593d739.tar.bz2
clang-tidy: address `google-readability-casting` lints
At least those involving `static_cast`.
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx2
-rw-r--r--Source/CTest/cmCTestBinPacker.cxx2
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx2
-rw-r--r--Source/CTest/cmCTestGIT.cxx3
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx3
-rw-r--r--Source/CTest/cmCTestP4.cxx3
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx6
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx3
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx2
-rw-r--r--Source/cmCTest.cxx17
-rw-r--r--Source/cmConditionEvaluator.cxx43
-rw-r--r--Source/cmCryptoHash.cxx6
-rw-r--r--Source/cmFileAPI.cxx2
-rw-r--r--Source/cmFileInstaller.cxx2
-rw-r--r--Source/cmForEachCommand.cxx4
-rw-r--r--Source/cmGeneratedFileStream.cxx3
-rw-r--r--Source/cmListCommand.cxx11
-rw-r--r--Source/cmMakefile.cxx2
-rw-r--r--Source/cmMakefileProfilingData.cxx4
-rw-r--r--Source/cmPolicies.cxx4
-rw-r--r--Source/cmProcessTools.cxx8
-rw-r--r--Source/cmProjectCommand.cxx4
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx2
-rw-r--r--Source/cmTimestamp.cxx2
-rw-r--r--Source/cmTransformDepfile.cxx4
-rw-r--r--Source/cmUuid.cxx13
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/cmakemain.cxx4
28 files changed, 92 insertions, 71 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<int>(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<AllocationStrategy>(
- resources, resourcesSorted, std::size_t(0), allocationsPtr);
+ resources, resourcesSorted, static_cast<std::size_t>(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<int>(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<SectionType>((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 << "<b>" << this->ResultStrings[failure] << "</b> ";
- if (results.empty() || unsigned(failure) > results.size() - 1) {
+ if (results.empty() ||
+ static_cast<unsigned>(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<SectionType>((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<cmCTest::Part>(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<cmCTest::Part>(p + 1)) {
// Skip parts we are not submitting.
if (!this->SubmitPart[p]) {
continue;
@@ -894,7 +894,7 @@ void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> 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<cmCTest::Part>(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<std::string>& passed,
{
std::size_t total = passed.size() + failed.size();
- float percent = float(passed.size()) * 100.0f / float(total);
+ float percent =
+ static_cast<float>(passed.size()) * 100.0f / static_cast<float>(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<size_t>(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<char>(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<Part>(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<Part>(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<Part>(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<Part>(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<int>(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<int>(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<Comp>
std::string bool2string(bool const value)
{
- return std::string(std::size_t(1), static_cast<char>('0' + int(value)));
+ return std::string(static_cast<std::size_t>(1),
+ static_cast<char>('0' + static_cast<int>(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<difference_type>(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<difference_type>(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<difference_type>(this->current != args.end()));
+ this->nextnext = std::next(
+ this->next, static_cast<difference_type>(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<difference_type>(this->current != args.end())))
+ , nextnext(std::next(
+ this->next, static_cast<difference_type>(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<bool>(
+ 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<bool>(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<bool>(
+ 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<bool>(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> 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<char>(input - '0');
return true;
}
if (input >= 'a' && input <= 'f') {
- output = char(input - 'a' + 0xA);
+ output = static_cast<char>(input - 'a' + 0xA);
return true;
}
if (input >= 'A' && input <= 'F') {
- output = char(input - 'A' + 0xA);
+ output = static_cast<char>(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<size_t>(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<int>(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<std::string> 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<int>(start < stop) * (stop - start) / std::abs(step) +
+ static_cast<int>(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<char>(0xEF), static_cast<char>(0xBB),
+ static_cast<char>(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<std::string> 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<std::string::size_type>(listString.empty() || args.empty());
listString += &";"[offset] + cmJoin(cmMakeRange(args).advance(2), ";");
makefile.AddDefinition(listName, listString);
@@ -255,7 +255,7 @@ bool HandlePrependCommand(std::vector<std::string> 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<std::string::size_type>(listString.empty() || args.empty());
listString.insert(0,
cmJoin(cmMakeRange(args).advance(2), ";") + &";"[offset]);
@@ -1346,7 +1346,7 @@ bool HandleSublistCommand(std::vector<std::string> const& args,
using size_type = decltype(varArgsExpanded)::size_type;
- if (start < 0 || size_type(start) >= varArgsExpanded.size()) {
+ if (start < 0 || static_cast<size_type>(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<std::string> const& args,
}
const size_type end =
- (length == -1 || size_type(start + length) > varArgsExpanded.size())
+ (length == -1 ||
+ static_cast<size_type>(start + length) > varArgsExpanded.size())
? varArgsExpanded.size()
- : size_type(start + length);
+ : static_cast<size_type>(start + length);
std::vector<std::string> 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<PolicyID>(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<Json::Value::UInt64>(
std::chrono::duration_cast<std::chrono::microseconds>(
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<Json::Value::UInt64>(
std::chrono::duration_cast<std::chrono::microseconds>(
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<cmPolicies::PolicyID>(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<cmPolicies::PolicyID> ancientPolicies;
for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
- pid = PolicyID(pid + 1)) {
+ pid = static_cast<PolicyID>(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<int>(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<int>(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<int>(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<int>(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<std::string> 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<int>(i) < vc) {
std::snprintf(vb[i], maxIntLength, "%u", v[i]);
- version_string += &"."[std::size_t(i == 0)];
+ version_string += &"."[static_cast<std::size_t>(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<std::string> const& args,
{
return TargetIncludeDirectoriesImpl(status).HandleArguments(
args, "INCLUDE_DIRECTORIES",
- TargetIncludeDirectoriesImpl::ArgumentFlags(
+ static_cast<TargetIncludeDirectoriesImpl::ArgumentFlags>(
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<time_t>(-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<char>(0xEF),
+ static_cast<char>(0xBB),
+ static_cast<char>(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<byte_t>(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<char>('0' + rest)
+ : static_cast<char>('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<char>(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<char>(input - '0');
return true;
}
if (input >= 'a' && input <= 'f') {
- output = char(input - 'a' + 0xA);
+ output = static_cast<char>(input - 'a' + 0xA);
return true;
}
if (input >= 'A' && input <= 'F') {
- output = char(input - 'A' + 0xA);
+ output = static_cast<char>(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<cmStateEnums::CacheEntryType>(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 <jobs> value is too large.\n\n";
} else {
- jobs = int(numJobs);
+ jobs = static_cast<int>(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<int>(numJobs);
}
} else {
std::cerr << "'CMAKE_BUILD_PARALLEL_LEVEL' environment variable\n"