[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Clang-format configuration discussion - pt 1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 8 Nov 2023 09:53:03 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=q6L/YZDPsesgrtyMIjEaDcBjHfqdbJpYJM3pXf9oqyg=; b=im0iXovahqbVeWN7K8KDgjZbRej4h+bhd5aE2xbVwgin8eRBvb/3EjKajaHx9iKKdE551M86Eqr2fm4KSuChdX48db99qoWnrbakP3RsrAv0q/ZMMaI5pStusgr7lIqA7z/75dA8sGiCt4crC4qHXZrdz1g4nrsD0lKsFsXGmDX4BDHI0CpM2sUqHnI1ryI3hV7J5kpCMKS2i6NAIh3MgfKEHl+j5g7d586JOetkiNQ+6YDCkE8FzxFp8xMo3o95sfxWZ0UlsDYTP7yPIcuiRNM75EAWlY7IpAlm7brjw0pRzmHlqiVkBJlgJdEHUWdpC9lEXPRaYqCkxVk+j16qeg==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=q6L/YZDPsesgrtyMIjEaDcBjHfqdbJpYJM3pXf9oqyg=; b=U7fAm4jsu20QPN3XOtiZtVduEQh5ZMFCl6UNq+zBIAz1UrKDEkGWViIl9kQTjVPpl01XzfwDSIxv7Lf4CEQpM40I4/X4xSRYlXQ/X3H1X1kWWxrACEdLaSnVE1sKG7mVihlfDE2Z/ksMjIuYOq5U/nFE/qRmJX0aCORCzehyDT6EDXEZi2UbHR96G9UzjJMOVhLFG9zfHYr6fdo8ReTEXia6xLJAxsKOGoj3v+/FBbTLPC49Lj9qlq7hU0dFEEfoaZbMm5dw0pg43RR0b/Elg/C8zm6afdZXkLsNvcewTeIgfIVNDXbFTgML8PirdM+b/itOviu2ddgFUpkZZJnCuw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=I1ORuAi2FcoLMXm5Pxv70KIpmFzDUyiyp1MZxNQ4LrE0aRThEkuvdnNmbfwpq9ofMQEa6fVv38jmOyJDmG5K4zLZ1G7ZmgfXZYOnMdXcAucYm8L6dAhLIG95Fxaq7NkAz8uEdYANgGNd0my2p9pfrDvIsXcFuep+rC77OV69hFZXwjNCoQb02M31k/KNgk3bof56xNIytZ3g9A+j+dBXhYek7ECMap5p8ACP3SlsT/i3EiBTILB0KR/pbcCQCAW2rDFlWLxH9XJ7WoN7Oa/1/TnWp6O18WV4J6hyGFSdlau9D2GHD58JRWKP7zRWSX0u5J37l5gWjSNRUqvMhFxlDw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gEUojyTXX/46dVU3jFHIXtE1nHpMj+Tsk5syMUFCD6aCzv/dm8trSM6XsCMwIUG+BHogcng0b+TkE1KB+KUfPKkTvjdzOHPYJFzV76Ebkmo0uhw5hICvz4sDtmbM/BGllQF5gZSlHFev/03ADE4pLDTPpimtSXxAr9/GpHSHAhbocLPiUAx5yIWFNR5rHJQ8xftcWcmkFjlDLRrwIANQKiyJgY1F7e7Pl+eIwrATRYiBo52Xt7L7ltjhReElcg7JXFYUHJC1NZG8QAKWPaXBxp8TR7nm8Q+5P2QrXRkVxqUyeAR9a/4hjMXfmp5avRkjYbOOHFbJs1Zoz9KfGWy5oA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <Michal.Orzel@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 08 Nov 2023 09:54:22 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHaEildkKeYHk+uAUifn4n5p7dg+w==
  • Thread-topic: Clang-format configuration discussion - pt 1

Hi all,

Let’s kick off the discussion about clang-format configuration, with this part 
1 I would like to discuss some configurable
that I feel are not controversial.

You can find the serie introducing clang-format here:
https://patchwork.kernel.org/project/xen-devel/cover/20231031132304.2573924-1-luca.fancellu@xxxxxxx/
and there is also a patch linked to my gitlab account where you can find the 
output for the hypervisor code.

For a full list of configurables and to find the possible values for them, 
please refer to this page:
https://clang.llvm.org/docs/ClangFormatStyleOptions.html

--------------------------------------------------------------------------------------------------------------------------------------------------------------

ColumnLimit: 80

IndentWidth: 4

TabWidth: 4

UseTab: Never

---
Our coding style states it explicitly:
[...]
Indenting uses spaces, not tabs - in contrast to Linux. An indent
level consists of four spaces. Code within blocks is indented by one
extra indent level.
[...]

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Language: Cpp

---
As the clang-format documentation says: Should be used for C, C++.

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Standard: C++03

---
From the documentation: Parse and format C++ constructs compatible with this 
standard.

This value is used also in Linux.

--------------------------------------------------------------------------------------------------------------------------------------------------------------

AttributeMacros:
  - '__init'
  - '__exit'
  - '__initdata'
  - '__initconst'
  - '__initconstrel'
  - '__initdata_cf_clobber'
  - '__initconst_cf_clobber'
  - '__hwdom_init'
  - '__hwdom_initdata'
  - '__maybe_unused'
  - '__packed'
  - '__stdcall'
  - '__vfp_aligned'
  - '__alt_call_maybe_initdata'
  - '__cacheline_aligned'
  - '__ro_after_init'
  - 'always_inline'
  - 'noinline'
  - 'noreturn'
  - '__weak'
  - '__inline__'
  - '__attribute_const__'
  - '__transparent__'
  - '__used'
  - '__must_check'
  - '__kprobes'

---
A vector of strings that should be interpreted as attributes/qualifiers instead 
of identifiers.
I’ve tried to list all the attributes I’ve found.

--------------------------------------------------------------------------------------------------------------------------------------------------------------

MacroBlockBegin: '^PLATFORM_START|^DT_DEVICE_START|^ACPI_DEVICE_START'

MacroBlockEnd: '^PLATFORM_END|^DT_DEVICE_END|^ACPI_DEVICE_END’

---
Regular expressions that matches begin and end of a block.
e.g.

PLATFORM_START(rcar2, "Renesas R-Car Gen2")
.compatible = rcar2_dt_compat,
.cpu_up = cpu_up_send_sgi,
.smp_init = rcar2_smp_init,
PLATFORM_END

--------------------------------------------------------------------------------------------------------------------------------------------------------------

StatementMacros:
  - 'PROGRESS'
  - 'PROGRESS_VCPU'
  - 'bitop'
  - 'guest_bitop'
  - 'testop'
  - 'guest_testop'
  - 'DEFINE_XEN_GUEST_HANDLE'
  - '__DEFINE_XEN_GUEST_HANDLE'
  - '___DEFINE_XEN_GUEST_HANDLE'
  - 'presmp_initcall'
  - '__initcall'
  - '__exitcall'

---
A vector of macros that should be interpreted as complete statements.
Typical macros are expressions, and require a semi-colon to be added; sometimes 
this is not the case, and this allows
to make clang-format aware of such cases.

While I was writing this, I’ve found that from ‘DEFINE_XEN_GUEST_HANDLE’ until 
the end of the list, probably I
shouldn’t list these entries because all of them end with semi-colon.

--------------------------------------------------------------------------------------------------------------------------------------------------------------

TypenameMacros:
  - 'XEN_GUEST_HANDLE'
  - 'XEN_GUEST_HANDLE_64'
  - 'XEN_GUEST_HANDLE_PARAM'
  - 'ELF_HANDLE_DECL'

---
A vector of macros that should be interpreted as type declarations instead of 
as function calls.
These are expected to be macros of the form:
STACK_OF(...)

--------------------------------------------------------------------------------------------------------------------------------------------------------------

WhitespaceSensitiveMacros:
  - '__stringify'

---
A vector of macros which are whitespace-sensitive and should not be touched.

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Ok this is it for now, let me know your thoughts about them, ideally if I don’t 
get any reply in two weeks (22nd of November),
I will consider that we have an agreement on these configuration.

Cheers,
Luca




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.