Skip to content

Update clang-format version to 18 #2945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ sudo apt install -y \
clang-16 \
clang-17 \
clang-18 \
clang-format-14 \
clang-format-18 \
libtbb-dev

pip install -r requirements.txt
Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/AutoClangFormat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ add_custom_target(format-cpp-files
COMMAND find ${DIRS_TO_FORMAT_CPP} ${FIND_TO_FORMAT_CPP})

#
# Use clang-format-14 for code format
# Use clang-format for code format
#
add_custom_target(format-cpp
COMMAND find ${DIRS_TO_FORMAT_CPP} ${FIND_TO_FORMAT_CPP} |
xargs -P ${CPU_COUNT} clang-format-14 -style=file -i)
xargs -P ${CPU_COUNT} clang-format-18 -style=file -i)

#
# Use simple python script for fixing C like boxed comments
Expand Down
6 changes: 3 additions & 3 deletions libs/libvtrutil/src/tl_optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ struct optional_copy_assign_base<T, false> : optional_move_base<T> {
// to make do with a non-trivial move assignment operator even if T is trivially
// move assignable
#ifndef TL_OPTIONAL_GCC49
template<class T, bool = std::is_trivially_destructible<T>::value&& std::is_trivially_move_constructible<T>::value&& std::is_trivially_move_assignable<T>::value>
template<class T, bool = std::is_trivially_destructible<T>::value && std::is_trivially_move_constructible<T>::value && std::is_trivially_move_assignable<T>::value>
struct optional_move_assign_base : optional_copy_assign_base<T> {
using optional_copy_assign_base<T>::optional_copy_assign_base;
};
Expand All @@ -539,7 +539,7 @@ struct optional_move_assign_base<T, false> : optional_copy_assign_base<T> {

optional_move_assign_base&
operator=(optional_move_assign_base&& rhs) noexcept(
std::is_nothrow_move_constructible<T>::value&& std::is_nothrow_move_assignable<T>::value) {
std::is_nothrow_move_constructible<T>::value && std::is_nothrow_move_assignable<T>::value) {
this->assign(std::move(rhs));
return *this;
}
Expand Down Expand Up @@ -1243,7 +1243,7 @@ class optional : private detail::optional_move_assign_base<T>,
/// If one has a value, it is moved to the other and the movee is left
/// valueless.
void
swap(optional& rhs) noexcept(std::is_nothrow_move_constructible<T>::value&& detail::is_nothrow_swappable<T>::value) {
swap(optional& rhs) noexcept(std::is_nothrow_move_constructible<T>::value && detail::is_nothrow_swappable<T>::value) {
using std::swap;
if (has_value()) {
if (rhs.has_value()) {
Expand Down
2 changes: 1 addition & 1 deletion libs/libvtrutil/src/vtr_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void free_chunk_memory(t_chunk* chunk_info) {
while (curr_ptr != nullptr) {
/* Must cast pointers to type char*, since the're of type void*, which delete can't
* be called on.*/
delete[]((char*)curr_ptr->data_vptr); /* Free memory "chunk". */
delete[] ((char*)curr_ptr->data_vptr); /* Free memory "chunk". */
prev_ptr = curr_ptr;
curr_ptr = curr_ptr->next;
delete (t_linked_vptr*)prev_ptr; /* Free memory used to track "chunk". */
Expand Down
22 changes: 11 additions & 11 deletions libs/libvtrutil/src/vtr_prefix_sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ class PrefixSum1D {
*/
PrefixSum1D(std::vector<T> vals, T zero = T())
: PrefixSum1D(
vals.size(),
[&](size_t x) noexcept {
return vals[x];
},
zero) {}
vals.size(),
[&](size_t x) noexcept {
return vals[x];
},
zero) {}

/**
* @brief Get the sum of all values in the original array of values between
Expand Down Expand Up @@ -227,12 +227,12 @@ class PrefixSum2D {
*/
PrefixSum2D(const vtr::NdMatrix<T, 2>& vals, T zero = T())
: PrefixSum2D(
vals.dim_size(0),
vals.dim_size(1),
[&](size_t x, size_t y) {
return vals[x][y];
},
zero) {}
vals.dim_size(0),
vals.dim_size(1),
[&](size_t x, size_t y) {
return vals[x][y];
},
zero) {}

/**
* @brief Get the sum of all values in the original grid of values between
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/draw/draw_rr_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void draw_chanx_to_chanx_edge(RRNodeId from_node, RRNodeId to_node, short switch
+ draw_coords->get_tile_width();
x2 = to_chan.left();

} /* The following then is executed when from_xlow == to_xlow */
} /* The following then is executed when from_xlow == to_xlow */
else if (to_xhigh > from_xhigh) { /* Draw from right edge of one to other */
x1 = from_chan.right();
x2 = draw_coords->tile_x[from_xhigh + 1];
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/pack/pb_type_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ static bool realloc_and_load_pb_graph_pin_ptrs_at_var(const int line_num,

if (prev_num_pins > 0) {
std::vector<t_pb_graph_pin*> temp(*pb_graph_pins, *pb_graph_pins + prev_num_pins);
delete[] * pb_graph_pins;
delete[] *pb_graph_pins;
*pb_graph_pins = new t_pb_graph_pin*[*num_pins];
for (i = 0; i < prev_num_pins; i++)
(*pb_graph_pins)[i] = temp[i];
Expand Down
16 changes: 8 additions & 8 deletions vpr/src/place/place_macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ int PlaceMacros::find_all_the_macro_(const ClusteredNetlist& clb_nlist,
num_macro++;

} // Do nothing if the from_pins does not have same possible direct connection.
} // Finish going through all the pins for from_pins.
} // Do nothing if the to_pins does not have same possible direct connection.
} // Finish going through all the pins for to_pins.
} // Finish going through all blocks.
} // Finish going through all the pins for from_pins.
} // Do nothing if the to_pins does not have same possible direct connection.
} // Finish going through all the pins for to_pins.
} // Finish going through all blocks.

// Now, all the data is readily stored in the temporary data structures.
return num_macro;
Expand Down Expand Up @@ -523,10 +523,10 @@ static void mark_direct_of_ports(int idirect,
port_pin_to_block_pin);
}
} // Do nothing if port_name does not match
} // Finish going through all the ports
} // Finish going through all the subtiles
} // Do nothing if pb_type_name does not match
} // Finish going through all the blocks
} // Finish going through all the ports
} // Finish going through all the subtiles
} // Do nothing if pb_type_name does not match
} // Finish going through all the blocks
}

static void mark_direct_of_pins(int start_pin_index,
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/place/verify_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static unsigned check_macro_placement_consistency(const BlkLocRegistry& blk_loc_
num_errors++;
}
} // Finish going through all the members
} // Finish going through all the macros
} // Finish going through all the macros

return num_errors;
}
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/route/rr_graph_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void count_bidir_routing_transistors(int num_switch, int wire_to_ipin_switch, fl
break;

} /* End switch on from_rr_type */
} /* End for all nodes */
} /* End for all nodes */

delete[] cblock_counted;
delete[] shared_buffer_trans;
Expand Down Expand Up @@ -478,7 +478,7 @@ void count_unidir_routing_transistors(std::vector<t_segment_inf>& /*segment_inf*
break;

} /* End switch on from_rr_type */
} /* End for all nodes */
} /* End for all nodes */

/* Now add in the input connection block transistors. */

Expand Down