clang-format: update to latest from docs repo
Since `Cpp11` is an alias for `Latest` and we should tend towards using the
latest C++ standard, update the C++ standard to Latest.
https://github.com/llvm/llvm-project/commit/e5032567903de19962333c4bf7d2edceaf4f9824#diff-b49a097415dff2837d9626d422c58ba8R82
https://github.com/openbmc/docs/blob/master/style/cpp/.clang-format
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Id5684236b64867ba631a3a00dadababe2c36db16
diff --git a/.clang-format b/.clang-format
index ea71ad6..625a0a0 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: true
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/controller.cpp b/controller.cpp
index 8b9a22d..685a4fc 100644
--- a/controller.cpp
+++ b/controller.cpp
@@ -20,8 +20,9 @@
#include "physical.hpp"
#include "sysfs.hpp"
-#include <algorithm>
#include <boost/algorithm/string.hpp>
+
+#include <algorithm>
#include <iostream>
#include <string>
diff --git a/physical.hpp b/physical.hpp
index 9be62fe..383c98a 100644
--- a/physical.hpp
+++ b/physical.hpp
@@ -2,12 +2,13 @@
#include "sysfs.hpp"
-#include <fstream>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
-#include <string>
#include <xyz/openbmc_project/Led/Physical/server.hpp>
+#include <fstream>
+#include <string>
+
namespace phosphor
{
namespace led
@@ -18,8 +19,9 @@
/** @class Physical
* @brief Responsible for applying actions on a particular physical LED
*/
-class Physical : public sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Led::server::Physical>
+class Physical :
+ public sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Led::server::Physical>
{
public:
Physical() = delete;
diff --git a/sysfs.hpp b/sysfs.hpp
index 290c97f..a8de9bd 100644
--- a/sysfs.hpp
+++ b/sysfs.hpp
@@ -25,8 +25,7 @@
{
public:
SysfsLed(std::experimental::filesystem::path&& root) : root(std::move(root))
- {
- }
+ {}
SysfsLed() = delete;
SysfsLed(const SysfsLed& other) = delete;
diff --git a/test/physical.cpp b/test/physical.cpp
index f05d882..10dc9b7 100644
--- a/test/physical.cpp
+++ b/test/physical.cpp
@@ -46,8 +46,7 @@
public:
/* Use a no-args ctor here to avoid headaches with {Nice,Strict}Mock */
MockLed() : SysfsLed(create_sandbox())
- {
- }
+ {}
virtual ~MockLed()
{