clang-format: update to latest from docs repo
This is from openbmc/docs/style/cpp/.clang-format
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I5b80bb568451706afb6d268b41e1a5357a2ca6db
diff --git a/.clang-format b/.clang-format
index bbc1bb1..52ac0a1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,7 +5,7 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
+AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
@@ -14,13 +14,13 @@
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
-AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
-AlwaysBreakTemplateDeclarations: false
+AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
+ AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
@@ -29,25 +29,50 @@
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
+ AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
+BreakInheritanceList: AfterColon
+BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
-DerivePointerAlignment: true
+DerivePointerAlignment: false
PointerAlignment: Left
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+ - Regex: '^[<"](gtest|gmock)'
+ Priority: 7
+ - Regex: '^"config.h"'
+ Priority: -1
+ - Regex: '^".*\.h"'
+ Priority: 1
+ - Regex: '^".*\.hpp"'
+ Priority: 2
+ - Regex: '^<.*\.h>'
+ Priority: 3
+ - Regex: '^<.*\.hpp>'
+ Priority: 4
+ - Regex: '^<.*'
+ Priority: 5
+ - Regex: '.*'
+ Priority: 6
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
@@ -65,12 +90,17 @@
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
-PointerAlignment: Right
ReflowComments: true
-SortIncludes: false
+SortIncludes: true
+SortUsingDeclarations: true
SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
@@ -78,7 +108,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp
index bf10c22..26deec9 100644
--- a/bmc_state_manager.cpp
+++ b/bmc_state_manager.cpp
@@ -1,11 +1,15 @@
-#include <cassert>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <sdbusplus/exception.hpp>
-#include <sys/sysinfo.h>
#include "bmc_state_manager.hpp"
+
#include "xyz/openbmc_project/Common/error.hpp"
+#include <sys/sysinfo.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/exception.hpp>
+
+#include <cassert>
+
namespace phosphor
{
namespace state
diff --git a/bmc_state_manager.hpp b/bmc_state_manager.hpp
index c55c822..cf53795 100644
--- a/bmc_state_manager.hpp
+++ b/bmc_state_manager.hpp
@@ -1,9 +1,11 @@
#pragma once
-#include <functional>
-#include <sdbusplus/bus.hpp>
#include "xyz/openbmc_project/State/BMC/server.hpp"
+#include <sdbusplus/bus.hpp>
+
+#include <functional>
+
namespace phosphor
{
namespace state
diff --git a/bmc_state_manager_main.cpp b/bmc_state_manager_main.cpp
index c03eeac..5867e51 100644
--- a/bmc_state_manager_main.cpp
+++ b/bmc_state_manager_main.cpp
@@ -1,7 +1,9 @@
-#include <sdbusplus/bus.hpp>
#include "config.h"
+
#include "bmc_state_manager.hpp"
+#include <sdbusplus/bus.hpp>
+
int main()
{
auto bus = sdbusplus::bus::new_default();
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp
index 17db4df..6fa10ee 100644
--- a/chassis_state_manager.cpp
+++ b/chassis_state_manager.cpp
@@ -1,16 +1,20 @@
+#include "config.h"
+
+#include "chassis_state_manager.hpp"
+
+#include "xyz/openbmc_project/Common/error.hpp"
+#include "xyz/openbmc_project/State/Shutdown/Power/error.hpp"
+
+#include <cereal/archives/json.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/exception.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/exception.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include "xyz/openbmc_project/Common/error.hpp"
-#include "xyz/openbmc_project/State/Shutdown/Power/error.hpp"
-#include "chassis_state_manager.hpp"
-#include <cereal/archives/json.hpp>
-#include <fstream>
-#include "config.h"
+
#include <experimental/filesystem>
+#include <fstream>
namespace phosphor
{
diff --git a/chassis_state_manager.hpp b/chassis_state_manager.hpp
index d1943dc..601e2a6 100644
--- a/chassis_state_manager.hpp
+++ b/chassis_state_manager.hpp
@@ -1,16 +1,19 @@
#pragma once
-#include <chrono>
-#include <functional>
-#include <experimental/filesystem>
+#include "config.h"
+
+#include "xyz/openbmc_project/State/Chassis/server.hpp"
+#include "xyz/openbmc_project/State/PowerOnHours/server.hpp"
+
#include <cereal/cereal.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>
-#include "xyz/openbmc_project/State/Chassis/server.hpp"
-#include "xyz/openbmc_project/State/PowerOnHours/server.hpp"
-#include "config.h"
+
+#include <chrono>
+#include <experimental/filesystem>
+#include <functional>
namespace phosphor
{
diff --git a/chassis_state_manager_main.cpp b/chassis_state_manager_main.cpp
index 30112a4..c78eea4 100644
--- a/chassis_state_manager_main.cpp
+++ b/chassis_state_manager_main.cpp
@@ -1,10 +1,13 @@
-#include <cstdlib>
-#include <iostream>
-#include <exception>
-#include <sdbusplus/bus.hpp>
#include "config.h"
+
#include "chassis_state_manager.hpp"
+#include <sdbusplus/bus.hpp>
+
+#include <cstdlib>
+#include <exception>
+#include <iostream>
+
int main()
{
auto bus = sdbusplus::bus::new_default();
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index 14b6117..06a32c4 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -1,18 +1,22 @@
-#include <getopt.h>
-#include <iostream>
-#include <map>
-#include <string>
#include "config.h"
-#include <systemd/sd-bus.h>
-#include <sdbusplus/exception.hpp>
-#include <sdbusplus/server.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog-errors.hpp>
+
#include "host_state_manager.hpp"
#include "settings.hpp"
#include "xyz/openbmc_project/Common/error.hpp"
#include "xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp"
+#include <getopt.h>
+#include <systemd/sd-bus.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/exception.hpp>
+#include <sdbusplus/server.hpp>
+
+#include <iostream>
+#include <map>
+#include <string>
+
namespace phosphor
{
namespace state
diff --git a/host_check_main.cpp b/host_check_main.cpp
index 56b22fb..e055abc 100644
--- a/host_check_main.cpp
+++ b/host_check_main.cpp
@@ -1,13 +1,16 @@
-#include <cstdlib>
+#include "config.h"
+
#include <unistd.h>
-#include <iostream>
-#include <fstream>
-#include <cstdio>
+
+#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/exception.hpp>
-#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Control/Host/server.hpp>
-#include "config.h"
+
+#include <cstdio>
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
using namespace std::literals;
using namespace phosphor::logging;
diff --git a/host_state_manager.cpp b/host_state_manager.cpp
index e2d8010..ed083c2 100644
--- a/host_state_manager.cpp
+++ b/host_state_manager.cpp
@@ -1,21 +1,25 @@
+#include "config.h"
+
+#include "host_state_manager.hpp"
+
+#include <systemd/sd-bus.h>
+
+#include <cereal/archives/json.hpp>
+#include <cereal/cereal.hpp>
+#include <cereal/types/string.hpp>
+#include <cereal/types/tuple.hpp>
+#include <cereal/types/vector.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/exception.hpp>
+#include <sdbusplus/server.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp>
+
+#include <fstream>
#include <iostream>
#include <map>
#include <string>
-#include <systemd/sd-bus.h>
-#include <cereal/cereal.hpp>
-#include <cereal/types/string.hpp>
-#include <cereal/types/vector.hpp>
-#include <cereal/types/tuple.hpp>
-#include <cereal/archives/json.hpp>
-#include <fstream>
-#include <sdbusplus/exception.hpp>
-#include <sdbusplus/server.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "host_state_manager.hpp"
-#include "config.h"
// Register class version with Cereal
CEREAL_CLASS_VERSION(phosphor::state::manager::Host, CLASS_VERSION)
diff --git a/host_state_manager.hpp b/host_state_manager.hpp
index c57c8aa..af22ade 100644
--- a/host_state_manager.hpp
+++ b/host_state_manager.hpp
@@ -1,18 +1,21 @@
#pragma once
-#include <string>
-#include <functional>
-#include <experimental/filesystem>
+#include "config.h"
+
+#include "settings.hpp"
+#include "xyz/openbmc_project/State/Host/server.hpp"
+
#include <cereal/access.hpp>
#include <cereal/cereal.hpp>
-#include <sdbusplus/bus.hpp>
#include <phosphor-logging/log.hpp>
-#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
+#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Control/Boot/RebootAttempts/server.hpp>
+#include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
#include <xyz/openbmc_project/State/OperatingSystem/Status/server.hpp>
-#include "xyz/openbmc_project/State/Host/server.hpp"
-#include "settings.hpp"
-#include "config.h"
+
+#include <experimental/filesystem>
+#include <functional>
+#include <string>
namespace phosphor
{
diff --git a/host_state_manager_main.cpp b/host_state_manager_main.cpp
index 6c82cf9..865987c 100644
--- a/host_state_manager_main.cpp
+++ b/host_state_manager_main.cpp
@@ -1,11 +1,14 @@
-#include <cstdlib>
-#include <iostream>
-#include <exception>
-#include <sdbusplus/bus.hpp>
-#include <experimental/filesystem>
#include "config.h"
+
#include "host_state_manager.hpp"
+#include <sdbusplus/bus.hpp>
+
+#include <cstdlib>
+#include <exception>
+#include <experimental/filesystem>
+#include <iostream>
+
int main()
{
namespace fs = std::experimental::filesystem;
diff --git a/scheduled_host_transition.cpp b/scheduled_host_transition.cpp
index 4bf16bd..1eb48f4 100644
--- a/scheduled_host_transition.cpp
+++ b/scheduled_host_transition.cpp
@@ -1,16 +1,19 @@
#include "scheduled_host_transition.hpp"
+
#include "utils.hpp"
+#include <sys/timerfd.h>
+#include <unistd.h>
+
+#include <cereal/archives/json.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/ScheduledTime/error.hpp>
-#include <cereal/archives/json.hpp>
+
#include <chrono>
#include <filesystem>
#include <fstream>
-#include <sys/timerfd.h>
-#include <unistd.h>
// Need to do this since its not exported outside of the kernel.
// Refer : https://gist.github.com/lethean/446cea944b7441228298
diff --git a/scheduled_host_transition.hpp b/scheduled_host_transition.hpp
index b42c5ae..4b75ad3 100644
--- a/scheduled_host_transition.hpp
+++ b/scheduled_host_transition.hpp
@@ -1,11 +1,12 @@
#pragma once
-#include <sdbusplus/bus.hpp>
+#include "config.h"
+
#include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>
#include <xyz/openbmc_project/State/ScheduledHostTransition/server.hpp>
-#include "config.h"
class TestScheduledHostTransition;
diff --git a/scheduled_host_transition_main.cpp b/scheduled_host_transition_main.cpp
index 61ab47a..c116f01 100644
--- a/scheduled_host_transition_main.cpp
+++ b/scheduled_host_transition_main.cpp
@@ -1,9 +1,12 @@
+#include "config.h"
+
+#include "scheduled_host_transition.hpp"
+
+#include <sdbusplus/bus.hpp>
+
#include <cstdlib>
#include <exception>
-#include <sdbusplus/bus.hpp>
#include <filesystem>
-#include "config.h"
-#include "scheduled_host_transition.hpp"
int main()
{
diff --git a/settings.cpp b/settings.cpp
index 7f9f236..7a7784b 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -1,8 +1,10 @@
+#include "settings.hpp"
+
+#include "xyz/openbmc_project/Common/error.hpp"
+
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/exception.hpp>
-#include "xyz/openbmc_project/Common/error.hpp"
-#include "settings.hpp"
namespace settings
{
diff --git a/settings.hpp b/settings.hpp
index 7571fe1..dca5cf9 100644
--- a/settings.hpp
+++ b/settings.hpp
@@ -1,8 +1,9 @@
#pragma once
-#include <string>
#include <sdbusplus/bus.hpp>
+#include <string>
+
namespace settings
{
diff --git a/systemd_target_monitor.cpp b/systemd_target_monitor.cpp
index c269f32..d5e7a38 100644
--- a/systemd_target_monitor.cpp
+++ b/systemd_target_monitor.cpp
@@ -1,10 +1,12 @@
+#include "systemd_target_parser.hpp"
+#include "systemd_target_signal.hpp"
+
#include <CLI/CLI.hpp>
-#include <iostream>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
-#include "systemd_target_parser.hpp"
-#include "systemd_target_signal.hpp"
+
+#include <iostream>
#include <vector>
using phosphor::logging::level;
diff --git a/systemd_target_parser.cpp b/systemd_target_parser.cpp
index 391d30a..7015c00 100644
--- a/systemd_target_parser.cpp
+++ b/systemd_target_parser.cpp
@@ -1,7 +1,8 @@
+#include "systemd_target_parser.hpp"
+
#include <cassert>
#include <fstream>
#include <iostream>
-#include "systemd_target_parser.hpp"
void validateErrorsToMonitor(std::vector<std::string>& errorsToMonitor)
{
diff --git a/systemd_target_parser.hpp b/systemd_target_parser.hpp
index fbe3814..3de63f2 100644
--- a/systemd_target_parser.hpp
+++ b/systemd_target_parser.hpp
@@ -1,11 +1,11 @@
#pragma once
+#include <nlohmann/json.hpp>
+
#include <map>
#include <string>
#include <vector>
-#include <nlohmann/json.hpp>
-
/** @brief Stores the error to log if errors to monitor is found */
struct targetEntry
{
diff --git a/systemd_target_signal.cpp b/systemd_target_signal.cpp
index f27e418..7d1d1db 100644
--- a/systemd_target_signal.cpp
+++ b/systemd_target_signal.cpp
@@ -1,9 +1,10 @@
-#include <phosphor-logging/log.hpp>
+#include "systemd_target_signal.hpp"
+
#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/exception.hpp>
#include <sdbusplus/server/manager.hpp>
#include <sdeventplus/event.hpp>
-#include <sdbusplus/exception.hpp>
-#include "systemd_target_signal.hpp"
#include <xyz/openbmc_project/Common/error.hpp>
namespace phosphor
diff --git a/systemd_target_signal.hpp b/systemd_target_signal.hpp
index 0d0abad..d9a58c7 100644
--- a/systemd_target_signal.hpp
+++ b/systemd_target_signal.hpp
@@ -1,8 +1,9 @@
#pragma once
+#include "systemd_target_parser.hpp"
+
#include <sdbusplus/bus.hpp>
#include <sdbusplus/bus/match.hpp>
-#include "systemd_target_parser.hpp"
extern bool gVerbose;
@@ -45,8 +46,7 @@
std::bind(
std::mem_fn(&SystemdTargetLogging::processNameChangeSignal),
this, std::placeholders::_1))
- {
- }
+ {}
/**
* @brief subscribe to the systemd signals
diff --git a/test/systemd_parser.cpp b/test/systemd_parser.cpp
index cb3a609..cbe795c 100644
--- a/test/systemd_parser.cpp
+++ b/test/systemd_parser.cpp
@@ -1,10 +1,11 @@
#include <systemd_target_parser.hpp>
-#include <gtest/gtest.h>
-#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <filesystem>
+#include <iostream>
+
+#include <gtest/gtest.h>
namespace fs = std::filesystem;
diff --git a/test/systemd_signal.cpp b/test/systemd_signal.cpp
index ce0a299..cd4b980 100644
--- a/test/systemd_signal.cpp
+++ b/test/systemd_signal.cpp
@@ -1,10 +1,11 @@
-#include <gtest/gtest.h>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
#include <systemd_target_signal.hpp>
#include <iostream>
+#include <gtest/gtest.h>
+
// Enable debug by default for debug when needed
bool gVerbose = true;
diff --git a/test/test_scheduled_host_transition.cpp b/test/test_scheduled_host_transition.cpp
index f148b59..fc4c6a0 100644
--- a/test/test_scheduled_host_transition.cpp
+++ b/test/test_scheduled_host_transition.cpp
@@ -1,12 +1,13 @@
#include "scheduled_host_transition.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <sdeventplus/event.hpp>
#include <xyz/openbmc_project/ScheduledTime/error.hpp>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
namespace phosphor
{
namespace state