Skip to content

Commit 7fe82c0

Browse files
Migration to clang-format-15 (openvinotoolkit#24226)
### Details: - Migration to clang-format-15 which is available in Ubuntu 22.04
1 parent df9b99d commit 7fe82c0

File tree

18 files changed

+63
-80
lines changed

18 files changed

+63
-80
lines changed

.github/workflows/code_style.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ concurrency:
77

88
jobs:
99
clang-format:
10-
runs-on: ubuntu-20.04
10+
runs-on: ubuntu-22.04
1111
permissions:
1212
pull-requests: write
1313
steps:
1414
- uses: actions/checkout@v4
1515
with:
1616
submodules: 'true'
1717

18-
- name: Install clang-format-9
18+
- name: Install clang-format-15
1919
run: |
2020
sudo apt update
21-
sudo apt --assume-yes install clang-format-9
21+
sudo apt --assume-yes install clang-format-15
2222
2323
# Run cmake with -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT in order to enable codestyle check for ITT collector
2424
- name: CMake configure

cmake/developer_package/clang_format/clang_format.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
if(ENABLE_CLANG_FORMAT)
6-
set(CLANG_FORMAT_REQUIRED_VERSION 9 CACHE STRING "Clang-format version to use")
6+
set(CLANG_FORMAT_REQUIRED_VERSION 15 CACHE STRING "Clang-format version to use")
77
set(CLANG_FORMAT_FILENAME clang-format-${CLANG_FORMAT_REQUIRED_VERSION} clang-format)
88
find_host_program(CLANG_FORMAT NAMES ${CLANG_FORMAT_FILENAME} PATHS ENV PATH)
99
if(CLANG_FORMAT)

src/bindings/c/include/openvino/c/deprecated.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
// Suppress warning "-Wdeprecated-declarations" / C4996
6464
#if defined(__GNUC__)
65-
# define OPENVINO_DO_PRAGMA(x) _Pragma(# x)
65+
# define OPENVINO_DO_PRAGMA(x) _Pragma(#x)
6666
#elif defined(_MSC_VER)
6767
# define OPENVINO_DO_PRAGMA(x) __pragma(x)
6868
#else

src/bindings/js/node/src/compiled_model.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Napi::Value CompiledModelWrap::get_output(const Napi::CallbackInfo& info) {
4949
return get_node(
5050
info,
5151
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)() const>(&ov::CompiledModel::output),
52-
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&)const>(
52+
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&) const>(
5353
&ov::CompiledModel::output),
5454
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)(size_t) const>(
5555
&ov::CompiledModel::output));
@@ -75,7 +75,7 @@ Napi::Value CompiledModelWrap::get_input(const Napi::CallbackInfo& info) {
7575
return get_node(
7676
info,
7777
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)() const>(&ov::CompiledModel::input),
78-
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&)const>(
78+
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&) const>(
7979
&ov::CompiledModel::input),
8080
static_cast<const ov::Output<const ov::Node>& (ov::CompiledModel::*)(size_t) const>(
8181
&ov::CompiledModel::input));
@@ -99,7 +99,7 @@ Napi::Value CompiledModelWrap::get_inputs(const Napi::CallbackInfo& info) {
9999
Napi::Value CompiledModelWrap::get_node(
100100
const Napi::CallbackInfo& info,
101101
const ov::Output<const ov::Node>& (ov::CompiledModel::*func)() const,
102-
const ov::Output<const ov::Node>& (ov::CompiledModel::*func_tname)(const std::string&)const,
102+
const ov::Output<const ov::Node>& (ov::CompiledModel::*func_tname)(const std::string&) const,
103103
const ov::Output<const ov::Node>& (ov::CompiledModel::*func_idx)(size_t) const) {
104104
if (info.Length() == 0) {
105105
return Output<const ov::Node>::wrap(info.Env(), (_compiled_model.*func)());

src/bindings/python/src/pyopenvino/core/compiled_model.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void regclass_CompiledModel(py::module m) {
209209

210210
cls.def(
211211
"input",
212-
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&)const) & ov::CompiledModel::input,
212+
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&) const) & ov::CompiledModel::input,
213213
py::arg("tensor_name"),
214214
R"(
215215
Gets input of a compiled model identified by a tensor_name.
@@ -253,11 +253,11 @@ void regclass_CompiledModel(py::module m) {
253253
:rtype: openvino.runtime.ConstOutput
254254
)");
255255

256-
cls.def(
257-
"output",
258-
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&)const) & ov::CompiledModel::output,
259-
py::arg("tensor_name"),
260-
R"(
256+
cls.def("output",
257+
(const ov::Output<const ov::Node>& (ov::CompiledModel::*)(const std::string&) const) &
258+
ov::CompiledModel::output,
259+
py::arg("tensor_name"),
260+
R"(
261261
Gets output of a compiled model identified by a tensor_name.
262262
If the output with given tensor name is not found, this method throws an exception.
263263

src/common/itt/include/openvino/itt.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ namespace itt {
2727
* @brief A domain type which enables tagging trace data for different modules or libraries in a program.
2828
*/
2929
typedef struct domain_ {
30-
} * domain_t;
30+
}* domain_t;
3131

3232
/**
3333
* @typedef handle_t
3434
* @ingroup ov_dev_profiling
3535
* @brief Annotation handle for section of code which would be named at runtime.
3636
*/
3737
typedef struct handle_ {
38-
} * handle_t;
38+
}* handle_t;
3939

