mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-01-26 19:09:06 +00:00
clang-tidy: address google-readability-casting lints
At least those involving `static_cast`.
This commit is contained in:
parent
9409e5c04f
commit
6ff03d463f
@ -707,7 +707,7 @@ bool cmCPackDebGenerator::createDebPackages()
|
||||
&cmCPackDebGenerator::createDbgsymDDeb) &&
|
||||
retval;
|
||||
}
|
||||
return int(retval);
|
||||
return static_cast<int>(retval);
|
||||
}
|
||||
|
||||
bool cmCPackDebGenerator::createDeb()
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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]++;
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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, ";"));
|
||||
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -115,7 +115,7 @@ private:
|
||||
|
||||
void Next()
|
||||
{
|
||||
this->C = char(this->Input.get());
|
||||
this->C = static_cast<char>(this->Input.get());
|
||||
if (this->Input.bad()) {
|
||||
this->ErrorExit("Unexpected end of file.");
|
||||
}
|
||||
|
||||
@ -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<std::size_t>(resourceGroupCount)) {
|
||||
std::cout
|
||||
<< "CTEST_RESOURCE_GROUP_COUNT does not match expected resource groups"
|
||||
<< std::endl
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user