Skip to content

Commit ced16af

Browse files
Model setup (#2)
* [sim] Initial simulator prototype * [sim] Initial code generation provided * [codegen] Missed array include * [cmake] Simplify codegen * [infra] Formatter, warnings, etc... * Fix warning * Rename workflow * [infra] Update clang-format * [infra] Use clang-format 18 * [infra] Add clang-tidy check * Fix warnings + some redesign * [ci] Use clang tidy as specific stage * Simplify --------- Co-authored-by: Andrey Derzhavin <derzhavin.andrej@yandex.ru>
1 parent b47b43a commit ced16af

19 files changed

Lines changed: 733 additions & 52 deletions

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
22
BasedOnStyle: LLVM
33
IndentWidth: 4
4+
InsertNewlineAtEOF: true
5+
KeepEmptyLinesAtEOF: false
46
---

.clang-tidy

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,36 @@
11
---
22
Checks: >
3-
*,
4-
clang-diagnostic-*,
5-
clang-analyzer-*,
6-
-llvmlibc-*,
3+
-*,
4+
bugprone-*
5+
misc-*,
6+
modernize-*,
7+
performance-*,
8+
portability-*,
9+
readability-*,
10+
-fuchsia-trailing-return,
11+
-readability-magic-numbers,
12+
-modernize-use-nodiscard,
713
-modernize-use-trailing-return-type,
8-
-fuchsia-default-arguments-calls,
9-
-google-readability-braces-around-statements,
10-
-hicpp-braces-around-statements,
11-
-altera-unroll-loops,
12-
-altera-struct-pack-align,
13-
-altera-id-dependent-backward-branch,
14-
-cppcoreguidelines-pro-type-vararg,
15-
-hicpp-vararg,
16-
-fuchsia-multiple-inheritance,
14+
-readability-braces-around-statements,
15+
-readability-redundant-access-specifiers,
16+
-readability-redundant-member-init,
17+
-readability-redundant-string-init,
1718
-readability-identifier-length
18-
19-
2019
CheckOptions:
21-
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
22-
value: true
20+
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
21+
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
22+
- { key: readability-identifier-naming.StructCase, value: CamelCase }
23+
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
24+
- { key: readability-identifier-naming.VariableCase, value: camelBack }
25+
- { key: readability-identifier-naming.PrivateMemberCase, value: camelBack }
26+
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ }
27+
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
28+
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
29+
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
30+
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
31+
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }
32+
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
33+
- { key: readability-identifier-naming.MacroDefinitionPrefix, value: HSIM_ }
34+
- { key: readability-identifier-naming.TypeAliasCase, value: CamelCase }
35+
- { key: readability-identifier-naming.TypedefCase, value: CamelCase }
36+
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }

.clangd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ CompileFlags:
55

66
Diagnostics:
77
UnusedIncludes: Strict
8-
Includes:
9-
MissingIncludes: Strict
8+
MissingIncludes: Strict
109

1110
Hover:
1211
ShowAKA: Yes