4040
/**
4141
* @cond

src/core/include/openvino/core/deprecated.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
// Suppress warning "-Wdeprecated-declarations" / C4996
4040
#if defined(__GNUC__)
41-
# define OPENVINO_DO_PRAGMA(x) _Pragma(# x)
41+
# define OPENVINO_DO_PRAGMA(x) _Pragma(#x)
4242
#elif defined(_MSC_VER)
4343
# define OPENVINO_DO_PRAGMA(x) __pragma(x)
4444
#else

src/core/include/openvino/core/extension.hpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ void OV_CREATE_EXTENSION(std::vector<ov::Extension::Ptr>&);
4747
*
4848
* @param vector of extensions
4949
*/
50-
#define OPENVINO_CREATE_EXTENSIONS(extensions) \
51-
OPENVINO_EXTENSION_C_API void OV_CREATE_EXTENSION(std::vector<ov::Extension::Ptr>& ext); \
52-
OPENVINO_EXTENSION_C_API void OV_CREATE_EXTENSION(std::vector<ov::Extension::Ptr>& ext) { \
53-
ext = extensions; \
54-
}
50+
#define OPENVINO_CREATE_EXTENSIONS(extensions) \
51+
OPENVINO_EXTENSION_C_API void OV_CREATE_EXTENSION(std::vector<ov::Extension::Ptr>& ext); \
52+
OPENVINO_EXTENSION_C_API void OV_CREATE_EXTENSION(std::vector<ov::Extension::Ptr>& ext) { ext = extensions; }

src/core/include/openvino/core/rtti.hpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
type_info_static.hash(); \
1919
return type_info_static; \
2020
} \
21-
const ::ov::DiscreteTypeInfo& get_type_info() const override { \
22-
return get_type_info_static(); \
23-
}
21+
const ::ov::DiscreteTypeInfo& get_type_info() const override { return get_type_info_static(); }
2422

2523
#define _OPENVINO_RTTI_WITH_TYPE_VERSION_PARENT(TYPE_NAME, VERSION_NAME, PARENT_CLASS) \
2624
_OPENVINO_RTTI_WITH_TYPE_VERSIONS_PARENT(TYPE_NAME, VERSION_NAME, PARENT_CLASS)
@@ -33,9 +31,7 @@
3331
type_info_static.hash(); \
3432
return type_info_static; \
3533
} \
36-
const ::ov::DiscreteTypeInfo& get_type_info() const override { \
37-
return get_type_info_static(); \
38-
}
34+
const ::ov::DiscreteTypeInfo& get_type_info() const override { return get_type_info_static(); }
3935

4036
/// Helper macro that puts necessary declarations of RTTI block inside a class definition.
4137
/// Should be used in the scope of class that requires type identification besides one provided by

src/core/src/itt.hpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ OV_CC_DOMAINS(ov_opset);
5050
# define INSERT_OP(opset_name, op_name, op_namespace) opset.insert<op_namespace::op_name>()
5151
#endif
5252

53-
#define OPENVINO_TYPE_CASE(region, a, ...) \
54-
case ov::element::Type_t::a: { \
55-
OV_SCOPE(ov_op, OV_PP_CAT3(region, _, a)) { \
56-
rc = evaluate<ov::element::Type_t::a>(__VA_ARGS__); \
57-
} \
53+
#define OPENVINO_TYPE_CASE(region, a, ...) \
54+
case ov::element::Type_t::a: { \
55+
OV_SCOPE(ov_op, OV_PP_CAT3(region, _, a)) { rc = evaluate<ov::element::Type_t::a>(__VA_ARGS__); } \
5856
} break
5957

6058
#define OPENVINO_2_TYPES_CASE(region, a, b, ...) \
@@ -64,9 +62,7 @@ OV_CC_DOMAINS(ov_opset);
6462
} \
6563
} break
6664

