forked from gem5/gem5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.clang-format
More file actions
114 lines (101 loc) · 5.12 KB
/
.clang-format
File metadata and controls
114 lines (101 loc) · 5.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
# Copyright (c) 2025 Arm Limited
# All rights reserved
#
# The license below extends only to copyright in the software and shall
# not be construed as granting a license to any other intellectual
# property including but not limited to intellectual property relating
# to a hardware implementation of the functionality of the software
# licensed hereunder. You may use the software subject to the license
# terms below provided that you ensure that this notice is replicated
# unmodified and in its entirety in all distributions of the software,
# modified or unmodified, in source code or in binary form.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met: redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer;
# redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution;
# neither the name of the copyright holders nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# `clang-format` configuration Based on LLVM style, overridden for gem5 C++ style.
# Generated by ChatGPT o4-mini-high to match the gem5 Style Guide as closely as possible.
# https://www.gem5.org/documentation/general_docs/development/coding_style
BasedOnStyle: LLVM
IndentWidth: 4 # 4 spaces per indent level (sec. Indentation)
UseTab: Never # No tabs (sec. Indentation)
ColumnLimit: 79 # Max 79 chars per line (sec. Line length)
# Namespace and label indentation
NamespaceIndentation: None # Namespaces do not add indent (sec. Indentation)
IndentCaseLabels: true # Indent labels 2 spaces (sec. Labels)
AccessModifierOffset: -2 # Outdent public/protected/private by 2
# Brace placement rules
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true # Function/object braces on newline (sec. Braces)
AfterClass: true
AfterStruct: true
AfterUnion: true
AfterEnum: true
AfterNamespace: true
AfterControlStatement: false # if/for braces same line (sec. Braces)
BeforeElse: false # else on same line (sec. Braces)
SplitEmptyFunction: false # empty function closing brace on same line
# as openning
# Spacing rules
SpaceBeforeParens: ControlStatements # Space before if/for/while (...)
SpacesInParentheses: false # No ( ... ) (sec. Spacing)
SpaceInEmptyParentheses: false # No f( ) -> f() (sec. Spacing)
SpacesInAngles: false # No < T > in templates
# Single‐line constructs
AllowShortIfStatementsOnASingleLine: false
AllowShortBlocksOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
# Require curly braces after control statements (if, else, for, do, while)
# unless inside macro definitions or if the braces would enclose preprocessor
# directives
InsertBraces: true
# Each constructor initializer in separate line
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# Return‐type / function‐name separation
AlwaysBreakAfterReturnType: None # Do not break after return type
AlwaysBreakAfterDefinitionReturnType: All # Unless it is a definition
# Pointer/reference alignment
DerivePointerAlignment: false
PointerAlignment: Right # Foo *p (sec. Pointers)
# Decoration
AlignConsecutiveDeclarations: false # No aligned declarations
# Include sorting & grouping
SortIncludes: true
IncludeCategories:
- Regex: ^<Python\\.h>$
Priority: 1
- Regex: ^"[^/]+\\.hh"$
Priority: 2
- Regex: ^<.*>$
Priority: 3
- Regex: ^<gem5/.*>$
Priority: 4
- Regex: ^".*\\.hh"$
Priority: 5
# Treat those macro as start and end of block so they are indented correctly.
MacroBlockBegin: ^(BitUnion(8|16|32|64)|(Signed)?SubBitUnion)$
MacroBlockEnd: ^(EndBitUnion|EndSubBitUnion)$