Update clang-format

Refer:https://github.com/openbmc/docs/blob/ac5d544553934f8083c61c5986a1420261bc8a4c/style/cpp/.clang-format

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I593ddf950d14009ab77251fd6d3f248214661765
diff --git a/.clang-format b/.clang-format
index ea71ad6..79a474d 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,19 +29,27 @@
   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
 Cpp11BracedListStyle: true
+DeriveLineEnding: false
 DerivePointerAlignment: false
 PointerAlignment: Left
 DisableFormat:   false
@@ -51,21 +59,25 @@
 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
-KeepEmptyLinesAtTheStartOfBlocks: true
+KeepEmptyLinesAtTheStartOfBlocks: false
 MacroBlockBegin: ''
 MacroBlockEnd:   ''
 MaxEmptyLinesToKeep: 1
@@ -83,8 +95,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 +109,8 @@
 SpacesInCStyleCastParentheses: false
 SpacesInParentheses: false
 SpacesInSquareBrackets: false
-Standard:        Cpp11
+Standard:        Latest
 TabWidth:        4
+UseCRLF: false
 UseTab:          Never
 ...
-
diff --git a/inc/button_factory.hpp b/inc/button_factory.hpp
index 1c513ef..0d427f7 100644
--- a/inc/button_factory.hpp
+++ b/inc/button_factory.hpp
@@ -4,6 +4,7 @@
 #include "gpio.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