67-
#define OPENVINO_COPY_TENSOR(region, a, ...) \
68-
case ov::element::Type_t::a: { \
69-
OV_SCOPE(ov_op, OV_PP_CAT3(region, _, a)) { \
70-
rc = copy_tensor<ov::element::Type_t::a>(__VA_ARGS__); \
71-
} \
65+
#define OPENVINO_COPY_TENSOR(region, a, ...) \
66+
case ov::element::Type_t::a: { \
67+
OV_SCOPE(ov_op, OV_PP_CAT3(region, _, a)) { rc = copy_tensor<ov::element::Type_t::a>(__VA_ARGS__); } \
7268
} break

src/core/src/opsets/opset.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ std::string ov::OpSet::to_upper_name(const std::string& name) {
9696

9797
const std::map<std::string, std::function<const ov::OpSet&()>>& ov::get_available_opsets() {
9898
#define _OPENVINO_REG_OPSET(OPSET) \
99-
{ #OPSET, ov::get_##OPSET }
99+
{ \
100+
# OPSET, ov::get_##OPSET \
101+
}
100102
const static std::map<std::string, std::function<const ov::OpSet&()>> opset_map = {_OPENVINO_REG_OPSET(opset1),
101103
_OPENVINO_REG_OPSET(opset2),
102104
_OPENVINO_REG_OPSET(opset3),

src/core/tests/type_prop/generate_proposals.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,10 @@ TEST(type_prop, generate_proposals_dynamic) {
282282
if (s.scores_shape.rank().is_static())
283283
set_shape_symbols(s.scores_shape);
284284

285-
auto expected_batch_label =
286-
s.scores_shape.rank().is_static()
287-
? s.scores_shape[0].get_symbol()
288-
: s.deltas_shape.rank().is_static()
289-
? s.deltas_shape[0].get_symbol()
290-
: s.im_info_shape.rank().is_static() ? s.im_info_shape[0].get_symbol() : nullptr;
285+
auto expected_batch_label = s.scores_shape.rank().is_static() ? s.scores_shape[0].get_symbol()
286+
: s.deltas_shape.rank().is_static() ? s.deltas_shape[0].get_symbol()
287+
: s.im_info_shape.rank().is_static() ? s.im_info_shape[0].get_symbol()
288+
: nullptr;
291289

292290
auto im_info = std::make_shared<ov::op::v0::Parameter>(element::f32, s.im_info_shape);
293291
auto anchors = std::make_shared<ov::op::v0::Parameter>(element::f32, s.anchors_shape);

src/frontends/ir/src/ir_deserializer.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,15 @@ ov::GenericLayerParams ov::XmlDeserializer::parse_generic_params(const pugi::xml
757757

758758
auto outNode = node.child("output");
759759
if (!outNode.empty()) {
760-
FOREACH_CHILD (_cn, outNode, "port") { params.outputPorts.emplace_back(parsePort(_cn, params, false)); }
760+
FOREACH_CHILD (_cn, outNode, "port") {
761+
params.outputPorts.emplace_back(parsePort(_cn, params, false));
762+
}
761763
}
762764
auto inpNode = node.child("input");
763765
if (!inpNode.empty()) {
764-
FOREACH_CHILD (_cn, inpNode, "port") { params.inputPorts.emplace_back(parsePort(_cn, params, true)); }
766+
FOREACH_CHILD (_cn, inpNode, "port") {
767+
params.inputPorts.emplace_back(parsePort(_cn, params, true));
768+
}
765769
}
766770
return params;
767771
}

src/inference/src/cpp/core.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ Core::Core(const std::string& xml_config_file) {
7878
}
7979

8080
std::map<std::string, Version> Core::get_versions(const std::string& device_name) const {
81-
OV_CORE_CALL_STATEMENT({ return _impl->get_versions(device_name); })
82-
}
83-
81+
OV_CORE_CALL_STATEMENT({ return _impl->get_versions(device_name); })}
8482
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
8583
std::shared_ptr<ov::Model> Core::read_model(const std::wstring& model_path, const std::wstring& bin_path) const {
8684
OV_CORE_CALL_STATEMENT(

src/inference/src/dev/threading/parallel_custom_arena.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,17 @@ task_arena::task_arena(int max_concurrency_, unsigned reserved_for_masters)
246246

247247
task_arena::task_arena(const constraints& constraints_, unsigned reserved_for_masters)
248248
# if USE_TBBBIND_2_5
249-
: my_task_arena {
250-
info::default_concurrency(constraints_), reserved_for_masters
251-
}
249+
: my_task_arena{info::default_concurrency(constraints_), reserved_for_masters}
252250
# elif TBB_NUMA_SUPPORT_PRESENT || TBB_HYBRID_CPUS_SUPPORT_PRESENT
253-
: my_task_arena {
254-
convert_constraints(constraints_), reserved_for_masters
255-
}
251+
: my_task_arena{convert_constraints(constraints_), reserved_for_masters}
256252
# else
257-
: my_task_arena {
258-
constraints_.max_concurrency, reserved_for_masters
259-
}
253+
: my_task_arena{constraints_.max_concurrency, reserved_for_masters}
260254
# endif
261-
, my_initialization_state{}, my_constraints{constraints_}, my_binding_observer{} {}
255+
,
256+
my_initialization_state{},
257+
my_constraints{constraints_},
258+
my_binding_observer{} {
259+
}
262260

263261
task_arena::task_arena(const task_arena& s)
264262
: my_task_arena{s.my_task_arena},

src/inference/tests/unit/cpu_map_parser/parser_windows.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ namespace {
1616
#if defined(_WIN32)
1717

1818
int Hex2Int(char c) {
19-
return (c >= '0' && c <= '9')
20-
? (c) - '0'
21-
: (c >= 'A' && c <= 'F') ? (c) - 'A' + 10 : (c >= 'a' && c <= 'f') ? (c) - 'a' + 10 : 0;
19+
return (c >= '0' && c <= '9') ? (c) - '0'
20+
: (c >= 'A' && c <= 'F') ? (c) - 'A' + 10
21+
: (c >= 'a' && c <= 'f') ? (c) - 'a' + 10
22+
: 0;
2223
}
2324

2425
void Hex2Bin(const char* hex, std::size_t sz, char* out) {

src/plugins/intel_npu/src/al/include/intel_npu/al/config/config.hpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,11 @@ struct TypePrinter {
3333
static constexpr const char* name();
3434
};
3535

36-
#define TYPE_PRINTER(type) \
37-
template <> \
38-
struct TypePrinter<type> { \
39-
static constexpr bool hasName() { \
40-
return true; \
41-
} \
42-
static constexpr const char* name() { \
43-
return #type; \
44-
} \
36+
#define TYPE_PRINTER(type) \
37+
template <> \
38+
struct TypePrinter<type> { \
39+
static constexpr bool hasName() { return true; } \
40+
static constexpr const char* name() { return #type; } \
4541
};
4642

4743
TYPE_PRINTER(bool)

src/tests/test_utils/common_test_utils/include/common_test_utils/graph_comparator.hpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,8 @@ class ReadAndStoreAttributes : public ov::AttributeVisitor, protected storage::S
517517
public:
518518
void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override;
519519

520-
#define ON_ADAPTER(TYPE) \
521-
void on_adapter(const std::string& name, ov::ValueAccessor<TYPE>& adapter) override { \
522-
insert(name, adapter.get()); \
523-
}
520+
#define ON_ADAPTER(TYPE) \
521+
void on_adapter(const std::string& name, ov::ValueAccessor<TYPE>& adapter) override { insert(name, adapter.get()); }
524522

525523
ON_ADAPTER(bool)
526524
ON_ADAPTER(std::string)
@@ -913,10 +911,8 @@ class ReadAndCompareAttributes : public ov::AttributeVisitor {
913911
verify_others(name, adapter);
914912
}
915913

916-
#define ON_ADAPTER(TYPE) \
917-
void on_adapter(const std::string& name, ov::ValueAccessor<TYPE>& adapter) override { \
918-
verify(name, adapter.get()); \
919-
}
914+
#define ON_ADAPTER(TYPE) \
915+
void on_adapter(const std::string& name, ov::ValueAccessor<TYPE>& adapter) override { verify(name, adapter.get()); }
920916

921917
ON_ADAPTER(bool)
922918
ON_ADAPTER(std::string)

0 commit comments

Comments
 (0)