.cmake-format.py

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
# ----------------------------------
2+
# Options affecting listfile parsing
3+
# ----------------------------------
4+
with section("parse"):
5+
6+
# Specify structure for custom cmake functions
7+
additional_commands = {
8+
'cpmaddpackage': {
9+
'pargs': {
10+
'nargs': '*',
11+
'flags': []
12+
},
13+
'spelling': 'CPMAddPackage',
14+
'kwargs': {
15+
'NAME': 1,
16+
'FORCE': 1,
17+
'VERSION': 1,
18+
'GIT_TAG': 1,
19+
'DOWNLOAD_ONLY': 1,
20+
'GITHUB_REPOSITORY': 1,
21+
'GITLAB_REPOSITORY': 1,
22+
'GIT_REPOSITORY': 1,
23+
'SVN_REPOSITORY': 1,
24+
'SVN_REVISION': 1,
25+
'SOURCE_DIR': 1,
26+
'DOWNLOAD_COMMAND': 1,
27+
'FIND_PACKAGE_ARGUMENTS': 1,
28+
'NO_CACHE': 1,
29+
'GIT_SHALLOW': 1,
30+
'URL': 1,
31+
'URL_HASH': 1,
32+
'URL_MD5': 1,
33+
'DOWNLOAD_NAME': 1,
34+
'DOWNLOAD_NO_EXTRACT': 1,
35+
'HTTP_USERNAME': 1,
36+
'HTTP_PASSWORD': 1,
37+
'EXCLUDE_FROM_ALL': 1,
38+
'SYSTEM': 1,
39+
'SOURCE_SUBDIR': 1,
40+
'PATCHES': '+',
41+
'OPTIONS': '+',
42+
}
43+
}
44+
}
45+
# Override configurations per-command where available
46+
override_spec = {}
47+
48+
# Specify variable tags.
49+
vartags = []
50+
51+
# Specify property tags.
52+
proptags = []
53+
54+
# -----------------------------
55+
# Options affecting formatting.
56+
# -----------------------------
57+
with section("format"):
58+
59+
# Disable formatting entirely, making cmake-format a no-op
60+
disable = False
61+
62+
# How wide to allow formatted cmake files
63+
line_width = 80
64+
65+
# How many spaces to tab for indent
66+
tab_size = 2
67+
68+
# If true, lines are indented using tab characters (utf-8 0x09) instead of
69+
# <tab_size> space characters (utf-8 0x20). In cases where the layout would
70+
# require a fractional tab character, the behavior of the fractional
71+
# indentation is governed by <fractional_tab_policy>
72+
use_tabchars = False
73+
74+
# If <use_tabchars> is True, then the value of this variable indicates how
75+
# fractional indentions are handled during whitespace replacement. If set to
76+
# 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
77+
# to `round-up` fractional indentation is replaced with a single tab character
78+
# (utf-8 0x09) effectively shifting the column to the next tabstop
79+
fractional_tab_policy = 'use-space'
80+
81+
# If an argument group contains more than this many sub-groups (parg or kwarg
82+
# groups) then force it to a vertical layout.
83+
max_subgroups_hwrap = 2
84+
85+
# If a positional argument group contains more than this many arguments, then
86+
# force it to a vertical layout.
87+
max_pargs_hwrap = 6
88+
89+
# If a cmdline positional group consumes more than this many lines without
90+
# nesting, then invalidate the layout (and nest)
91+
max_rows_cmdline = 2
92+
93+
# If true, separate flow control names from their parentheses with a space
94+
separate_ctrl_name_with_space = False
95+
96+
# If true, separate function names from parentheses with a space
97+
separate_fn_name_with_space = False
98+
99+
# If a statement is wrapped to more than one line, than dangle the closing
100+
# parenthesis on its own line.
101+
dangle_parens = False
102+
103+
# If the trailing parenthesis must be 'dangled' on its on line, then align it
104+
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
105+
# the start of the statement, plus one indentation level, `child`: align to
106+
# the column of the arguments
107+
dangle_align = 'prefix'
108+
109+
# If the statement spelling length (including space and parenthesis) is
110+
# smaller than this amount, then force reject nested layouts.
111+
min_prefix_chars = 4
112+
113+
# If the statement spelling length (including space and parenthesis) is larger
114+
# than the tab width by more than this amount, then force reject un-nested
115+
# layouts.
116+
max_prefix_chars = 10
117+
118+
# If a candidate layout is wrapped horizontally but it exceeds this many
119+
# lines, then reject the layout.
120+
max_lines_hwrap = 2
121+
122+
# What style line endings to use in the output.
123+
line_ending = 'unix'
124+
125+
# Format command names consistently as 'lower' or 'upper' case
126+
command_case = 'canonical'
127+
128+
# Format keywords consistently as 'lower' or 'upper' case
129+
keyword_case = 'unchanged'
130+
131+
# A list of command names which should always be wrapped
132+
always_wrap = []
133+
134+
# If true, the argument lists which are known to be sortable will be sorted
135+
# lexicographicall
136+
enable_sort = False
137+
138+
# If true, the parsers may infer whether or not an argument list is sortable
139+
# (without annotation).
140+
autosort = False
141+
142+
# By default, if cmake-format cannot successfully fit everything into the
143+
# desired linewidth it will apply the last, most aggressive attempt that it
144+
# made. If this flag is True, however, cmake-format will print error, exit
145+
# with non-zero status code, and write-out nothing
146+
require_valid_layout = False
147+
148+
# A dictionary mapping layout nodes to a list of wrap decisions. See the
149+
# documentation for more information.
150+
layout_passes = {}
151+
152+
# ------------------------------------------------
153+
# Options affecting comment reflow and formatting.
154+
# ------------------------------------------------
155+
with section("markup"):
156+
157+
# What character to use for bulleted lists
158+
bullet_char = '*'
159+
160+
# What character to use as punctuation after numerals in an enumerated list
161+
enum_char = '.'
162+
163+
# If comment markup is enabled, don't reflow the first comment block in each
164+
# listfile. Use this to preserve formatting of your copyright/license
165+
# statements.
166+
first_comment_is_literal = False
167+
168+
# If comment markup is enabled, don't reflow any comment block which matches
169+
# this (regex) pattern. Default is `None` (disabled).
170+
literal_comment_pattern = None
171+
172+
# Regular expression to match preformat fences in comments default=
173+
# ``r'^\s*([`~]{3}[`~]*)(.*)$'``
174+
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
175+
176+
# Regular expression to match rulers in comments default=
177+
# ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
178+
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
179+
180+
# If a comment line matches starts with this pattern then it is explicitly a
181+
# trailing comment for the preceding argument. Default is '#<'
182+
explicit_trailing_pattern = '#<'
183+
184+
# If a comment line starts with at least this many consecutive hash
185+
# characters, then don't lstrip() them off. This allows for lazy hash rulers
186+
# where the first hash char is not separated by space
187+
hashruler_min_length = 10
188+
189+
# If true, then insert a space between the first hash char and remaining hash
190+
# chars in a hash ruler, and normalize its length to fill the column
191+
canonicalize_hashrulers = True
192+
193+
# enable comment markup parsing and reflow
194+
enable_markup = True
195+
196+
# ----------------------------
197+
# Options affecting the linter
198+
# ----------------------------
199+
with section("lint"):
200+
201+
# a list of lint codes to disable
202+
disabled_codes = []
203+
204+
# regular expression pattern describing valid function names
205+
function_pattern = '[0-9a-z_]+'
206+
207+
# regular expression pattern describing valid macro names
208+
macro_pattern = '[0-9A-Z_]+'
209+
210+
# regular expression pattern describing valid names for variables with global
211+
# (cache) scope
212+
global_var_pattern = '[A-Z][0-9A-Z_]+'
213+
214+
# regular expression pattern describing valid names for variables with global
215+
# scope (but internal semantic)
216+
internal_var_pattern = '_[A-Z][0-9A-Z_]+'
217+
218+
# regular expression pattern describing valid names for variables with local
219+
# scope
220+
local_var_pattern = '[a-z][a-z0-9_]+'
221+
222+
# regular expression pattern describing valid names for privatedirectory
223+
# variables
224+
private_var_pattern = '_[0-9a-z_]+'
225+
226+
# regular expression pattern describing valid names for public directory
227+
# variables
228+
public_var_pattern = '[A-Z][0-9A-Z_]+'
229+
230+
# regular expression pattern describing valid names for function/macro
231+
# arguments and loop variables.
232+
argument_var_pattern = '[a-z][a-z0-9_]+'
233+
234+
# regular expression pattern describing valid names for keywords used in
235+
# functions or macros
236+
keyword_pattern = '[A-Z][0-9A-Z_]+'
237+
238+
# In the heuristic for C0201, how many conditionals to match within a loop in
239+
# before considering the loop a parser.
240+
max_conditionals_custom_parser = 2
241+
242+
# Require at least this many newlines between statements
243+
min_statement_spacing = 1
244+
245+
# Require no more than this many newlines between statements
246+
max_statement_spacing = 2
247+
max_returns = 6
248+
max_branches = 12
249+
max_arguments = 5
250+
max_localvars = 15
251+
max_statements = 50
252+
253+
# -------------------------------
254+
# Options affecting file encoding
255+
# -------------------------------
256+
with section("encode"):
257+
258+
# If true, emit the unicode byte-order mark (BOM) at the start of the file
259+
emit_byteorder_mark = False
260+
261+
# Specify the encoding of the input file. Defaults to utf-8
262+
input_encoding = 'utf-8'
263+
264+
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
265+
# only claims to support utf-8 so be careful when using anything else
266+
output_encoding = 'utf-8'
267+
268+
# -------------------------------------
269+
# Miscellaneous configurations options.
270+
# -------------------------------------
271+
with section("misc"):
272+
273+
# A dictionary containing any per-command configuration overrides. Currently
274+
# only `command_case` is supported.
275+
per_command = {}

0 commit comments

Comments
 (0)