From 8cf6a22ea3c410d37664ee12a3becb25be0dd7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sun, 30 Apr 2023 07:33:19 +0200 Subject: [PATCH] cleaned up includes based on `include-what-you-use` (#5021) --- Makefile | 2 +- cli/cmdlineparser.cpp | 1 + cli/executor.cpp | 1 - cli/processexecutor.cpp | 3 ++- gui/newsuppressiondialog.cpp | 1 - lib/checkio.cpp | 1 + lib/checkunusedfunctions.cpp | 1 + lib/errorlogger.cpp | 3 ++- test/helpers.cpp | 4 ++++ test/helpers.h | 10 +++------- test/testcmdlineparser.cpp | 2 +- test/testcppcheck.cpp | 1 - test/testerrorlogger.cpp | 1 - test/testsimplifyusing.cpp | 3 +++ test/testsuppressions.cpp | 1 - test/testutils.cpp | 5 +++++ 16 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index ce1deb17e..65ca5504e 100644 --- a/Makefile +++ b/Makefile @@ -670,7 +670,7 @@ cli/threadexecutor.o: cli/threadexecutor.cpp cli/cppcheckexecutor.h cli/executor test/fixture.o: test/fixture.cpp lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/suppressions.h test/fixture.h test/options.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/fixture.cpp -test/helpers.o: test/helpers.cpp externals/simplecpp/simplecpp.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/helpers.h +test/helpers.o: test/helpers.cpp externals/simplecpp/simplecpp.h lib/config.h lib/errortypes.h lib/mathlib.h lib/path.h lib/preprocessor.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/helpers.cpp test/main.o: test/main.cpp externals/simplecpp/simplecpp.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/preprocessor.h lib/suppressions.h test/fixture.h test/options.h diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 2ee6c0082..b43244896 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -21,6 +21,7 @@ #include "check.h" #include "config.h" #include "cppcheckexecutor.h" +#include "errorlogger.h" #include "errortypes.h" #include "filelister.h" #include "importproject.h" diff --git a/cli/executor.cpp b/cli/executor.cpp index 8be6b30b6..67f84e28d 100644 --- a/cli/executor.cpp +++ b/cli/executor.cpp @@ -24,7 +24,6 @@ #include "suppressions.h" #include -#include #include // IWYU pragma: keep #include diff --git a/cli/processexecutor.cpp b/cli/processexecutor.cpp index 01b2a6614..a2b28ebe0 100644 --- a/cli/processexecutor.cpp +++ b/cli/processexecutor.cpp @@ -20,7 +20,6 @@ #if !defined(WIN32) && !defined(__MINGW32__) -#include "color.h" #include "config.h" #include "cppcheck.h" #include "cppcheckexecutor.h" @@ -56,6 +55,8 @@ #include #endif +enum class Color; + // NOLINTNEXTLINE(misc-unused-using-decls) - required for FD_ZERO using std::memset; diff --git a/gui/newsuppressiondialog.cpp b/gui/newsuppressiondialog.cpp index e47c15dc5..99815837a 100644 --- a/gui/newsuppressiondialog.cpp +++ b/gui/newsuppressiondialog.cpp @@ -24,7 +24,6 @@ #include "ui_newsuppressiondialog.h" -#include #include #include diff --git a/lib/checkio.cpp b/lib/checkio.cpp index a01ff0c30..c93820d31 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -26,6 +26,7 @@ #include "symboldatabase.h" #include "token.h" #include "tokenize.h" +#include "utils.h" #include "vfvalue.h" #include diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index 35e8344de..54d5266d0 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -29,6 +29,7 @@ #include "token.h" #include "tokenize.h" #include "tokenlist.h" +#include "utils.h" #include #include diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index 3cd3bbf52..35552d313 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -24,6 +24,7 @@ #include "path.h" #include "token.h" #include "tokenlist.h" +#include "utils.h" #include #include @@ -32,9 +33,9 @@ #include #include #include -#include #include // IWYU pragma: keep #include +#include #include #include diff --git a/test/helpers.cpp b/test/helpers.cpp index be5fd4987..d18ef2889 100644 --- a/test/helpers.cpp +++ b/test/helpers.cpp @@ -22,8 +22,10 @@ #include "preprocessor.h" #include +#include #include #include +#include #ifdef _WIN32 #include @@ -34,6 +36,8 @@ #include +class Suppressions; + ScopedFile::ScopedFile(std::string name, const std::string &content, std::string path) : mName(std::move(name)) , mPath(Path::toNativeSeparators(std::move(path))) diff --git a/test/helpers.h b/test/helpers.h index d3117fe55..10e50042f 100644 --- a/test/helpers.h +++ b/test/helpers.h @@ -19,20 +19,16 @@ #ifndef helpersH #define helpersH -#include "color.h" -#include "errorlogger.h" -#include "settings.h" -#include "suppressions.h" #include "tokenize.h" #include "tokenlist.h" -#include // IWYU pragma: keep -#include #include // IWYU pragma: keep #include class Token; -class Processor; +class Preprocessor; +class Settings; +class Suppressions; class givenACodeSampleToTokenize { private: diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index f0756dea1..750dc1152 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -17,7 +17,7 @@ */ #include "cmdlineparser.h" -#include "color.h" +#include "config.h" #include "cppcheckexecutor.h" #include "errortypes.h" #include "platform.h" diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 44782bdab..08b1adcbd 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -23,7 +23,6 @@ #include "fixture.h" #include -#include #include #include diff --git a/test/testerrorlogger.cpp b/test/testerrorlogger.cpp index abe9890ce..ac1160d9b 100644 --- a/test/testerrorlogger.cpp +++ b/test/testerrorlogger.cpp @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -#include "color.h" #include "config.h" #include "cppcheck.h" #include "errorlogger.h" diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 1cc7d1aed..00a2bab8e 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -26,8 +26,11 @@ #include +#include #include // IWYU pragma: keep #include +#include +#include class TestSimplifyUsing : public TestFixture { diff --git a/test/testsuppressions.cpp b/test/testsuppressions.cpp index 4c6ad0637..0dd6e0107 100644 --- a/test/testsuppressions.cpp +++ b/test/testsuppressions.cpp @@ -39,7 +39,6 @@ #include #include #include -#include class TestSuppressions : public TestFixture { public: diff --git a/test/testutils.cpp b/test/testutils.cpp index 612b92da4..ff492ac71 100644 --- a/test/testutils.cpp +++ b/test/testutils.cpp @@ -21,6 +21,11 @@ #include "settings.h" #include "utils.h" +#include +#include +#include +#include + const Settings givenACodeSampleToTokenize::settings; class TestUtils : public TestFixture {