Run clang-tidy with make tidy

This commit is contained in:
Rangi42
2025-07-18 10:10:34 -04:00
parent e31256c0d4
commit 8e84850679
4 changed files with 27 additions and 15 deletions

6
.clang-tidy Normal file
View File

@@ -0,0 +1,6 @@
---
Checks: ''
WarningsAsErrors: ''
HeaderFilterRegex: ''
FormatStyle: none
SystemHeaders: false

View File

@@ -3,7 +3,7 @@
.SUFFIXES: .SUFFIXES:
.SUFFIXES: .cpp .y .o .SUFFIXES: .cpp .y .o
.PHONY: all clean install checkdiff develop debug profile coverage iwyu mingw32 mingw64 wine-shim dist .PHONY: all clean install checkdiff develop debug profile coverage tidy iwyu mingw32 mingw64 wine-shim dist
# User-defined variables # User-defined variables
@@ -165,7 +165,6 @@ src/gfx/rgba.o: src/gfx/rgba.cpp
$Q${CXX} ${REALCXXFLAGS} -c -o $@ $< $Q${CXX} ${REALCXXFLAGS} -c -o $@ $<
# Target used to remove all files generated by other Makefile targets # Target used to remove all files generated by other Makefile targets
clean: clean:
$Q${RM} rgbasm rgbasm.exe $Q${RM} rgbasm rgbasm.exe
$Q${RM} rgblink rgblink.exe $Q${RM} rgblink rgblink.exe
@@ -179,7 +178,6 @@ clean:
$Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test $Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test
# Target used to install the binaries and man pages. # Target used to install the binaries and man pages.
install: all install: all
$Qinstall -d ${DESTDIR}${bindir}/ ${DESTDIR}${mandir}/man1/ ${DESTDIR}${mandir}/man5/ ${DESTDIR}${mandir}/man7/ $Qinstall -d ${DESTDIR}${bindir}/ ${DESTDIR}${mandir}/man1/ ${DESTDIR}${mandir}/man5/ ${DESTDIR}${mandir}/man7/
$Qinstall ${STRIP} -m ${BINMODE} rgbasm ${DESTDIR}${bindir}/rgbasm${SUFFIX} $Qinstall ${STRIP} -m ${BINMODE} rgbasm ${DESTDIR}${bindir}/rgbasm${SUFFIX}
@@ -191,15 +189,13 @@ install: all
$Qinstall -m ${MANMODE} man/rgbds.7 man/gbz80.7 ${DESTDIR}${mandir}/man7/ $Qinstall -m ${MANMODE} man/rgbds.7 man/gbz80.7 ${DESTDIR}${mandir}/man7/
# Target used to check for suspiciously missing changed files. # Target used to check for suspiciously missing changed files.
checkdiff: checkdiff:
$Qcontrib/checkdiff.bash `git merge-base HEAD ${BASE_REF}` $Qcontrib/checkdiff.bash `git merge-base HEAD ${BASE_REF}`
# This target is used during development in order to prevent adding new issues # Target used in development to prevent adding new issues to the source code.
# to the source code. All warnings are treated as errors in order to block the # All warnings are treated as errors to block the compilation and make the
# compilation and make the continous integration infrastructure return failure. # continous integration infrastructure return failure.
# The rationale for some of the flags is documented in the CMakeLists. # The rationale for some of the flags is documented in the CMakeLists.
develop: develop:
$Q${MAKE} WARNFLAGS="${WARNFLAGS} -Werror -Wextra \ $Q${MAKE} WARNFLAGS="${WARNFLAGS} -Werror -Wextra \
-Walloc-zero -Wcast-align -Wcast-qual -Wduplicated-branches -Wduplicated-cond \ -Walloc-zero -Wcast-align -Wcast-qual -Wduplicated-branches -Wduplicated-cond \
@@ -212,26 +208,27 @@ develop:
-fsanitize=float-divide-by-zero" \ -fsanitize=float-divide-by-zero" \
CXXFLAGS="-ggdb3 -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls" CXXFLAGS="-ggdb3 -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls"
# This target is used during development in order to more easily debug with gdb. # Target used in development to debug with gdb.
debug: debug:
$Qenv ${MAKE} \ $Qenv ${MAKE} \
CXXFLAGS="-ggdb3 -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls" CXXFLAGS="-ggdb3 -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls"
# This target is used during development in order to more easily profile with callgrind. # Target used in development to profile with callgrind.
profile: profile:
$Qenv ${MAKE} \ $Qenv ${MAKE} \
CXXFLAGS="-ggdb3 -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls" CXXFLAGS="-ggdb3 -O3 -fno-omit-frame-pointer -fno-optimize-sibling-calls"
# This target is used during development in order to inspect code coverage with gcov. # Target used in development to inspect code coverage with gcov.
coverage: coverage:
$Qenv ${MAKE} \ $Qenv ${MAKE} \
CXXFLAGS="-ggdb3 -Og --coverage -fno-omit-frame-pointer -fno-optimize-sibling-calls" CXXFLAGS="-ggdb3 -Og --coverage -fno-omit-frame-pointer -fno-optimize-sibling-calls"
# This target is used during development in order to remove unused `#include` headers. # Target used in development to check code with clang-tidy.
# Requires Bison-generated header files to exist.
tidy: src/asm/parser.hpp src/link/script.hpp
$Qclang-tidy -p . $$(find src -name '*.cpp')
# Target used in development to remove unused `#include` headers.
iwyu: iwyu:
$Qenv ${MAKE} \ $Qenv ${MAKE} \
CXX="include-what-you-use" \ CXX="include-what-you-use" \

View File

@@ -93,6 +93,7 @@ The RGBDS source code file structure is as follows:
│ └── run-tests.sh │ └── run-tests.sh
├── .clang-format ├── .clang-format
├── CMakeLists.txt ├── CMakeLists.txt
├── compile_flags.txt
├── Dockerfile ├── Dockerfile
├── Makefile ├── Makefile
└── README.md └── README.md
@@ -118,6 +119,8 @@ The RGBDS source code file structure is as follows:
modify the behavior of RGBDS. modify the behavior of RGBDS.
- `.clang-format` - code style for automated C++ formatting with - `.clang-format` - code style for automated C++ formatting with
[`clang-format`](https://clang.llvm.org/docs/ClangFormat.html). [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html).
- `compile_flags.txt` - compiler flags for C++ static analysis with
[`clang-tidy`](https://clang.llvm.org/extra/clang-tidy/).
- `Dockerfile` - defines how to build RGBDS with Docker. - `Dockerfile` - defines how to build RGBDS with Docker.
## 3. History ## 3. History

6
compile_flags.txt Normal file
View File

@@ -0,0 +1,6 @@
-std=c++2a
-I
include
-fno-exceptions
-fno-rtti
-fno-caret-diagnostics