Update clang-format

refer: https://github.com/openbmc/docs/blob/master/style/cpp/.clang-format

Tested: built openpower-occ-control successfully.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I136870023229ff906d471dd4d8debfd404812ff1
diff --git a/.clang-format b/.clang-format
index ea71ad6..abedc25 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: true
+AlwaysBreakTemplateDeclarations: Yes
 BinPackArguments: true
 BinPackParameters: true
 BraceWrapping:
+  AfterCaseLabel:  true
   AfterClass:      true
   AfterControlStatement: true
   AfterEnum:       true
@@ -29,15 +29,22 @@
   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: false
 ColumnLimit:     80
 CommentPragmas:  '^ IWYU pragma:'
+CompactNamespaces: false
 ConstructorInitializerAllOnOneLineOrOnePerLine: false
 ConstructorInitializerIndentWidth: 4
 ContinuationIndentWidth: 4
@@ -51,17 +58,21 @@
 IncludeBlocks: Regroup
 IncludeCategories:
   - Regex:           '^[<"](gtest|gmock)'
-    Priority:        5
+    Priority:        7
   - Regex:           '^"config.h"'
     Priority:        -1
-  - Regex:           '^".*\.hpp"'
+  - Regex:           '^".*\.h"'
     Priority:        1
-  - Regex:           '^<.*\.h>'
+  - Regex:           '^".*\.hpp"'
     Priority:        2
-  - Regex:           '^<.*'
+  - Regex:           '^<.*\.h>'
     Priority:        3
-  - Regex:           '.*'
+  - Regex:           '^<.*\.hpp>'
     Priority:        4
+  - Regex:           '^<.*'
+    Priority:        5
+  - Regex:           '.*'
+    Priority:        6
 IndentCaseLabels: true
 IndentWidth:     4
 IndentWrappedFunctionNames: true
@@ -83,8 +94,13 @@
 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
@@ -92,8 +108,7 @@
 SpacesInCStyleCastParentheses: false
 SpacesInParentheses: false
 SpacesInSquareBrackets: false
-Standard:        Cpp11
+Standard:        Latest
 TabWidth:        4
 UseTab:          Never
 ...
-
diff --git a/elog-errors.hpp b/elog-errors.hpp
index 6f87a57..7c937a5 100644
--- a/elog-errors.hpp
+++ b/elog-errors.hpp
@@ -5,6 +5,7 @@
 #include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/exception.hpp>
+
 #include <string>
 #include <tuple>
 #include <type_traits>