+
 #include <unordered_map>
 
 using buttonIfCreatorMethod = std::function<std::unique_ptr<ButtonIface>(
@@ -16,7 +17,6 @@
 
 class ButtonFactory
 {
-
   public:
     static ButtonFactory& instance()
     {
@@ -35,7 +35,6 @@
     template <typename T>
     void addToRegistry()
     {
-
         buttonIfaceRegistry[std::string(T::getFormFactorName())] =
             [](sdbusplus::bus::bus& bus, EventPtr& event,
                buttonConfig& buttonCfg) {
@@ -52,7 +51,6 @@
                                                 EventPtr& event,
                                                 buttonConfig& buttonCfg)
     {
-
         // find matching name in the registry and call factory method.
         auto objectIter = buttonIfaceRegistry.find(name);
         if (objectIter != buttonIfaceRegistry.end())
diff --git a/inc/button_interface.hpp b/inc/button_interface.hpp
index f37a29c..0a0181b 100644
--- a/inc/button_interface.hpp
+++ b/inc/button_interface.hpp
@@ -9,7 +9,6 @@
 //
 class ButtonIface
 {
-
   public:
     ButtonIface(sdbusplus::bus::bus& bus, EventPtr& event,
                 buttonConfig& buttonCfg,
@@ -31,8 +30,7 @@
         }
     }
     virtual ~ButtonIface()
-    {
-    }
+    {}
 
     /**
      * @brief This method is called from sd-event provided callback function
@@ -47,7 +45,6 @@
     {
         if (userdata)
         {
-
             ButtonIface* buttonIface = static_cast<ButtonIface*>(userdata);
             buttonIface->handleEvent(es, fd, revents);
         }
@@ -70,7 +67,6 @@
 
     virtual void init()
     {
-
         // initialize the button io fd from the buttonConfig
         // which has fd stored when configGroupGpio is called
         for (auto gpioCfg : config.gpios)
diff --git a/inc/gpio.hpp b/inc/gpio.hpp
index a5b943a..6f0a67b 100644
--- a/inc/gpio.hpp
+++ b/inc/gpio.hpp
@@ -17,6 +17,7 @@
 
 #include <nlohmann/json.hpp>
 #include <sdbusplus/bus.hpp>
+
 #include <string>
 #include <vector>
 
diff --git a/inc/hostSelector_switch.hpp b/inc/hostSelector_switch.hpp
index acdae19..3f62012 100644
--- a/inc/hostSelector_switch.hpp
+++ b/inc/hostSelector_switch.hpp
@@ -8,11 +8,12 @@
 
 #include <unistd.h>
 
-#include <fstream>
-#include <iostream>
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 
+#include <fstream>
+#include <iostream>
+
 static constexpr std::string_view HOST_SELECTOR = "HOST_SELECTOR";
 
 static constexpr auto INVALID_INDEX = std::numeric_limits<size_t>::max();
@@ -23,10 +24,11 @@
     high
 };
 
-class HostSelector final : public sdbusplus::server::object_t<
-                               sdbusplus::xyz::openbmc_project::Chassis::
-                                   Buttons::server::HostSelector>,
-                           public ButtonIface
+class HostSelector final :
+    public sdbusplus::server::object_t<
+        sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::
+            HostSelector>,
+    public ButtonIface
 {
   public:
     HostSelector(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
diff --git a/inc/id_button.hpp b/inc/id_button.hpp
index c58d264..3e9c9e4 100644
--- a/inc/id_button.hpp
+++ b/inc/id_button.hpp
@@ -28,12 +28,11 @@
 
 static constexpr std::string_view ID_BUTTON = "ID_BTN";
 
-class IDButton
-    : public sdbusplus::server::object::object<
-          sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>,
-      public ButtonIface
+class IDButton :
+    public sdbusplus::server::object::object<
+        sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>,
+    public ButtonIface
 {
-
   public:
     IDButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
              buttonConfig& buttonCfg) :
diff --git a/inc/power_button.hpp b/inc/power_button.hpp
index bef2662..9bf8744 100644
--- a/inc/power_button.hpp
+++ b/inc/power_button.hpp
@@ -24,15 +24,16 @@
 
 #include <unistd.h>
 
-#include <chrono>
 #include <phosphor-logging/elog-errors.hpp>
 
+#include <chrono>
+
 static constexpr std::string_view POWER_BUTTON = "POWER_BUTTON";
 
-class PowerButton
-    : public sdbusplus::server::object::object<
-          sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>,
-      public ButtonIface
+class PowerButton :
+    public sdbusplus::server::object::object<
+        sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>,
+    public ButtonIface
 {
   public:
     PowerButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
@@ -47,7 +48,6 @@
 
     ~PowerButton()
     {
-
         deInit();
     }
 
diff --git a/inc/reset_button.hpp b/inc/reset_button.hpp
index 8e15740..3bd7e3f 100644
--- a/inc/reset_button.hpp
+++ b/inc/reset_button.hpp
@@ -28,10 +28,10 @@
 
 static constexpr std::string_view RESET_BUTTON = "RESET_BUTTON";
 
-class ResetButton
-    : public sdbusplus::server::object::object<
-          sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>,
-      public ButtonIface
+class ResetButton :
+    public sdbusplus::server::object::object<
+        sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>,
+    public ButtonIface
 {
   public:
     ResetButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
diff --git a/src/button_handler.cpp b/src/button_handler.cpp
index 55f5db5..a819183 100644
--- a/src/button_handler.cpp
+++ b/src/button_handler.cpp
@@ -196,7 +196,8 @@
 
     switch (powerEventType)
     {
-        case PowerEvent::powerPressed: {
+        case PowerEvent::powerPressed:
+        {
             objPathName = HOST_STATE_OBJECT_NAME + hostNumStr;
             dbusIfaceName = hostIface;
             transitionName = "RequestedHostTransition";
@@ -211,7 +212,8 @@
 
             break;
         }
-        case PowerEvent::longPowerPressed: {
+        case PowerEvent::longPowerPressed:
+        {
             dbusIfaceName = chassisIface;
             transitionName = "RequestedPowerTransition";
             objPathName = CHASSIS_STATE_OBJECT_NAME + hostNumStr;
@@ -244,8 +246,8 @@
             break;
         }
 
-        case PowerEvent::resetPressed: {
-
+        case PowerEvent::resetPressed:
+        {
             objPathName = HOST_STATE_OBJECT_NAME + hostNumStr;
             dbusIfaceName = hostIface;
             transitionName = "RequestedHostTransition";
@@ -260,7 +262,8 @@
             transition = Host::Transition::Reboot;
             break;
         }
-        default: {
+        default:
+        {
             log<level::ERR>(
                 "Invalid power event. skipping...",
                 entry("EVENT=%d", static_cast<int>(powerEventType)));
diff --git a/src/gpio.cpp b/src/gpio.cpp
index bb7f79b..86d4cec 100644
--- a/src/gpio.cpp
+++ b/src/gpio.cpp
@@ -21,12 +21,13 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#include <filesystem>
-#include <fstream>
 #include <gpioplus/utility/aspeed.hpp>
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/log.hpp>
 
+#include <filesystem>
+#include <fstream>
+
 const std::string gpioDev = "/sys/class/gpio";
 
 using namespace phosphor::logging;
@@ -93,7 +94,6 @@
         result = configGpio(gpioCfg);
         if (result < 0)
         {
-
             std::string errorMsg =
                 "Error configuring gpio: GPIO_NUM=" +
                 std::to_string(gpioCfg.number) +
@@ -109,7 +109,6 @@
 
 int configGpio(gpioInfo& gpioConfig)
 {
-
     auto gpioNum = gpioConfig.number;
     auto gpioDirection = gpioConfig.direction;
 
diff --git a/src/main.cpp b/src/main.cpp
index e1efd3e..624c9e7 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -17,9 +17,10 @@
 #include "button_factory.hpp"
 #include "gpio.hpp"
 
-#include <fstream>
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/elog-errors.hpp>
+
+#include <fstream>
 static constexpr auto gpioDefFile = "/etc/default/obmc/gpio/gpio_defs.json";
 
 using namespace phosphor::logging;
diff --git a/src/power_button.cpp b/src/power_button.cpp
index 2e69154..2446d7b 100644
--- a/src/power_button.cpp
+++ b/src/power_button.cpp
@@ -41,7 +41,6 @@
 
 void PowerButton::handleEvent(sd_event_source* es, int fd, uint32_t revents)
 {
-
     int n = -1;
     char buf = '0';