diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..d90ac699 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,6 @@ +--- +Checks: '' +WarningsAsErrors: '' +HeaderFilterRegex: '' +FormatStyle: none +SystemHeaders: false diff --git a/Makefile b/Makefile index b912fb15..8201e1f1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ .SUFFIXES: .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 @@ -165,7 +165,6 @@ src/gfx/rgba.o: src/gfx/rgba.cpp $Q${CXX} ${REALCXXFLAGS} -c -o $@ $< # Target used to remove all files generated by other Makefile targets - clean: $Q${RM} rgbasm rgbasm.exe $Q${RM} rgblink rgblink.exe @@ -179,7 +178,6 @@ clean: $Q${RM} test/gfx/randtilegen test/gfx/rgbgfx_test # Target used to install the binaries and man pages. - install: all $Qinstall -d ${DESTDIR}${bindir}/ ${DESTDIR}${mandir}/man1/ ${DESTDIR}${mandir}/man5/ ${DESTDIR}${mandir}/man7/ $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/ # Target used to check for suspiciously missing changed files. - checkdiff: $Qcontrib/checkdiff.bash `git merge-base HEAD ${BASE_REF}` -# This target is used during development in order to prevent adding new issues -# to the source code. All warnings are treated as errors in order to block the -# compilation and make the continous integration infrastructure return failure. +# Target used in development to prevent adding new issues to the source code. +# All warnings are treated as errors to block the compilation and make the +# continous integration infrastructure return failure. # The rationale for some of the flags is documented in the CMakeLists. - develop: $Q${MAKE} WARNFLAGS="${WARNFLAGS} -Werror -Wextra \ -Walloc-zero -Wcast-align -Wcast-qual -Wduplicated-branches -Wduplicated-cond \ @@ -212,26 +208,27 @@ develop: -fsanitize=float-divide-by-zero" \ 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: $Qenv ${MAKE} \ 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: $Qenv ${MAKE} \ 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: $Qenv ${MAKE} \ 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: $Qenv ${MAKE} \ CXX="include-what-you-use" \ diff --git a/README.md b/README.md index ae523e8d..0a899836 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ The RGBDS source code file structure is as follows: │ └── run-tests.sh ├── .clang-format ├── CMakeLists.txt +├── compile_flags.txt ├── Dockerfile ├── Makefile └── README.md @@ -118,6 +119,8 @@ The RGBDS source code file structure is as follows: modify the behavior of RGBDS. - `.clang-format` - code style for automated C++ formatting with [`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. ## 3. History diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 00000000..4cdeefd4 --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,6 @@ +-std=c++2a +-I +include +-fno-exceptions +-fno-rtti +-fno-caret-diagnostics