@@ -375,9 +376,7 @@
 namespace Host
 {
 namespace _CommandNotSupported
-{
-
-} // namespace _CommandNotSupported
+{} // namespace _CommandNotSupported
 
 struct CommandNotSupported
 {
@@ -452,9 +451,7 @@
 namespace Common
 {
 namespace _InternalFailure
-{
-
-} // namespace _InternalFailure
+{} // namespace _InternalFailure
 
 struct InternalFailure
 {
@@ -1122,9 +1119,7 @@
 namespace Host
 {
 namespace _SoftOffTimeout
-{
-
-} // namespace _SoftOffTimeout
+{} // namespace _SoftOffTimeout
 
 struct SoftOffTimeout
 {
@@ -1160,9 +1155,7 @@
 namespace Device
 {
 namespace _WriteFailure
-{
-
-} // namespace _WriteFailure
+{} // namespace _WriteFailure
 
 struct WriteFailure
 {
@@ -1200,9 +1193,7 @@
 namespace Device
 {
 namespace _OpenFailure
-{
-
-} // namespace _OpenFailure
+{} // namespace _OpenFailure
 
 struct OpenFailure
 {
@@ -1240,9 +1231,7 @@
 namespace Device
 {
 namespace _ReadFailure
-{
-
-} // namespace _ReadFailure
+{} // namespace _ReadFailure
 
 struct ReadFailure
 {
@@ -1280,9 +1269,7 @@
 namespace Device
 {
 namespace _WriteFailure
-{
-
-} // namespace _WriteFailure
+{} // namespace _WriteFailure
 
 struct WriteFailure
 {
@@ -1320,9 +1307,7 @@
 namespace Device
 {
 namespace _ConfigFailure
-{
-
-} // namespace _ConfigFailure
+{} // namespace _ConfigFailure
 
 struct ConfigFailure
 {
@@ -1360,9 +1345,7 @@
 namespace Device
 {
 namespace _ReadFailure
-{
-
-} // namespace _ReadFailure
+{} // namespace _ReadFailure
 
 struct ReadFailure
 {
diff --git a/occ_command.cpp b/occ_command.cpp
index 5d693e7..d9faea2 100644
--- a/occ_command.cpp
+++ b/occ_command.cpp
@@ -9,11 +9,12 @@
 #include <fmt/core.h>
 #include <unistd.h>
 
-#include <algorithm>
-#include <memory>
 #include <org/open_power/OCC/Device/error.hpp>
 #include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/log.hpp>
+
+#include <algorithm>
+#include <memory>
 #include <string>
 
 //#define TRACE_PACKETS
diff --git a/occ_command.hpp b/occ_command.hpp
index 42962d9..3ea9b19 100644
--- a/occ_command.hpp
+++ b/occ_command.hpp
@@ -6,6 +6,7 @@
 #include <org/open_power/OCC/PassThrough/server.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
+
 #include <string>
 
 namespace open_power
diff --git a/occ_dbus.cpp b/occ_dbus.cpp
index 2ed2f3b..dde2e7d 100644
--- a/occ_dbus.cpp
+++ b/occ_dbus.cpp
@@ -2,9 +2,10 @@
 
 #include "utils.hpp"
 
-#include <iostream>
 #include <phosphor-logging/log.hpp>
 
+#include <iostream>
+
 namespace open_power
 {
 namespace occ
diff --git a/occ_dbus.hpp b/occ_dbus.hpp
index 330f140..d042ea8 100644
--- a/occ_dbus.hpp
+++ b/occ_dbus.hpp
@@ -26,8 +26,7 @@
 {
   private:
     OccDBusSensors()
-    {
-    }
+    {}
 
   public:
     OccDBusSensors(const OccDBusSensors&) = delete;
diff --git a/occ_device.hpp b/occ_device.hpp
index 50dd11d..4215640 100644
--- a/occ_device.hpp
+++ b/occ_device.hpp
@@ -6,9 +6,10 @@
 #include "occ_events.hpp"
 #include "occ_presence.hpp"
 
+#include <org/open_power/OCC/Device/error.hpp>
+
 #include <experimental/filesystem>
 #include <fstream>
-#include <org/open_power/OCC/Device/error.hpp>
 
 namespace open_power
 {
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 04276b9..6191a75 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -6,13 +6,14 @@
 #include "occ_dbus.hpp"
 #include "utils.hpp"
 
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
 #include <chrono>
 #include <cmath>
 #include <experimental/filesystem>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
 #include <regex>
-#include <xyz/openbmc_project/Common/error.hpp>
 
 namespace open_power
 {
@@ -187,10 +188,11 @@
 
     if ((!_pollTimer->isEnabled()) && (activeCount > 0))
     {
-        log<level::INFO>(fmt::format("Manager::statusCallBack(): {} OCCs will "
-                                     "be polled every {} seconds",
-                                     activeCount, pollInterval)
-                             .c_str());
+        log<level::INFO>(
+            fmt::format(
+                "Manager::statusCallBack(): {} OCCs will be polled every {} seconds",
+                activeCount, pollInterval)
+                .c_str());
 
         // Send poll and start OCC poll timer
         pollerTimerExpired();
@@ -198,8 +200,8 @@
     else if ((_pollTimer->isEnabled()) && (activeCount == 0))
     {
         // Stop OCC poll timer
-        log<level::INFO>("Manager::statusCallBack(): OCCs are not running, "
-                         "stopping poll timer");
+        log<level::INFO>(
+            "Manager::statusCallBack(): OCCs are not running, stopping poll timer");
         _pollTimer->setEnabled(false);
 
 #ifdef READ_OCC_SENSORS
@@ -249,8 +251,8 @@
     if (activeCount == 0)
     {
         // No OCCs running, so poll timer will not be restarted
-        log<level::INFO>("Manager::pollerTimerExpire(): No OCCs running, poll "
-                         "timer not restarted");
+        log<level::INFO>(
+            "Manager::pollerTimerExpire(): No OCCs running, poll timer not restarted");
     }
 
     if (!_pollTimer)
@@ -349,10 +351,11 @@
                 auto iter = dimmTempSensorName.find(fruTypeValue);
                 if (iter == dimmTempSensorName.end())
                 {
-                    log<level::ERR>(fmt::format("readTempSensors: Fru type "
-                                                "error! fruTypeValue = {}) ",
-                                                fruTypeValue)
-                                        .c_str());
+                    log<level::ERR>(
+                        fmt::format(
+                            "readTempSensors: Fru type error! fruTypeValue = {}) ",
+                            fruTypeValue)
+                            .c_str());
                     continue;
                 }
 
diff --git a/occ_manager.hpp b/occ_manager.hpp
index 140b14a..dbb3cf6 100644
--- a/occ_manager.hpp
+++ b/occ_manager.hpp
@@ -11,11 +11,12 @@
 #include "powermode.hpp"
 #endif
 
-#include <cstring>
-#include <functional>
 #include <sdbusplus/bus.hpp>
 #include <sdeventplus/event.hpp>
 #include <sdeventplus/utility/timer.hpp>
+
+#include <cstring>
+#include <functional>
 #include <vector>
 
 namespace sdbusRule = sdbusplus::bus::match::rules;
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp
index a53cba4..db133b1 100644
--- a/occ_pass_through.cpp
+++ b/occ_pass_through.cpp
@@ -9,11 +9,12 @@
 #include <fmt/core.h>
 #include <unistd.h>
 
-#include <algorithm>
-#include <memory>
 #include <org/open_power/OCC/Device/error.hpp>
 #include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/log.hpp>
+
+#include <algorithm>
+#include <memory>
 #include <string>
 
 namespace open_power
@@ -73,10 +74,10 @@
     {
         if (response.size() >= 5)
         {
-            log<level::DEBUG>(fmt::format("PassThrough::send() "
-                                          "response had {} bytes",
-                                          response.size())
-                                  .c_str());
+            log<level::DEBUG>(
+                fmt::format("PassThrough::send() response had {} bytes",
+                            response.size())
+                    .c_str());
         }
         else
         {
diff --git a/occ_pass_through.hpp b/occ_pass_through.hpp
index ef31826..185db79 100644
--- a/occ_pass_through.hpp
+++ b/occ_pass_through.hpp
@@ -9,6 +9,7 @@
 #include <phosphor-logging/log.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
+
 #include <string>
 
 namespace open_power
diff --git a/occ_status.cpp b/occ_status.cpp
index 344134f..ab6b9d1 100644
--- a/occ_status.cpp
+++ b/occ_status.cpp
@@ -280,10 +280,11 @@
     status = sendModeChange();
     if (status != CmdStatus::SUCCESS)
     {
-        log<level::ERR>(fmt::format("Status::occsWentActive: OCC mode "
-                                    "change failed with status {}",
-                                    status)
-                            .c_str());
+        log<level::ERR>(
+            fmt::format(
+                "Status::occsWentActive: OCC mode change failed with status {}",
+                status)
+                .c_str());
     }
 
     status = sendIpsData();
@@ -291,8 +292,7 @@
     {
         log<level::ERR>(
             fmt::format(
-                "Status::occsWentActive: Sending Idle Power Save Config data"
-                " failed with status {}",
+                "Status::occsWentActive: Sending Idle Power Save Config data failed with status {}",
                 status)
                 .c_str());
     }
@@ -306,17 +306,17 @@
     if (!device.master())
     {
         log<level::ERR>(
-            fmt::format("Status::sendModeChange: MODE CHANGE does not "
-                        "get sent to slave OCC{}",
-                        instance)
+            fmt::format(
+                "Status::sendModeChange: MODE CHANGE does not get sent to slave OCC{}",
+                instance)
                 .c_str());
         return status;
     }
     if (!isPowerVM())
     {
         // Mode change is only supported on PowerVM systems
-        log<level::DEBUG>("Status::sendModeChange: MODE CHANGE does not "
-                          "get sent on non-PowerVM systems");
+        log<level::DEBUG>(
+            "Status::sendModeChange: MODE CHANGE does not get sent on non-PowerVM systems");
         return CmdStatus::SUCCESS;
     }
 
@@ -334,10 +334,11 @@
         cmd.push_back(0x00); // Mode Data (Freq Point)
         cmd.push_back(0x00); //
         cmd.push_back(0x00); // reserved
-        log<level::INFO>(fmt::format("Status::sendModeChange: SET_MODE({}) "
-                                     "command to OCC{} ({} bytes)",
-                                     newMode, instance, cmd.size())
-                             .c_str());
+        log<level::INFO>(
+            fmt::format(
+                "Status::sendModeChange: SET_MODE({}) command to OCC{} ({} bytes)",
+                newMode, instance, cmd.size())
+                .c_str());
         status = occCmd.send(cmd, rsp);
         if (status == CmdStatus::SUCCESS)
         {
@@ -345,15 +346,15 @@
             {
                 if (RspStatus::SUCCESS == RspStatus(rsp[2]))
                 {
-                    log<level::DEBUG>("Status::sendModeChange: - Mode change "
-                                      "completed successfully");
+                    log<level::DEBUG>(
+                        "Status::sendModeChange: - Mode change completed successfully");
                 }
                 else
                 {
                     log<level::ERR>(
-                        fmt::format("Status::sendModeChange: SET MODE "
-                                    "failed with status 0x{:02X}",
-                                    rsp[2])
+                        fmt::format(
+                            "Status::sendModeChange: SET MODE failed with status 0x{:02X}",
+                            rsp[2])
                             .c_str());
                 }
             }
@@ -397,17 +398,17 @@
     if (!device.master())
     {
         log<level::ERR>(
-            fmt::format("Status::sendIpsData: SET_CFG_DATA[IPS] does not "
-                        "get sent to slave OCC{}",
-                        instance)
+            fmt::format(
+                "Status::sendIpsData: SET_CFG_DATA[IPS] does not get sent to slave OCC{}",
+                instance)
                 .c_str());
         return status;
     }
     if (!isPowerVM())
     {
         // Idle Power Saver data is only supported on PowerVM systems
-        log<level::DEBUG>("Status::sendIpsData: SET_CFG_DATA[IPS] does not "
-                          "get sent on non-PowerVM systems");
+        log<level::DEBUG>(
+            "Status::sendIpsData: SET_CFG_DATA[IPS] does not get sent on non-PowerVM systems");
         return CmdStatus::SUCCESS;
     }
 
@@ -425,10 +426,11 @@
     cmd.push_back(0x00); // Exit Delay Time (10s)
     cmd.push_back(0x0A); //
     cmd.push_back(0x0C); // Exit Utilization (12%)
-    log<level::INFO>(fmt::format("Status::sendIpsData: SET_CFG_DATA[IPS] "
-                                 "command to OCC{} ({} bytes)",
-                                 instance, cmd.size())
-                         .c_str());
+    log<level::INFO>(
+        fmt::format(
+            "Status::sendIpsData: SET_CFG_DATA[IPS] command to OCC{} ({} bytes)",
+            instance, cmd.size())
+            .c_str());
     status = occCmd.send(cmd, rsp);
     if (status == CmdStatus::SUCCESS)
     {
@@ -436,15 +438,15 @@
         {
             if (RspStatus::SUCCESS == RspStatus(rsp[2]))
             {
-                log<level::DEBUG>("Status::sendIpsData: - SET_CFG_DATA[IPS] "
-                                  "completed successfully");
+                log<level::DEBUG>(
+                    "Status::sendIpsData: - SET_CFG_DATA[IPS] completed successfully");
             }
             else
             {
                 log<level::ERR>(
-                    fmt::format("Status::sendIpsData: SET_CFG_DATA[IPS] "
-                                "failed with status 0x{:02X}",
-                                rsp[2])
+                    fmt::format(
+                        "Status::sendIpsData: SET_CFG_DATA[IPS] failed with status 0x{:02X}",
+                        rsp[2])
                         .c_str());
             }
         }
diff --git a/occ_status.hpp b/occ_status.hpp
index a1cf82e..dce73f8 100644
--- a/occ_status.hpp
+++ b/occ_status.hpp
@@ -6,12 +6,13 @@
 #include "occ_events.hpp"
 #include "utils.hpp"
 
-#include <functional>
 #include <org/open_power/Control/Host/server.hpp>
 #include <org/open_power/OCC/Status/server.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/server/object.hpp>
 
+#include <functional>
+
 namespace open_power
 {
 namespace occ
diff --git a/pldm.cpp b/pldm.cpp
index 2552183..30faf89 100644
--- a/pldm.cpp
+++ b/pldm.cpp
@@ -42,8 +42,8 @@
 
     if (!offsetFound)
     {
-        log<level::ERR>("pldm: OCC state sensor PDR with StateSetId "
-                        "PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS not found");
+        log<level::ERR>(
+            "pldm: OCC state sensor PDR with StateSetId PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS not found");
         return;
     }
 
diff --git a/pldm.hpp b/pldm.hpp
index a10284d..811ed47 100644
--- a/pldm.hpp
+++ b/pldm.hpp
@@ -69,8 +69,7 @@
                                           "xyz.openbmc_project.State.Host"),
             std::bind(std::mem_fn(&Interface::hostStateEvent), this,
                       std::placeholders::_1))
-    {
-    }
+    {}
 
     /** @brief Fetch the OCC state sensor PDRs and populate the cache with
      *         sensorId to OCC instance mapping information and the sensor
diff --git a/powercap.cpp b/powercap.cpp
index e435096..ccf2998 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -1,6 +1,7 @@
-#include <cassert>
 #include <phosphor-logging/log.hpp>
 #include <powercap.hpp>
+
+#include <cassert>
 #include <regex>
 
 namespace open_power
diff --git a/powercap.hpp b/powercap.hpp
index bb4dc8b..212c1c2 100644
--- a/powercap.hpp
+++ b/powercap.hpp
@@ -5,10 +5,11 @@
 #include "occ_status.hpp"
 #include "utils.hpp"
 
-#include <experimental/filesystem>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/bus/match.hpp>
 
+#include <experimental/filesystem>
+
 namespace open_power
 {
 namespace occ
diff --git a/powermode.cpp b/powermode.cpp
index af739cb..32af335 100644
--- a/powermode.cpp
+++ b/powermode.cpp
@@ -1,11 +1,12 @@
 #include <fmt/core.h>
 
-#include <cassert>
 #include <phosphor-logging/log.hpp>
 #include <powermode.hpp>
-#include <regex>
 #include <xyz/openbmc_project/Control/Power/Mode/server.hpp>
 
+#include <cassert>
+#include <regex>
+
 namespace open_power
 {
 namespace occ
diff --git a/powermode.hpp b/powermode.hpp
index 472fd3e..ddb1072 100644
--- a/powermode.hpp
+++ b/powermode.hpp
@@ -5,10 +5,11 @@
 
 #include "occ_status.hpp"
 
-#include <experimental/filesystem>
 #include <sdbusplus/bus.hpp>
 #include <sdbusplus/bus/match.hpp>
 
+#include <experimental/filesystem>
+
 namespace open_power
 {
 namespace occ
diff --git a/test/utest.cpp b/test/utest.cpp
index 704c5c6..2933023 100644
--- a/test/utest.cpp
+++ b/test/utest.cpp
@@ -1,10 +1,11 @@
 #include "powercap.hpp"
 #include "utils.hpp"
 
-#include <experimental/filesystem>
 #include <occ_events.hpp>
 #include <occ_manager.hpp>
 
+#include <experimental/filesystem>
+
 #include <gtest/gtest.h>
 
 using namespace open_power::occ;
@@ -21,8 +22,7 @@
         event = nullptr;
     }
     ~VerifyOccInput()
-    {
-    }
+    {}
 
     sd_event* event;
     int rc;
diff --git a/utils.cpp b/utils.cpp
index 9a412a3..73ee3a7 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -2,8 +2,9 @@
 
 #include <phosphor-logging/elog-errors.hpp>
 #include <sdbusplus/bus.hpp>
-#include <string>
 #include <xyz/openbmc_project/Common/error.hpp>
+
+#include <string>
 namespace open_power
 {
 namespace occ
diff --git a/utils.hpp b/utils.hpp
index 5e49f83..9b78cd1 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -1,7 +1,8 @@
 #pragma once
 
-#include <optional>
 #include <sdbusplus/bus.hpp>
+
+#include <optional>
 #include <string>
 #include <tuple>