clang-format-12
This commit is contained in:
parent
31253f400d
commit
29cbf8b83f
|
@ -2,16 +2,18 @@
|
|||
Language: Cpp
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveMacros: false
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
|
@ -21,12 +23,14 @@ AlwaysBreakAfterDefinitionReturnType: None
|
|||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: MultiLine
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
|
@ -36,11 +40,14 @@ BraceWrapping:
|
|||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
|
@ -56,27 +63,43 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
|||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^(<|"(gtest|isl|json)/)'
|
||||
Priority: 3
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: AfterHash
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequires: false
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
|
@ -86,6 +109,7 @@ MaxEmptyLinesToKeep: 1
|
|||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
|
@ -96,31 +120,46 @@ PenaltyBreakString: 1000
|
|||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SortIncludes: false
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
...
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Coding style
|
|||
We use clang-format to format source code consistently. The
|
||||
clang-format configuration file .clang-format is located at the root
|
||||
directory. Since clang-format produces slightly different results
|
||||
between versions, we currently use clang-format-10.
|
||||
between versions, we currently use clang-format-12.
|
||||
|
||||
To detect any violation to the coding style, we recommend to setup git
|
||||
pre-commit hook to check coding style of the changes you introduced.
|
||||
|
@ -34,7 +34,7 @@ The pre-commit file is located at the root directory. Copy it under
|
|||
.git/hooks and make sure that it is executable. The pre-commit script
|
||||
uses clang-format-diff.py to detect any style errors. If it is not in
|
||||
your PATH or it exists under different name (e.g.,
|
||||
clang-format-diff-10 in debian), either add it to PATH variable or add
|
||||
clang-format-diff-12 in debian), either add it to PATH variable or add
|
||||
git option ``clangformatdiff.binary`` to point to the script.
|
||||
|
||||
For emacs users, integrating clang-format to emacs is very easy.
|
||||
|
|
|
@ -6430,8 +6430,9 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
|||
|
||||
/* CONTINUATION won't bear NGHTTP2_PADDED flag */
|
||||
|
||||
iframe->frame.hd.flags = (uint8_t)(
|
||||
iframe->frame.hd.flags | (cont_hd.flags & NGHTTP2_FLAG_END_HEADERS));
|
||||
iframe->frame.hd.flags =
|
||||
(uint8_t)(iframe->frame.hd.flags |
|
||||
(cont_hd.flags & NGHTTP2_FLAG_END_HEADERS));
|
||||
iframe->frame.hd.length += cont_hd.length;
|
||||
|
||||
busy = 1;
|
||||
|
|
|
@ -197,7 +197,7 @@ inline size_t concat_string_ref_count(size_t acc) { return acc; }
|
|||
// accumulated, and passed to the next function.
|
||||
template <typename... Args>
|
||||
size_t concat_string_ref_count(size_t acc, const StringRef &value,
|
||||
Args &&... args) {
|
||||
Args &&...args) {
|
||||
return concat_string_ref_count(acc + value.size(),
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ inline uint8_t *concat_string_ref_copy(uint8_t *p) { return p; }
|
|||
// beyond the last byte written.
|
||||
template <typename... Args>
|
||||
uint8_t *concat_string_ref_copy(uint8_t *p, const StringRef &value,
|
||||
Args &&... args) {
|
||||
Args &&...args) {
|
||||
p = std::copy(std::begin(value), std::end(value), p);
|
||||
return concat_string_ref_copy(p, std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ uint8_t *concat_string_ref_copy(uint8_t *p, const StringRef &value,
|
|||
// Returns the string which is the concatenation of |args| in the
|
||||
// given order. The resulting string will be NULL-terminated.
|
||||
template <typename BlockAllocator, typename... Args>
|
||||
StringRef concat_string_ref(BlockAllocator &alloc, Args &&... args) {
|
||||
StringRef concat_string_ref(BlockAllocator &alloc, Args &&...args) {
|
||||
size_t len = concat_string_ref_count(0, std::forward<Args>(args)...);
|
||||
auto dst = static_cast<uint8_t *>(alloc.alloc(len + 1));
|
||||
auto p = dst;
|
||||
|
@ -237,7 +237,7 @@ StringRef concat_string_ref(BlockAllocator &alloc, Args &&... args) {
|
|||
// then just call concat_string_ref().
|
||||
template <typename BlockAllocator, typename... Args>
|
||||
StringRef realloc_concat_string_ref(BlockAllocator &alloc,
|
||||
const StringRef &value, Args &&... args) {
|
||||
const StringRef &value, Args &&...args) {
|
||||
if (value.empty()) {
|
||||
return concat_string_ref(alloc, std::forward<Args>(args)...);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ generator_cb deferred_generator() {
|
|||
}
|
||||
|
||||
template <typename F, typename... T>
|
||||
std::shared_ptr<Defer<F, T...>> defer_shared(F &&f, T &&... t) {
|
||||
std::shared_ptr<Defer<F, T...>> defer_shared(F &&f, T &&...t) {
|
||||
return std::make_shared<Defer<F, T...>>(std::forward<F>(f),
|
||||
std::forward<T>(t)...);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
serve_mux &mux,
|
||||
const boost::posix_time::time_duration &tls_handshake_timeout,
|
||||
const boost::posix_time::time_duration &read_timeout,
|
||||
SocketArgs &&... args)
|
||||
SocketArgs &&...args)
|
||||
: socket_(std::forward<SocketArgs>(args)...),
|
||||
mux_(mux),
|
||||
deadline_(GET_IO_SERVICE(socket_)),
|
||||
|
|
|
@ -198,9 +198,9 @@ StringRef Request::get_real_host() const {
|
|||
|
||||
uint16_t Request::get_real_port() const {
|
||||
auto scheme = get_real_scheme();
|
||||
return config.host_override.empty()
|
||||
? util::has_uri_field(u, UF_PORT) ? u.port
|
||||
: scheme == "https" ? 443 : 80
|
||||
return config.host_override.empty() ? util::has_uri_field(u, UF_PORT) ? u.port
|
||||
: scheme == "https" ? 443
|
||||
: 80
|
||||
: config.port_override == 0 ? scheme == "https" ? 443 : 80
|
||||
: config.port_override;
|
||||
}
|
||||
|
@ -1681,8 +1681,9 @@ void update_html_parser(HttpClient *client, Request *req, const uint8_t *data,
|
|||
continue;
|
||||
}
|
||||
|
||||
auto link_port =
|
||||
util::has_uri_field(u, UF_PORT) ? u.port : scheme == "https" ? 443 : 80;
|
||||
auto link_port = util::has_uri_field(u, UF_PORT) ? u.port
|
||||
: scheme == "https" ? 443
|
||||
: 80;
|
||||
|
||||
if (port != link_port) {
|
||||
continue;
|
||||
|
|
|
@ -1070,8 +1070,7 @@ Http2Upstream::Http2Upstream(ClientHandler *handler)
|
|||
<< nghttp2_strerror(rv);
|
||||
}
|
||||
|
||||
auto window_size =
|
||||
faddr->alt_mode != UpstreamAltMode::NONE
|
||||
auto window_size = faddr->alt_mode != UpstreamAltMode::NONE
|
||||
? std::numeric_limits<int32_t>::max()
|
||||
: http2conf.upstream.optimize_window_size
|
||||
? std::min(http2conf.upstream.connection_window_size,
|
||||
|
|
|
@ -595,12 +595,10 @@ void upstream_accesslog(const std::vector<LogFragment> &lfv,
|
|||
auto downstream_addr = downstream->get_addr();
|
||||
auto method = req.method == -1 ? StringRef::from_lit("<unknown>")
|
||||
: http2::to_method_string(req.method);
|
||||
auto path = req.method == HTTP_CONNECT
|
||||
? req.authority
|
||||
: config->http2_proxy
|
||||
? construct_absolute_request_uri(balloc, req)
|
||||
: req.path.empty() ? req.method == HTTP_OPTIONS
|
||||
? StringRef::from_lit("*")
|
||||
auto path =
|
||||
req.method == HTTP_CONNECT ? req.authority
|
||||
: config->http2_proxy ? construct_absolute_request_uri(balloc, req)
|
||||
: req.path.empty() ? req.method == HTTP_OPTIONS ? StringRef::from_lit("*")
|
||||
: StringRef::from_lit("-")
|
||||
: req.path;
|
||||
auto path_without_query =
|
||||
|
|
|
@ -45,7 +45,7 @@ template <typename... T>
|
|||
constexpr std::array<
|
||||
typename std::decay<typename std::common_type<T...>::type>::type,
|
||||
sizeof...(T)>
|
||||
make_array(T &&... t) {
|
||||
make_array(T &&...t) {
|
||||
return std::array<
|
||||
typename std::decay<typename std::common_type<T...>::type>::type,
|
||||
sizeof...(T)>{{std::forward<T>(t)...}};
|
||||
|
@ -62,7 +62,7 @@ template <typename T, size_t N> constexpr size_t str_size(T (&)[N]) {
|
|||
// inspired by <http://blog.korfuri.fr/post/go-defer-in-cpp/>, but our
|
||||
// template can take functions returning other than void.
|
||||
template <typename F, typename... T> struct Defer {
|
||||
Defer(F &&f, T &&... t)
|
||||
Defer(F &&f, T &&...t)
|
||||
: f(std::bind(std::forward<F>(f), std::forward<T>(t)...)) {}
|
||||
Defer(Defer &&o) noexcept : f(std::move(o.f)) {}
|
||||
~Defer() { f(); }
|
||||
|
@ -72,7 +72,7 @@ template <typename F, typename... T> struct Defer {
|
|||
std::function<ResultType()> f;
|
||||
};
|
||||
|
||||
template <typename F, typename... T> Defer<F, T...> defer(F &&f, T &&... t) {
|
||||
template <typename F, typename... T> Defer<F, T...> defer(F &&f, T &&...t) {
|
||||
return Defer<F, T...>(std::forward<F>(f), std::forward<T>(t)...);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue