clang-format: copy latest and re-format
clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.
Change-Id: I3a681a9dd632fc31b26bf2df50de0cf4b65f8ec0
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/.clang-format b/.clang-format
index 9109e65..d92a3f1 100644
--- a/.clang-format
+++ b/.clang-format
@@ -5,22 +5,24 @@
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: false
-AlignOperands: true
-AlignTrailingComments: true
+AlignEscapedNewlines: Right
+AlignOperands: Align
+AlignTrailingComments:
+ Kind: Always
+ OverEmptyLines: 1
AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
+AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: None
+AllowShortFunctionsOnASingleLine: Empty
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,29 +31,60 @@
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
+ AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: false
+ SplitEmptyNamespace: false
+BreakAfterAttributes: Never
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
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
+IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: true
-KeepEmptyLinesAtTheStartOfBlocks: true
+InsertNewlineAtEOF: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: OuterScope
+LineEnding: LF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
@@ -59,18 +92,29 @@
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 25
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
+PenaltyIndentedWhitespace: 0
+QualifierAlignment: Left
+ReferenceAlignment: Left
ReflowComments: true
+RequiresClausePosition: OwnLine
+RequiresExpressionIndentation: Keyword
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 +122,7 @@
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
-Standard: Cpp11
+Standard: Latest
TabWidth: 4
UseTab: Never
...
diff --git a/example/pulse.cpp b/example/pulse.cpp
index 15101bb..23eee2c 100644
--- a/example/pulse.cpp
+++ b/example/pulse.cpp
@@ -1,6 +1,7 @@
-#include <exception>
#include <gpioplus/chip.hpp>
#include <gpioplus/handle.hpp>
+
+#include <exception>
#include <string>
int main(int argc, char* argv[])
diff --git a/src/gpioplus/chip.cpp b/src/gpioplus/chip.cpp
index 051ef57..da4910c 100644
--- a/src/gpioplus/chip.cpp
+++ b/src/gpioplus/chip.cpp
@@ -1,7 +1,9 @@
-#include <cstring>
#include <fcntl.h>
-#include <gpioplus/chip.hpp>
#include <linux/gpio.h>
+
+#include <gpioplus/chip.hpp>
+
+#include <cstring>
#include <string>
#include <system_error>
@@ -13,14 +15,12 @@
active_low(flags & GPIOLINE_FLAG_ACTIVE_LOW),
open_drain(flags & GPIOLINE_FLAG_OPEN_DRAIN),
open_source(flags & GPIOLINE_FLAG_OPEN_SOURCE)
-{
-}
+{}
Chip::Chip(unsigned id, const internal::Sys* sys) :
fd(std::string{"/dev/gpiochip"}.append(std::to_string(id)).c_str(),
O_RDONLY | O_CLOEXEC, sys)
-{
-}
+{}
ChipInfo Chip::getChipInfo() const
{
diff --git a/src/gpioplus/chip.hpp b/src/gpioplus/chip.hpp
index 7e8f9d7..b8cbce7 100644
--- a/src/gpioplus/chip.hpp
+++ b/src/gpioplus/chip.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <cstdint>
#include <gpioplus/internal/fd.hpp>
#include <gpioplus/internal/sys.hpp>
+
+#include <cstdint>
#include <string>
namespace gpioplus
diff --git a/src/gpioplus/event.cpp b/src/gpioplus/event.cpp
index 58708fc..1859fae 100644
--- a/src/gpioplus/event.cpp
+++ b/src/gpioplus/event.cpp
@@ -1,6 +1,8 @@
-#include <cstring>
-#include <gpioplus/event.hpp>
#include <linux/gpio.h>
+
+#include <gpioplus/event.hpp>
+
+#include <cstring>
#include <optional>
#include <stdexcept>
#include <system_error>
@@ -52,8 +54,7 @@
EventFlags event_flags, std::string_view consumer_label) :
fd(build(chip, line_offset, handle_flags, event_flags, consumer_label),
std::false_type(), chip.getFd().getSys())
-{
-}
+{}
const internal::Fd& Event::getFd() const
{
diff --git a/src/gpioplus/event.hpp b/src/gpioplus/event.hpp
index 0bfe19c..e36fdeb 100644
--- a/src/gpioplus/event.hpp
+++ b/src/gpioplus/event.hpp
@@ -1,9 +1,10 @@
#pragma once
-#include <chrono>
-#include <cstdint>
#include <gpioplus/chip.hpp>
#include <gpioplus/handle.hpp>
#include <gpioplus/internal/fd.hpp>
+
+#include <chrono>
+#include <cstdint>
#include <optional>
#include <ratio>
#include <string_view>
diff --git a/src/gpioplus/handle.cpp b/src/gpioplus/handle.cpp
index a001ed4..33af777 100644
--- a/src/gpioplus/handle.cpp
+++ b/src/gpioplus/handle.cpp
@@ -1,6 +1,8 @@
-#include <cstring>
-#include <gpioplus/handle.hpp>
#include <linux/gpio.h>
+
+#include <gpioplus/handle.hpp>
+
+#include <cstring>
#include <stdexcept>
#include <system_error>
#include <type_traits>
@@ -11,8 +13,7 @@
HandleFlags::HandleFlags(LineFlags line_flags) :
output(line_flags.output), active_low(line_flags.active_low),
open_drain(line_flags.open_drain), open_source(line_flags.open_source)
-{
-}
+{}
uint32_t HandleFlags::toInt() const
{
@@ -78,8 +79,7 @@
fd(build(chip, lines, flags, consumer_label), std::false_type(),
chip.getFd().getSys()),
nlines(lines.size())
-{
-}
+{}
const internal::Fd& Handle::getFd() const
{
diff --git a/src/gpioplus/handle.hpp b/src/gpioplus/handle.hpp
index 96f8d28..58500fd 100644
--- a/src/gpioplus/handle.hpp
+++ b/src/gpioplus/handle.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <cstdint>
#include <gpioplus/chip.hpp>
#include <gpioplus/internal/fd.hpp>
+
+#include <cstdint>
#include <string_view>
#include <vector>
diff --git a/src/gpioplus/internal/fd.cpp b/src/gpioplus/internal/fd.cpp
index 12a2f40..b05726b 100644
--- a/src/gpioplus/internal/fd.cpp
+++ b/src/gpioplus/internal/fd.cpp
@@ -1,7 +1,9 @@
+#include <fcntl.h>
+
+#include <gpioplus/internal/fd.hpp>
+
#include <cerrno>
#include <cstdlib>
-#include <fcntl.h>
-#include <gpioplus/internal/fd.hpp>
#include <system_error>
#include <utility>
@@ -29,13 +31,9 @@
return fd;
}
-Fd::Fd(int fd, const Sys* sys) : sys(sys), fd(dup(fd, sys))
-{
-}
+Fd::Fd(int fd, const Sys* sys) : sys(sys), fd(dup(fd, sys)) {}
-Fd::Fd(int fd, std::false_type, const Sys* sys) : sys(sys), fd(fd)
-{
-}
+Fd::Fd(int fd, std::false_type, const Sys* sys) : sys(sys), fd(fd) {}
Fd::~Fd()
{
@@ -49,9 +47,7 @@
}
}
-Fd::Fd(const Fd& other) : sys(other.sys), fd(dup(other.fd, sys))
-{
-}
+Fd::Fd(const Fd& other) : sys(other.sys), fd(dup(other.fd, sys)) {}
Fd& Fd::operator=(const Fd& other)
{
diff --git a/src/gpioplus/internal/fd.hpp b/src/gpioplus/internal/fd.hpp
index b111c3e..2beb250 100644
--- a/src/gpioplus/internal/fd.hpp
+++ b/src/gpioplus/internal/fd.hpp
@@ -1,5 +1,6 @@
#pragma once
#include <gpioplus/internal/sys.hpp>
+
#include <type_traits>
namespace gpioplus
diff --git a/src/gpioplus/internal/sys.cpp b/src/gpioplus/internal/sys.cpp
index 1035072..21d945c 100644
--- a/src/gpioplus/internal/sys.cpp
+++ b/src/gpioplus/internal/sys.cpp
@@ -1,9 +1,10 @@
#include <fcntl.h>
-#include <gpioplus/internal/sys.hpp>
#include <linux/gpio.h>
#include <sys/ioctl.h>
#include <unistd.h>
+#include <gpioplus/internal/sys.hpp>
+
namespace gpioplus
{
namespace internal
diff --git a/src/gpioplus/internal/sys.hpp b/src/gpioplus/internal/sys.hpp
index 618259a..6965dd2 100644
--- a/src/gpioplus/internal/sys.hpp
+++ b/src/gpioplus/internal/sys.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <cstddef>
#include <linux/gpio.h>
+#include <cstddef>
+
namespace gpioplus
{
namespace internal
diff --git a/src/gpioplus/test/event.hpp b/src/gpioplus/test/event.hpp
index 64c3613..b4f1250 100644
--- a/src/gpioplus/test/event.hpp
+++ b/src/gpioplus/test/event.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <gmock/gmock.h>
#include <gpioplus/event.hpp>
+#include <gmock/gmock.h>
+
namespace gpioplus
{
namespace test
diff --git a/src/gpioplus/test/handle.hpp b/src/gpioplus/test/handle.hpp
index b629e84..6e3253d 100644
--- a/src/gpioplus/test/handle.hpp
+++ b/src/gpioplus/test/handle.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <gmock/gmock.h>
#include <gpioplus/handle.hpp>
+#include <gmock/gmock.h>
+
namespace gpioplus
{
namespace test
diff --git a/src/gpioplus/test/sys.hpp b/src/gpioplus/test/sys.hpp
index c794218..752599a 100644
--- a/src/gpioplus/test/sys.hpp
+++ b/src/gpioplus/test/sys.hpp
@@ -1,7 +1,8 @@
#pragma once
-#include <gmock/gmock.h>
#include <gpioplus/internal/sys.hpp>
+#include <gmock/gmock.h>
+
namespace gpioplus
{
namespace test
diff --git a/test/chip.cpp b/test/chip.cpp
index aa3979f..cf1f76d 100644
--- a/test/chip.cpp
+++ b/test/chip.cpp
@@ -1,15 +1,18 @@
+#include <fcntl.h>
+#include <linux/gpio.h>
+
+#include <gpioplus/chip.hpp>
+#include <gpioplus/test/sys.hpp>
+
#include <cerrno>
#include <cstdint>
#include <cstring>
-#include <fcntl.h>
-#include <gmock/gmock.h>
-#include <gpioplus/chip.hpp>
-#include <gpioplus/test/sys.hpp>
-#include <gtest/gtest.h>
-#include <linux/gpio.h>
#include <memory>
#include <system_error>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
namespace gpioplus
{
namespace
diff --git a/test/event.cpp b/test/event.cpp
index 3676804..f245747 100644
--- a/test/event.cpp
+++ b/test/event.cpp
@@ -1,16 +1,19 @@
-#include <cerrno>
-#include <cstring>
-#include <gmock/gmock.h>
+#include <linux/gpio.h>
+
#include <gpioplus/event.hpp>
#include <gpioplus/test/sys.hpp>
-#include <gtest/gtest.h>
-#include <linux/gpio.h>
+
+#include <cerrno>
+#include <cstring>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string>
#include <system_error>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
namespace gpioplus
{
namespace
diff --git a/test/handle.cpp b/test/handle.cpp
index 6370c30..3b24312 100644
--- a/test/handle.cpp
+++ b/test/handle.cpp
@@ -1,16 +1,19 @@
-#include <cerrno>
-#include <cstdint>
-#include <gmock/gmock.h>
+#include <linux/gpio.h>
+
#include <gpioplus/handle.hpp>
#include <gpioplus/test/sys.hpp>
-#include <gtest/gtest.h>
-#include <linux/gpio.h>
+
+#include <cerrno>
+#include <cstdint>
#include <memory>
#include <stdexcept>
#include <string>
#include <system_error>
#include <vector>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
namespace gpioplus
{
namespace
diff --git a/test/internal/fd.cpp b/test/internal/fd.cpp
index 852c5c6..a909a99 100644
--- a/test/internal/fd.cpp
+++ b/test/internal/fd.cpp
@@ -1,17 +1,20 @@
-#include <cerrno>
-#include <cstring>
#include <fcntl.h>
-#include <gmock/gmock.h>
-#include <gpioplus/internal/fd.hpp>
-#include <gpioplus/test/sys.hpp>
-#include <gtest/gtest.h>
-#include <memory>
#include <signal.h>
#include <sys/prctl.h>
+
+#include <gpioplus/internal/fd.hpp>
+#include <gpioplus/test/sys.hpp>
+
+#include <cerrno>
+#include <cstring>
+#include <memory>
#include <system_error>
#include <type_traits>
#include <utility>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
#ifdef HAVE_GCOV
// Needed for the abrt test
extern "C" void __gcov_flush(void);
diff --git a/test/utility/aspeed.cpp b/test/utility/aspeed.cpp
index 90580b5..562ea69 100644
--- a/test/utility/aspeed.cpp
+++ b/test/utility/aspeed.cpp
@@ -1,4 +1,5 @@
#include <gpioplus/utility/aspeed.hpp>
+
#include <gtest/gtest.h>
namespace gpioplus