Use clang-format-18 for source formatting (#256)

* Updating clang-format to v18

- Updates the pre-commit-config
- Formats source files according to the utility

Signed-off-by: David Galiffi <David.Galiffi@amd.com>

* Update format source workflow

Signed-off-by: David Galiffi <David.Galiffi@amd.com>

* Update CONTRIBUTING

* Update comment in .clang-format

* Update CONTRIBUTING.md

* Update helper script

---------

Signed-off-by: David Galiffi <David.Galiffi@amd.com>

[ROCm/rocprofiler-systems commit: 1e13b590e7]
这个提交包含在:
David Galiffi
2025-06-22 08:48:08 -04:00
提交者 GitHub
父节点 6a8cef771e
当前提交 0403aaa97f
修改 76 个文件,包含 258 行新增255 行删除
@@ -293,8 +293,7 @@ main(int argc, char** argv)
{
_msg << "| " << std::setw(std::get<0>(_w) + 2) << "String";
if(_show) _msg << " | " << std::setw(std::get<1>(_w)) << "Value";
_msg << " | " << std::setw(std::get<2>(_w)) << "Encoding"
<< " |\n";
_msg << " | " << std::setw(std::get<2>(_w)) << "Encoding" << " |\n";
auto _dashes = [](int64_t _n) {
std::stringstream _dss{};
@@ -965,9 +964,9 @@ write_settings_info(std::ostream& os, const array_t<bool, N>& opts,
"C++ MEMBER ACCESSOR", "Python ACCESSOR", "DESCRIPTION", "CATEGORIES",
};
array_t<string_t, size> _keys = { "environ", "value",
"data_type", "static_accessor",
"member_accessor", "python_accessor",
"description", "categories" };
"data_type", "static_accessor",
"member_accessor", "python_accessor",
"description", "categories" };
array_t<bool, size> _center = {
false, true, true, false, false, false, false, false
};
@@ -162,8 +162,8 @@ private:
unique_set exclude_stream = {};
int_stack name_counter;
unique_set value_keys = { "name", "value", "description", "count",
"environ", "max_count", "cmdline", "data_type",
"initial", "categories" };
"environ", "max_count", "cmdline", "data_type",
"initial", "categories" };
};
//======================================================================================//
@@ -48,6 +48,6 @@ struct enumerated_list<TupT<T...>, std::index_sequence<I, Idx...>>
using Tp = tim::component::enumerator_t<I>;
static constexpr bool is_nothing = tim::concepts::is_placeholder<Tp>::value;
using type = typename enumerated_list<
std::conditional_t<is_nothing, type_list<T...>, type_list<T..., Tp>>,
std::index_sequence<Idx...>>::type;
std::conditional_t<is_nothing, type_list<T...>, type_list<T..., Tp>>,
std::index_sequence<Idx...>>::type;
};
@@ -161,7 +161,8 @@ struct setting_serialization<tsettings<Tp>, custom_setting_serializer>
} // namespace tim
template <typename... Tp>
void push(type_list<Tp...>)
void
push(type_list<Tp...>)
{
ROCPROFSYS_FOLD_EXPRESSION(
settings::push_serialize_map_callback<Tp, custom_setting_serializer>());
@@ -171,7 +172,8 @@ void push(type_list<Tp...>)
}
template <typename... Tp>
void pop(type_list<Tp...>)
void
pop(type_list<Tp...>)
{
ROCPROFSYS_FOLD_EXPRESSION(
settings::pop_serialize_map_callback<Tp, custom_setting_serializer>());
@@ -32,7 +32,8 @@
#include <string>
template <typename... Tp>
auto get_categories(type_list<Tp...>)
auto
get_categories(type_list<Tp...>)
{
auto _cleanup = [](std::string _type, const std::string& _pattern) {
auto _pos = std::string::npos;
@@ -122,7 +122,7 @@ int
get_verbose()
{
verbose = get_env("ROCPROFSYS_CAUSAL_VERBOSE",
get_env<int>("ROCPROFSYS_VERBOSE", verbose, false));
get_env<int>("ROCPROFSYS_VERBOSE", verbose, false));
auto _debug = get_env("ROCPROFSYS_CAUSAL_DEBUG",
get_env<bool>("ROCPROFSYS_DEBUG", false, false));
if(_debug) verbose += 8;
@@ -146,16 +146,12 @@ module_function::write_header(std::ostream& os)
auto w2 = std::min<size_t>(get_width()[2], absolute_max_width);
std::stringstream ss;
ss << std::setw(14) << "StartAddress"
<< " " << std::setw(14) << "AddressRange"
<< " " << std::setw(14) << "#Instructions"
<< " " << std::setw(6) << "Ratio"
<< " " << std::setw(7) << "Linkage"
<< " " << std::setw(10) << "Visibility"
<< " " << std::setw(w0 + 8) << std::left << "Module"
<< " " << std::setw(w1 + 8) << std::left << "Function"
<< " " << std::setw(w2 + 8) << std::left << "FunctionSignature"
<< "\n";
ss << std::setw(14) << "StartAddress" << " " << std::setw(14) << "AddressRange" << " "
<< std::setw(14) << "#Instructions" << " " << std::setw(6) << "Ratio" << " "
<< std::setw(7) << "Linkage" << " " << std::setw(10) << "Visibility" << " "
<< std::setw(w0 + 8) << std::left << "Module" << " " << std::setw(w1 + 8)
<< std::left << "Function" << " " << std::setw(w2 + 8) << std::left
<< "FunctionSignature" << "\n";
os << ss.str();
}
@@ -1015,7 +1011,7 @@ module_function::register_coverage(address_space_t* _addr_space,
auto _start_addr = itr.second.start_address;
auto& _signature = itr.second.signature;
auto _trace_entr = rocprofsys_call_expr(_signature.m_file,
_signature.m_name, _start_addr);
_signature.m_name, _start_addr);
auto _entr = _trace_entr.get(_entr_trace);
if(insert_instr(_addr_space, _entr, BPatch_entry, itr.first))
@@ -147,7 +147,7 @@ symtab_data_s symtab_data = {};
std::set<symbol_linkage_t> enabled_linkage = {};
std::set<symbol_visibility_t> enabled_visibility = {};
const std::set<symbol_linkage_t> default_enabled_linkage = { SL_GLOBAL, SL_LOCAL,
SL_UNIQUE };
SL_UNIQUE };
const std::set<symbol_visibility_t> default_enabled_visibility = { SV_DEFAULT, SV_HIDDEN,
SV_INTERNAL,
SV_PROTECTED };
@@ -272,8 +272,8 @@ activate_signal_handlers(const std::vector<sys_signal>& _signals)
TIMEMORY_PRINTF_FATAL(
stderr,
"These were the last %i log entries from rocprof-sys. You can control the "
"number of log entries via the '--log <N>' option or ROCPROFSYS_LOG_COUNT "
"env variable.\n",
"number of log entries via the '--log <N>' option or ROCPROFSYS_LOG_COUNT "
"env variable.\n",
num_log_entries);
if(log_ofs) log_ofs->close();
@@ -1207,8 +1207,7 @@ main(int argc, char** argv)
std::min<size_t>(std::get<0>(tim::utility::console::get_columns()) - 20,
strlen(_cmdv[0]) + 32);
_separator.fill('=');
_separator << "#" << std::setw(_width - 2) << ""
<< "#";
_separator << "#" << std::setw(_width - 2) << "" << "#";
verbprintf(0, "%s\n", _separator.str().c_str());
verbprintf(0, "\n");
verbprintf(0, "Warning! '%s' is not executable!\n", _cmdv[0]);
@@ -1708,7 +1707,7 @@ main(int argc, char** argv)
auto* user_start_func = find_function(app_image, "rocprofsys_user_start_trace",
{ "rocprofsys_user_start_thread_trace" });
auto* user_stop_func = find_function(app_image, "rocprofsys_user_stop_trace",
{ "rocprofsys_user_stop_thread_trace" });
{ "rocprofsys_user_stop_thread_trace" });
#if ROCPROFSYS_USE_MPI > 0 || ROCPROFSYS_USE_MPI_HEADERS > 0
// if any of the below MPI functions are found, enable MPI support
for(const auto* itr :
@@ -114,9 +114,9 @@ get_verbose(parser_data_t& _data)
{
auto& verbose = _data.verbose;
verbose = get_env("ROCPROFSYS_CAUSAL_VERBOSE",
get_env<int>("ROCPROFSYS_VERBOSE", verbose, false));
get_env<int>("ROCPROFSYS_VERBOSE", verbose, false));
auto _debug = get_env("ROCPROFSYS_CAUSAL_DEBUG",
get_env<bool>("ROCPROFSYS_DEBUG", false, false));
get_env<bool>("ROCPROFSYS_DEBUG", false, false));
if(_debug) verbose += 8;
return verbose;
}