clang-format: re-format for clang-18
clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.
See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.
Change-Id: I8078c8196a2d5706179dc10bf20c0af1a69ec962
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index d43e884..28e3328 100644
--- a/.clang-format
+++ b/.clang-format
@@ -87,7 +87,7 @@
IndentWrappedFunctionNames: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false
-LambdaBodyIndentation: OuterScope
+LambdaBodyIndentation: Signature
LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
@@ -98,13 +98,14 @@
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 25
-PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakBeforeFirstCallParameter: 50
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PenaltyIndentedWhitespace: 0
+PenaltyIndentedWhitespace: 1
PointerAlignment: Left
QualifierAlignment: Left
ReferenceAlignment: Left
diff --git a/association_manager.cpp b/association_manager.cpp
index 65897ca..2ff4cec 100644
--- a/association_manager.cpp
+++ b/association_manager.cpp
@@ -142,20 +142,20 @@
continue;
}
- auto interface = std::find_if(object.begin(), object.end(),
- [&condition](const auto& i) {
- return i.first == condition.interface;
- });
+ auto interface = std::find_if(
+ object.begin(), object.end(), [&condition](const auto& i) {
+ return i.first == condition.interface;
+ });
if (interface == object.end())
{
continue;
}
- auto property = std::find_if(interface->second.begin(),
- interface->second.end(),
- [&condition](const auto& p) {
- return condition.property == p.first;
- });
+ auto property =
+ std::find_if(interface->second.begin(), interface->second.end(),
+ [&condition](const auto& p) {
+ return condition.property == p.first;
+ });
if (property == interface->second.end())
{
continue;
@@ -279,11 +279,10 @@
}
}
-void Manager::createAssociation(const std::string& forwardPath,
- const std::string& forwardType,
- const std::string& reversePath,
- const std::string& reverseType,
- bool deferSignal)
+void Manager::createAssociation(
+ const std::string& forwardPath, const std::string& forwardType,
+ const std::string& reversePath, const std::string& reverseType,
+ bool deferSignal)
{
auto object = _associationIfaces.find(forwardPath);
if (object == _associationIfaces.end())
diff --git a/functor.cpp b/functor.cpp
index 272bd14..008e29f 100644
--- a/functor.cpp
+++ b/functor.cpp
@@ -30,17 +30,15 @@
{
namespace functor
{
-bool PropertyConditionBase::operator()(sdbusplus::bus_t& bus,
- sdbusplus::message_t&,
- Manager& mgr) const
+bool PropertyConditionBase::operator()(
+ sdbusplus::bus_t& bus, sdbusplus::message_t&, Manager& mgr) const
{
std::string path(_path);
return (*this)(path, bus, mgr);
}
-bool PropertyConditionBase::operator()(const std::string& path,
- sdbusplus::bus_t& bus,
- Manager& mgr) const
+bool PropertyConditionBase::operator()(
+ const std::string& path, sdbusplus::bus_t& bus, Manager& mgr) const
{
std::string host;
diff --git a/functor.hpp b/functor.hpp
index 903cbd0..ddb3604 100644
--- a/functor.hpp
+++ b/functor.hpp
@@ -199,8 +199,8 @@
PropertyChangedCondition& operator=(PropertyChangedCondition&&) = default;
PropertyChangedCondition(const char* iface, const char* property,
U&& condition) :
- _iface(iface),
- _property(property), _condition(std::forward<U>(condition))
+ _iface(iface), _property(property),
+ _condition(std::forward<U>(condition))
{}
/** @brief Test a property value.
@@ -267,8 +267,8 @@
*/
PropertyConditionBase(const char* path, const char* iface,
const char* property, const char* service) :
- _path(path ? path : std::string()),
- _iface(iface), _property(property), _service(service)
+ _path(path ? path : std::string()), _iface(iface), _property(property),
+ _service(service)
{}
/** @brief Forward comparison to type specific implementation. */
diff --git a/manager.cpp b/manager.cpp
index 27e60eb..f9e40c6 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -131,10 +131,9 @@
}
}
-void Manager::updateInterfaces(const sdbusplus::message::object_path& path,
- const Object& interfaces,
- ObjectReferences::iterator pos, bool newObject,
- bool restoreFromCache)
+void Manager::updateInterfaces(
+ const sdbusplus::message::object_path& path, const Object& interfaces,
+ ObjectReferences::iterator pos, bool newObject, bool restoreFromCache)
{
auto& refaces = pos->second;
auto ifaceit = interfaces.cbegin();
@@ -318,8 +317,8 @@
const_cast<const Manager*>(this)->getInterfaceHolder(path, interface));
}
-const std::any& Manager::getInterfaceHolder(const char* path,
- const char* interface) const
+const std::any&
+ Manager::getInterfaceHolder(const char* path, const char* interface) const
{
std::string p{path};
auto oit = _refs.find(_root + p);
@@ -343,8 +342,8 @@
return;
}
- static const std::string remove = std::string(PIM_PERSIST_PATH) +
- INVENTORY_ROOT;
+ static const std::string remove =
+ std::string(PIM_PERSIST_PATH) + INVENTORY_ROOT;
std::map<sdbusplus::message::object_path, Object> objects;
for (const auto& dirent :
@@ -405,8 +404,8 @@
auto& getProperty =
std::get<GetPropertyValueType>(maker->second);
- condition.actualValue = getProperty(condition.property,
- ifaceIt->second);
+ condition.actualValue =
+ getProperty(condition.property, ifaceIt->second);
}
}
}
@@ -416,11 +415,11 @@
// associations file is valid so create its associations.
if (_associations.conditionMatch())
{
- std::for_each(_refs.begin(), _refs.end(),
- [this](const auto& ref) {
- _associations.createAssociations(
- ref.first, _status != ManagerStatus::RUNNING);
- });
+ std::for_each(
+ _refs.begin(), _refs.end(), [this](const auto& ref) {
+ _associations.createAssociations(
+ ref.first, _status != ManagerStatus::RUNNING);
+ });
}
}
#endif
diff --git a/test/interface_ops_test.cpp b/test/interface_ops_test.cpp
index 1fb15ed..b6d6ac8 100644
--- a/test/interface_ops_test.cpp
+++ b/test/interface_ops_test.cpp
@@ -121,8 +121,8 @@
EXPECT_CALL(mock, constructWithProperties(_, _, _)).Times(0);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
EXPECT_NO_THROW(
std::any_cast<std::shared_ptr<DummyInterfaceWithoutProperties>>(r));
@@ -138,8 +138,8 @@
EXPECT_CALL(mock, constructWithProperties(_, _, _)).Times(0);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
EXPECT_NO_THROW(
std::any_cast<std::shared_ptr<DummyInterfaceWithoutProperties>>(r));
@@ -155,8 +155,8 @@
EXPECT_CALL(mock, constructWithProperties("bar", _, _)).Times(1);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "bar", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "bar", i, false);
EXPECT_NO_THROW(
std::any_cast<std::shared_ptr<DummyInterfaceWithProperties>>(r));
@@ -172,8 +172,8 @@
EXPECT_CALL(mock, constructWithProperties("foo", _, _)).Times(1);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i, false);
EXPECT_NO_THROW(
std::any_cast<std::shared_ptr<DummyInterfaceWithProperties>>(r));
@@ -188,8 +188,8 @@
EXPECT_CALL(mock, setPropertyByName(_, _, _)).Times(0);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
AssignInterface<DummyInterfaceWithoutProperties>::op(i, r, false);
}
@@ -203,8 +203,8 @@
EXPECT_CALL(mock, setPropertyByName(_, _, _)).Times(0);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
AssignInterface<DummyInterfaceWithoutProperties>::op(i, r, false);
}
@@ -218,8 +218,8 @@
EXPECT_CALL(mock, setPropertyByName(_, _, _)).Times(0);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i, false);
AssignInterface<DummyInterfaceWithProperties>::op(i, r, false);
}
@@ -233,8 +233,8 @@
EXPECT_CALL(mock, setPropertyByName("foo"s, 1ll, _)).Times(1);
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "bar", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "bar", i, false);
AssignInterface<DummyInterfaceWithProperties>::op(i, r, false);
}
@@ -246,8 +246,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, serializeTwoArgs("/foo"s, "bar"s)).Times(1);
@@ -262,8 +262,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, serializeTwoArgs("/foo"s, "bar"s)).Times(1);
@@ -278,8 +278,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, serializeThreeArgs("/foo"s, "bar"s, _)).Times(1);
@@ -294,8 +294,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, serializeThreeArgs("/foo"s, "bar"s, _)).Times(1);
@@ -310,8 +310,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, deserializeNoop()).Times(1);
@@ -326,8 +326,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithoutProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, deserializeNoop()).Times(1);
@@ -342,8 +342,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, deserializeThreeArgs("/foo"s, "bar"s, _)).Times(1);
@@ -358,8 +358,8 @@
sdbusplus::SdBusMock interface;
auto b = sdbusplus::get_mocked_new(&interface);
- auto r = MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i,
- false);
+ auto r =
+ MakeInterface<DummyInterfaceWithProperties>::op(b, "foo", i, false);
EXPECT_CALL(mock, deserializeThreeArgs("/foo"s, "bar"s, _)).Times(1);