Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimír Štill <git@vstill.eu>
  • Loading branch information
asl and vlstill committed Feb 1, 2024
1 parent 2298ff1 commit f0331d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backends/p4tools/common/core/abstract_execution_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ const IR::Expression *AbstractExecutionState::convertToComplexExpression(
IR::Vector<IR::Expression> components;
const auto *elementType = resolveType(ts->elementType);
for (size_t idx = 0; idx < ts->getSize(); idx++) {
auto ref = new IR::ArrayIndex(elementType, parent, new IR::Constant(uint64_t(idx)));
auto ref = new IR::ArrayIndex(elementType, parent,
new IR::Constant((static_cast<uint64_t>(idx))));
if (elementType->is<IR::Type_StructLike>() || elementType->to<IR::Type_Stack>()) {
components.push_back(convertToComplexExpression(ref));
} else {
Expand Down
4 changes: 2 additions & 2 deletions ir/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ class INode : public Util::IHasSourceInfo, public IHasDbPrint, public ICastable

// default checkedTo implementation for nodes: just fallback to generic ICastable method
template <typename T>
typename std::enable_if_t<!has_static_type_name_v<T>, const T *> checkedTo() const {
std::enable_if_t<!has_static_type_name_v<T>, const T *> checkedTo() const {
return ICastable::checkedTo<T>();
}

// alternative checkedTo implementation that produces slightly better error message
// due to node_type_name() / static_type_name() being available
template <typename T>
typename std::enable_if_t<has_static_type_name_v<T>, const T *> checkedTo() const {
std::enable_if_t<has_static_type_name_v<T>, const T *> checkedTo() const {
const auto *result = to<T>();
BUG_CHECK(result, "Cast failed: %1% with type %2% is not a %3%.", this, node_type_name(),
T::static_type_name());
Expand Down

0 comments on commit f0331d3

Please sign in to comment.