mirror of
https://github.com/openharmony/ark_runtime_core.git
synced 2026-07-19 13:17:49 -04:00
Fix codex warnings.
Signed-off-by: wangyantian <wangyantian@huawei.com>
This commit is contained in:
@@ -592,9 +592,9 @@ AnnotationItem *AsmEmitter::CreateAnnotationItem(ItemContainer *container, const
|
||||
|
||||
if (value_type == Value::Type::ARRAY && !value->GetAsArray()->GetValues().empty()) {
|
||||
auto array_element_type = value->GetAsArray()->GetComponentType();
|
||||
tag_type = Value::GetArrayTypeAsChar(array_element_type);
|
||||
tag_type = static_cast<uint8_t>(Value::GetArrayTypeAsChar(array_element_type));
|
||||
} else {
|
||||
tag_type = Value::GetTypeAsChar(value_type);
|
||||
tag_type = static_cast<uint8_t>(Value::GetTypeAsChar(value_type));
|
||||
}
|
||||
|
||||
ASSERT(tag_type != '0');
|
||||
@@ -1409,8 +1409,8 @@ bool AsmEmitter::EmitFunctions(ItemContainer *items, const Program &program,
|
||||
code->SetNumVregs(func.regs_num);
|
||||
code->SetNumArgs(func.GetParamsNum());
|
||||
|
||||
size_t num_ins =
|
||||
std::count_if(func.ins.begin(), func.ins.end(), [](auto it) { return it.opcode != Opcode::INVALID; });
|
||||
size_t num_ins = static_cast<size_t>(
|
||||
std::count_if(func.ins.begin(), func.ins.end(), [](auto it) { return it.opcode != Opcode::INVALID; }));
|
||||
code->SetNumInstructions(num_ins);
|
||||
|
||||
auto *bytes = code->GetInstructions();
|
||||
@@ -1618,12 +1618,12 @@ void Function::EmitLocalVariable(panda_file::LineNumberProgramItem *program, Ite
|
||||
|
||||
size_t Function::GetLineNumber(size_t i) const
|
||||
{
|
||||
return static_cast<int32_t>(ins[i].ins_debug.line_number);
|
||||
return ins[i].ins_debug.line_number;
|
||||
}
|
||||
|
||||
size_t Function::GetColumnNumber(size_t i) const
|
||||
{
|
||||
return static_cast<int32_t>(ins[i].ins_debug.column_number);
|
||||
return ins[i].ins_debug.column_number;
|
||||
}
|
||||
|
||||
void Function::EmitNumber(panda_file::LineNumberProgramItem *program, std::vector<uint8_t> *constant_pool,
|
||||
@@ -1646,9 +1646,9 @@ void Function::EmitNumber(panda_file::LineNumberProgramItem *program, std::vecto
|
||||
void Function::EmitLineNumber(panda_file::LineNumberProgramItem *program, std::vector<uint8_t> *constant_pool,
|
||||
int32_t &prev_line_number, uint32_t &pc_inc, size_t instruction_number) const
|
||||
{
|
||||
int32_t line_inc = GetLineNumber(instruction_number) - prev_line_number;
|
||||
int32_t line_inc = static_cast<int32_t>(GetLineNumber(instruction_number)) - prev_line_number;
|
||||
if (line_inc) {
|
||||
prev_line_number = GetLineNumber(instruction_number);
|
||||
prev_line_number = static_cast<int32_t>(GetLineNumber(instruction_number));
|
||||
EmitNumber(program, constant_pool, pc_inc, line_inc);
|
||||
pc_inc = 0;
|
||||
}
|
||||
@@ -1657,7 +1657,7 @@ void Function::EmitLineNumber(panda_file::LineNumberProgramItem *program, std::v
|
||||
void Function::EmitColumnNumber(panda_file::LineNumberProgramItem *program, std::vector<uint8_t> *constant_pool,
|
||||
int32_t &prev_column_number, uint32_t &pc_inc, size_t instruction_number) const
|
||||
{
|
||||
int32_t cn = GetColumnNumber(instruction_number);
|
||||
auto cn = static_cast<int32_t>(GetColumnNumber(instruction_number));
|
||||
if (cn != prev_column_number) {
|
||||
program->EmitColumn(constant_pool, pc_inc, cn);
|
||||
pc_inc = 0;
|
||||
@@ -1677,8 +1677,8 @@ void Function::BuildLineNumberProgram(panda_file::DebugInfoItem *debug_item, con
|
||||
}
|
||||
|
||||
uint32_t pc_inc = 0;
|
||||
int32_t prev_line_number = GetLineNumber(0);
|
||||
int32_t prev_column_number = GetColumnNumber(0);
|
||||
auto prev_line_number = static_cast<int32_t>(GetLineNumber(0));
|
||||
auto prev_column_number = static_cast<int32_t>(GetColumnNumber(0));
|
||||
BytecodeInstruction bi(bytecode.data());
|
||||
debug_item->SetLineNumber(static_cast<uint32_t>(prev_line_number));
|
||||
|
||||
|
||||
@@ -354,7 +354,8 @@ void Parser::ParseResetFunctionLabelsAndParams()
|
||||
for (const auto &v : t.second) {
|
||||
if (!curr_func_->ins.empty() && curr_func_->ins.size() >= v.first &&
|
||||
!curr_func_->ins[v.first - 1].regs.empty()) {
|
||||
curr_func_->ins[v.first - 1].regs[v.second] += curr_func_->value_of_first_param + 1;
|
||||
curr_func_->ins[v.first - 1].regs[v.second] +=
|
||||
static_cast<uint16_t>(curr_func_->value_of_first_param + 1);
|
||||
size_t max_reg_number = (1 << curr_func_->ins[v.first - 1].MaxRegEncodingWidth());
|
||||
if (curr_func_->ins[v.first - 1].regs[v.second] >= max_reg_number) {
|
||||
const auto &debug = curr_func_->ins[v.first - 1].ins_debug;
|
||||
@@ -393,7 +394,7 @@ void Parser::ParseResetFunctionTable()
|
||||
|
||||
bool is_initobj = insn_it->opcode == Opcode::INITOBJ || insn_it->opcode == Opcode::INITOBJ_SHORT ||
|
||||
insn_it->opcode == Opcode::INITOBJ_RANGE;
|
||||
auto diff = is_initobj ? 0 : 1;
|
||||
size_t diff = is_initobj ? 0 : 1;
|
||||
if (insn_it->OperandListLength() - diff < program_.function_table.at(insn_it->ids[0]).GetParamsNum()) {
|
||||
auto insn_idx = std::distance(k.second.ins.begin(), insn_it);
|
||||
const auto &debug = curr_func_->ins[insn_idx].ins_debug;
|
||||
@@ -924,16 +925,16 @@ bool Parser::ParseOperandVreg()
|
||||
|
||||
if (p[0] == 'v') {
|
||||
p.remove_prefix(1);
|
||||
int64_t number = ToNumber(p);
|
||||
int64_t number = static_cast<int64_t>(ToNumber(p));
|
||||
|
||||
if (number > *(context_.max_value_of_reg)) {
|
||||
*(context_.max_value_of_reg) = number;
|
||||
}
|
||||
|
||||
curr_ins_->regs.push_back(number);
|
||||
curr_ins_->regs.push_back(static_cast<uint16_t>(number));
|
||||
} else if (p[0] == 'a') {
|
||||
p.remove_prefix(1);
|
||||
curr_ins_->regs.push_back(ToNumber(p));
|
||||
curr_ins_->regs.push_back(static_cast<uint16_t>(ToNumber(p)));
|
||||
context_.function_arguments_list->emplace_back(context_.ins_number, curr_ins_->regs.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,9 +104,9 @@ private:
|
||||
int8_t shift = 0, int token_shift = 0, const std::string &add_mess = "") const
|
||||
{
|
||||
return Error(mess, line_stric_, err, add_mess,
|
||||
context_.tokens[context_.number + token_shift - 1].bound_left + shift,
|
||||
context_.tokens[context_.number + token_shift - 1].bound_right,
|
||||
context_.tokens[context_.number + token_shift - 1].whole_line);
|
||||
context_.tokens[static_cast<int>(context_.number) + token_shift - 1].bound_left + shift,
|
||||
context_.tokens[static_cast<int>(context_.number) + token_shift - 1].bound_right,
|
||||
context_.tokens[static_cast<int>(context_.number) + token_shift - 1].whole_line);
|
||||
}
|
||||
|
||||
inline void GetWarning(const std::string &mess = "", Error::ErrorType err = Error::ErrorType::ERR_NONE,
|
||||
|
||||
+9
-7
@@ -345,13 +345,15 @@ void Lexer::LexPreprocess()
|
||||
|
||||
// Searching for comment marker located outside of the string literals.
|
||||
inside_str_lit = curr_line_->buffer.size() > 0 && curr_line_->buffer[0] == '\"';
|
||||
cmt_pos = -1;
|
||||
while ((cmt_pos = curr_line_->buffer.find_first_of("\"#", cmt_pos + 1)) != std::string::npos) {
|
||||
if (cmt_pos != 0 && curr_line_->buffer[cmt_pos - 1] != '\\' && curr_line_->buffer[cmt_pos] == '\"') {
|
||||
inside_str_lit = !inside_str_lit;
|
||||
} else if (curr_line_->buffer[cmt_pos] == PARSE_COMMENT_MARKER && !inside_str_lit) {
|
||||
break;
|
||||
}
|
||||
cmt_pos = curr_line_->buffer.find_first_of("\"#", 0);
|
||||
if (cmt_pos != std::string::npos) {
|
||||
do {
|
||||
if (cmt_pos != 0 && curr_line_->buffer[cmt_pos - 1] != '\\' && curr_line_->buffer[cmt_pos] == '\"') {
|
||||
inside_str_lit = !inside_str_lit;
|
||||
} else if (curr_line_->buffer[cmt_pos] == PARSE_COMMENT_MARKER && !inside_str_lit) {
|
||||
break;
|
||||
}
|
||||
} while ((cmt_pos = curr_line_->buffer.find_first_of("\"#", cmt_pos + 1)) != std::string::npos);
|
||||
}
|
||||
|
||||
if (cmt_pos != std::string::npos) {
|
||||
|
||||
@@ -196,7 +196,7 @@ inline size_t ToNumber(std::string_view p)
|
||||
|
||||
for (char i : p) {
|
||||
if (isdigit(i) != 0) {
|
||||
sum = sum * DEC_BASE + (i - '0');
|
||||
sum = sum * DEC_BASE + static_cast<size_t>(i - '0');
|
||||
} else {
|
||||
return MAX_DWORD;
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ public:
|
||||
size_ = other.size_;
|
||||
deleter_ = other.deleter_;
|
||||
other.ptr_ = nullptr;
|
||||
other.deleter_ = nullptr;
|
||||
}
|
||||
|
||||
MapPtr &operator=(MapPtr &&other) noexcept
|
||||
@@ -176,6 +177,7 @@ public:
|
||||
size_ = other.size_;
|
||||
deleter_ = other.deleter_;
|
||||
other.ptr_ = nullptr;
|
||||
other.deleter_ = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -229,6 +231,9 @@ public:
|
||||
*/
|
||||
~MapPtr()
|
||||
{
|
||||
if (ptr_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
uintptr_t addr = reinterpret_cast<uintptr_t>(ptr_) - page_offset_;
|
||||
// LINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
size_t size = size_ + page_offset_;
|
||||
|
||||
@@ -99,7 +99,7 @@ std::optional<Error> MakeMemReadOnly(void *mem, size_t size)
|
||||
|
||||
uintptr_t AlignDownToPageSize(uintptr_t addr)
|
||||
{
|
||||
const size_t SYS_PAGE_SIZE = sysconf(_SC_PAGESIZE);
|
||||
const auto SYS_PAGE_SIZE = static_cast<size_t>(sysconf(_SC_PAGESIZE));
|
||||
addr &= ~(SYS_PAGE_SIZE - 1);
|
||||
return addr;
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@ struct timespec ConvertTime(uint64_t ms, uint64_t ns, bool is_absolute)
|
||||
if (!is_absolute) {
|
||||
clock_gettime(CLOCK_REALTIME, &abs_time);
|
||||
}
|
||||
time_t seconds = ms / MILLISECONDS_PER_SEC;
|
||||
time_t nanoseconds = (ms % MILLISECONDS_PER_SEC) * NANOSECONDS_PER_MILLISEC + ns;
|
||||
auto seconds = static_cast<time_t>(ms / MILLISECONDS_PER_SEC);
|
||||
auto nanoseconds = static_cast<time_t>((ms % MILLISECONDS_PER_SEC) * NANOSECONDS_PER_MILLISEC + ns);
|
||||
abs_time.tv_sec += seconds;
|
||||
abs_time.tv_nsec += nanoseconds;
|
||||
if (abs_time.tv_nsec >= NANOSECONDS_PER_SEC) {
|
||||
|
||||
@@ -47,7 +47,7 @@ int SetFdNonblocking(const UniqueFd &fd)
|
||||
if (res < 0) {
|
||||
flags = 0;
|
||||
} else {
|
||||
flags = res;
|
||||
flags = static_cast<size_t>(res);
|
||||
}
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-signed-bitwise)
|
||||
return fcntl(fd.Get(), F_SETFL, flags | O_NONBLOCK);
|
||||
@@ -91,7 +91,7 @@ Expected<size_t, Error> WaitForEvent(const UniqueFd *handles, size_t size, Event
|
||||
std::vector<pollfd> pollfds(size);
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
pollfds[i].fd = handles[i].Get(); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
pollfds[i].events = poll_events;
|
||||
pollfds[i].events = static_cast<int16_t>(poll_events);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
|
||||
@@ -207,7 +207,7 @@ static std::array<SignalHook, _NSIG + 1> signal_hooks;
|
||||
|
||||
void SignalHook::CallOldAction(int signo, siginfo_t *siginfo, void *ucontext_raw)
|
||||
{
|
||||
size_t handler_flags = signal_hooks[signo].old_action_.sa_flags;
|
||||
auto handler_flags = static_cast<size_t>(signal_hooks[signo].old_action_.sa_flags);
|
||||
sigset_t mask = signal_hooks[signo].old_action_.sa_mask;
|
||||
real_sigprocmask(SIG_SETMASK, &mask, nullptr);
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void DfxController::ResetOptionValueFromString(const std::string &s)
|
||||
last_pos = s.find_first_not_of(';', pos);
|
||||
pos = s.find(';', last_pos);
|
||||
std::string option_str = arg.substr(0, arg.find(':'));
|
||||
uint8_t value = std::stoi(arg.substr(arg.find(':') + 1));
|
||||
uint8_t value = static_cast<uint8_t>(std::stoi(arg.substr(arg.find(':') + 1)));
|
||||
auto dfx_option = DfxOptionHandler::DfxOptionFromString(option_str);
|
||||
if (dfx_option != DfxOptionHandler::END_FLAG) {
|
||||
DfxController::SetOptionValue(dfx_option, value);
|
||||
|
||||
@@ -211,7 +211,7 @@ bool JsonObject::Parser::GetValue()
|
||||
|
||||
// Save source string of parsed value:
|
||||
auto pos_end = istream_.tellg();
|
||||
size_t size = pos_end - pos_start;
|
||||
auto size = static_cast<size_t>(pos_end - pos_start);
|
||||
string_temp_.resize(size, '\0');
|
||||
istream_.seekg(pos_start);
|
||||
istream_.read(&string_temp_[0], size);
|
||||
|
||||
@@ -121,8 +121,7 @@ inline size_t EncodeSigned(T data, uint8_t *out)
|
||||
bool more = true;
|
||||
|
||||
while (more) {
|
||||
// NOLINTNEXTLINE(hicpp-signed-bitwise)
|
||||
uint8_t byte = data & PAYLOAD_MASK;
|
||||
auto byte = static_cast<uint8_t>(static_cast<size_t>(data) & PAYLOAD_MASK);
|
||||
// NOLINTNEXTLINE(hicpp-signed-bitwise)
|
||||
data >>= PAYLOAD_WIDTH;
|
||||
more = !((data == 0 && (byte & SIGN_BIT) == 0) || (data == -1 && (byte & SIGN_BIT) != 0));
|
||||
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
// Get ((uint8_t*)tail)[i - 1]:
|
||||
uintptr_t block_pointer = tail + sizeof(uint8_t) * (i - 1);
|
||||
uint8_t block = *reinterpret_cast<uint8_t *>(block_pointer);
|
||||
uint32_t temp = (block << (TAIL_SHIFT * (i - 1U)));
|
||||
uint32_t temp = static_cast<uint32_t>(block << (TAIL_SHIFT * (i - 1U)));
|
||||
k1 ^= temp;
|
||||
if (i == 1) {
|
||||
k1 = Rotl(k1, TAIL_LAST_SHIFT);
|
||||
@@ -180,7 +180,7 @@ private:
|
||||
uint32_t k1 = 0;
|
||||
for (size_t i = tail_len; i > 0; i--) {
|
||||
uint8_t block = memblock[i - 1U];
|
||||
uint32_t temp = (block << (TAIL_SHIFT * (i - 1U)));
|
||||
uint32_t temp = static_cast<uint32_t>(block << (TAIL_SHIFT * (i - 1U)));
|
||||
k1 ^= temp;
|
||||
if (i == 1) {
|
||||
k1 = Rotl(k1, TAIL_LAST_SHIFT);
|
||||
|
||||
@@ -84,7 +84,7 @@ bool operator!=(const ValueUnit &lhs, const ValueUnit &rhs)
|
||||
std::ostream &operator<<(std::ostream &os, const ValueUnit &element)
|
||||
{
|
||||
if (element.GetValue().index() == 0U) {
|
||||
os << std::fixed << std::setprecision(static_cast<int>(element.GetPrecision())) << element.GetDoubleValue()
|
||||
os << std::fixed << std::setprecision(static_cast<int>(element.GetPrecision())) << element.GetDoubleValue()
|
||||
<< std::setprecision(-1);
|
||||
} else {
|
||||
os << element.GetUint64Value();
|
||||
|
||||
@@ -44,7 +44,7 @@ AnnotationDataAccessor::Tag AnnotationDataAccessor::GetTag(size_t i) const
|
||||
{
|
||||
ASSERT(i < count_);
|
||||
auto sp = elements_tags_.SubSpan(i * TYPE_TAG_SIZE);
|
||||
char item = helpers::Read<TYPE_TAG_SIZE>(&sp);
|
||||
auto item = static_cast<char>(helpers::Read<TYPE_TAG_SIZE>(&sp));
|
||||
return AnnotationDataAccessor::Tag(item);
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +245,11 @@ void BytecodeEmitter::Jcmpz(BytecodeInstruction::Opcode opcode, const Label &lab
|
||||
*/
|
||||
BytecodeEmitter::ErrorCode BytecodeEmitter::ReserveSpaceForOffsets()
|
||||
{
|
||||
int32_t bias = 0;
|
||||
uint32_t bias = 0;
|
||||
std::map<uint32_t, Label> new_branches;
|
||||
auto it = branches_.begin();
|
||||
while (it != branches_.end()) {
|
||||
uint32_t insn_pc = it->first + bias;
|
||||
auto insn_pc = static_cast<uint32_t>(it->first + bias);
|
||||
auto label = it->second;
|
||||
|
||||
auto opcode = static_cast<Opcode>(bytecode_[insn_pc]);
|
||||
@@ -375,7 +375,7 @@ BytecodeEmitter::ErrorCode BytecodeEmitter::UpdateBranches()
|
||||
return ErrorCode::SUCCESS;
|
||||
}
|
||||
|
||||
void BytecodeEmitter::UpdateLabelTargets(uint32_t pc, int32_t bias)
|
||||
void BytecodeEmitter::UpdateLabelTargets(uint32_t pc, size_t bias)
|
||||
{
|
||||
pc_list_.push_front(pc);
|
||||
Label fake(pc_list_.begin());
|
||||
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
ErrorCode DoReserveSpaceForOffset(BytecodeInstruction::Opcode opcode, uint32_t insn_pc,
|
||||
BitImmSize expected_imm_size, size_t *extra_bytes_ptr, uint32_t *target_ptr);
|
||||
ErrorCode UpdateBranches();
|
||||
void UpdateLabelTargets(uint32_t pc, int32_t bias);
|
||||
void UpdateLabelTargets(uint32_t pc, size_t bias);
|
||||
int32_t EstimateMaxDistance(uint32_t insn_pc, uint32_t target_pc, uint32_t bias) const;
|
||||
ErrorCode CheckLabels() const;
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ private:
|
||||
ASSERT(static_cast<uint8_t>(opcode) >= LineNumberProgramItem::OPCODE_BASE);
|
||||
|
||||
auto adjust_opcode = static_cast<uint8_t>(opcode) - LineNumberProgramItem::OPCODE_BASE;
|
||||
uint32_t pc_offset = adjust_opcode / LineNumberProgramItem::LINE_RANGE;
|
||||
auto pc_offset = static_cast<uint32_t>(adjust_opcode / LineNumberProgramItem::LINE_RANGE);
|
||||
int32_t line_offset = adjust_opcode % LineNumberProgramItem::LINE_RANGE + LineNumberProgramItem::LINE_BASE;
|
||||
state_.AdvancePc(pc_offset);
|
||||
state_.AdvanceLine(line_offset);
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
void AdvanceLine(int32_t v)
|
||||
{
|
||||
line_ += v;
|
||||
line_ += static_cast<size_t>(v);
|
||||
}
|
||||
|
||||
void AdvancePc(uint32_t v)
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
void SetColumn(int32_t c)
|
||||
{
|
||||
column_ = c;
|
||||
column_ = static_cast<size_t>(c);
|
||||
}
|
||||
|
||||
size_t GetColumn() const
|
||||
|
||||
Reference in New Issue
Block a user