aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2022-09-14 14:09:25 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2022-09-28 11:42:29 +0200
commit9c1349047edb660095eba11ae8444970e97f375d (patch)
tree39bf0222fa4c70e472599bfcb9ec99310fdacd52
parentf8feb285c26ecd87a1141a51e55b0fa345175a1a (diff)
clang-format: codify some of our conventions
1. We tend to use 2 spaces for indenting pre-processor directives, when we do it. Unfortunately clang-format also counts header-guards so not really recommended to use blindly on a header... 2. Add comments to namespaces, since the closing brace is simply a brace with no further decoration. 3. Attach escaped new-lines on the left (instead of current: right). Where 'right' will add the '\' characters on the far-right of our column limit, 'left' will put them as far left as it can while having them vertically aligned. Change-Id: Ib5a836c76f7761d743e0100c83e7db609b959249 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
-rw-r--r--_clang-format17
1 files changed, 17 insertions, 0 deletions
diff --git a/_clang-format b/_clang-format
index 19d2e364..085320ad 100644
--- a/_clang-format
+++ b/_clang-format
@@ -62,6 +62,8 @@ NamespaceIndentation: None
# Allow indentation for preprocessing directives (if/ifdef/endif). https://reviews.llvm.org/rL312125
IndentPPDirectives: AfterHash
+# We only indent with 2 spaces for preprocessor directives
+PPIndentWidth: 2
# Horizontally align arguments after an open bracket.
# The coding style does not specify the following, but this is what gives
@@ -85,6 +87,21 @@ ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCH
# Break constructor initializers before the colon and after the commas.
BreakConstructorInitializers: BeforeColon
+# Add "// namespace <namespace>" comments on closing brace for a namespace
+# Ignored for namespaces that qualify as a short namespace,
+# see 'ShortNamespaceLines'
+FixNamespaceComments: true
+
+# Definition of how short a short namespace is, default 1
+ShortNamespaceLines: 1
+
+# When escaping newlines in a macro attach the '\' as far left as possible, e.g.
+##define a \
+# something; \
+# other; \
+# thelastlineislong;
+AlignEscapedNewlines: Left
+
# Avoids the addition of a space between an identifier and the
# initializer list in list-initialization.
SpaceBeforeCpp11BracedList: false