"git@developer.sourcefind.cn:gaoqiong/composable_kernel.git" did not exist on "959ddcf895c98f6948e62d33859d0aebed14f533"
Commit e888d686 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

Makefile: add clang-format and clang-tidy lint support

These are slower and currently yield a lot of warnings to be fixed.
parent cea1670e
---
BasedOnStyle: Google
SortIncludes: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
DerivePointerAlignment: true
PointerAlignment: Left
ColumnLimit: 80
ForEachMacros: ['list_for_every_entry','list_for_every_entry_safe']
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<simbricks/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
---
Checks: >
-*,
bugprone-*,
clang-diagnostic-*,
-clang-diagnostic-unused-command-line-argument,
google-*,
-google-runtime-references,
misc-*,
-misc-noexcept*,
-misc-unused-parameters,
-misc-non-private-member-variables-in-classes,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-raw-string-literal,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-equals-delete,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
performance-*,
readability-*,
-readability-function-cognitive-complexity,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-qualified-auto,
-readability-uppercase-literal-suffix,
WarningsAsErrors: false
AnalyzeTemporaryDtors: false
FormatStyle: file
CheckOptions:
- key: bugprone-assert-side-effect.AssertMacros
value: 'FXL_DCHECK'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '2'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-default-member-init.UseAssignment
value: '1'
- key: modernize-use-emplace.IgnoreImplicitConstructors
value: '1'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: readability-braces-around-statements.ShortStatementLines
value: '2'
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.TemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: aNy_CasE
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.ClassMemberCase
value: lower_case
- key: readability-identifier-naming.ClassMemberSuffix
value: _
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.EnumConstantCase
value: CamelCase
- key: readability-identifier-naming.EnumConstantPrefix
value: k
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.GlobalConstantCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantPrefix
value: k
- key: readability-identifier-naming.MemberConstantCase
value: CamelCase
- key: readability-identifier-naming.MemberConstantPrefix
value: k
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantPrefix
value: k
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: 1
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: 1
...
#!/bin/bash
IGNORES="sims/nic/i40e_bm/base/*.h /usr/share/verilator/include/*.h"
# This is an ugly hack to exclude individual headers, until clang-tidy has a
# proper mechanism for this (e.g. https://reviews.llvm.org/D34654)
lf="["
for f in $IGNORES
do
lf="$lf{\"name\":\"$f\",\"lines\":[[9999999,9999999]]},"
done
lf="$lf{\"name\":\".c\"},{\"name\":\".cc\"},{\"name\":\".h\"}]"
tidy=$1
shift
files=
for f in `cat .lint-files`
do
[ ! -f $f ] && continue
[ ${f: -2} == ".h" ] && continue
files="$files $f"
done
$tidy --quiet --format-style=file --header-filter='.*' --line-filter="$lf" \
$files -- "$@"
sims/net/*/*.c
sims/net/*/*.cc
sims/nic/corundum/*.cc
sims/nic/corundum/*.h
sims/nic/corundum_bm/*.cc
sims/nic/corundum_bm/*.c
sims/nic/corundum_bm/*.h
sims/nic/i40e_bm/*.cc
sims/nic/i40e_bm/*.h
lib/simbricks/*/*.c
lib/simbricks/*/*.cc
lib/simbricks/*/*.h
trace/*.cc
trace/*.h
...@@ -26,7 +26,9 @@ include mk/recipes.mk ...@@ -26,7 +26,9 @@ include mk/recipes.mk
base_dir := $(d)./ base_dir := $(d)./
CPPLINT = cpplint CPPLINT ?= cpplint
CLANG_TIDY ?= clang-tidy
CLANG_FORMAT ?= clang-format
CFLAGS += -Wall -Wextra -Wno-unused-parameter -O3 -fPIC CFLAGS += -Wall -Wextra -Wno-unused-parameter -O3 -fPIC
CXXFLAGS += -Wall -Wextra -Wno-unused-parameter -O3 -fPIC CXXFLAGS += -Wall -Wextra -Wno-unused-parameter -O3 -fPIC
CPPFLAGS += -I$(base_dir)/lib -iquote$(base_dir) CPPFLAGS += -I$(base_dir)/lib -iquote$(base_dir)
...@@ -53,9 +55,22 @@ clean: ...@@ -53,9 +55,22 @@ clean:
distclean: distclean:
rm -rf $(CLEAN_ALL) $(DISTCLEAN_ALL) rm -rf $(CLEAN_ALL) $(DISTCLEAN_ALL)
lint: lint-cpplint:
$(CPPLINT) --quiet --recursive . $(CPPLINT) --quiet --recursive .
lint-clang-tidy:
./.clang-tidy-wrapper.sh $(CLANG_TIDY) -I$(base_dir) -I$(base_dir)lib \
-I/usr/share/verilator/include
clang-format:
$(CLANG_FORMAT) -i --style=file `cat .lint-files`
lint-clang-format:
$(CLANG_FORMAT) --dry-run --style=file `cat .lint-files`
lint: lint-cpplint lint-clang-format
lint-all: lint lint-clang-tidy
help: help:
@echo "Targets:" @echo "Targets:"
@echo " all: builds all the tools directly in this repo" @echo " all: builds all the tools directly in this repo"
...@@ -64,8 +79,12 @@ help: ...@@ -64,8 +79,12 @@ help:
@echo " documentation: build documentation in doc/build_" @echo " documentation: build documentation in doc/build_"
@echo " external: clone and build our tools in external repos " @echo " external: clone and build our tools in external repos "
@echo " (qemu, gem5, ns-3)" @echo " (qemu, gem5, ns-3)"
@echo " lint: run quick format and style checks"
@echo " lint-all: run slow & thorough format and style checks"
@echo " clang-format: reformat source (use with caution)"
.PHONY: all clean distclean lint help .PHONY: all clean distclean lint lint-all lint-cpplint lint-clang-tidy \
lint-clang-format clang-format help
include mk/subdir_post.mk include mk/subdir_post.mk
-include $(DEPS_ALL) -include $(DEPS_ALL)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment