From 66758d65f9c1fb844667902a019895ff829fdc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Wed, 8 Feb 2023 08:19:21 +0100 Subject: [PATCH] updated precompiled headers based on `ClangBuildAnalyzer` (#4775) --- .github/workflows/clang-tidy.yml | 1 + gui/CMakeLists.txt | 3 +++ gui/precompiled.h | 31 +++++++++++++++++++++++++++++++ lib/precompiled.h | 12 +++++++----- test/fixture.h | 3 +++ test/precompiled.h | 14 ++++++++++---- 6 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 gui/precompiled.h diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 74828486b..41a442753 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -53,6 +53,7 @@ jobs: - name: Prepare CMake dependencies run: | # make sure the precompiled headers exist + make -C cmake.output/gui cmake_pch.hxx.pch make -C cmake.output/lib cmake_pch.hxx.pch make -C cmake.output/test cmake_pch.hxx.pch # make sure the auto-generated GUI sources exist diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 19953448e..e319c35b0 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -44,6 +44,9 @@ CheckOptions: else() target_include_directories(cppcheck-gui SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() + if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) + target_precompile_headers(cppcheck-gui PRIVATE precompiled.h) + endif() if (HAVE_RULES) target_link_libraries(cppcheck-gui ${PCRE_LIBRARY}) endif() diff --git a/gui/precompiled.h b/gui/precompiled.h new file mode 100644 index 000000000..c21895879 --- /dev/null +++ b/gui/precompiled.h @@ -0,0 +1,31 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2023 Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "checkthread.h" +#include "codeeditor.h" +#include "codeeditorstyle.h" +#include "config.h" +#include "cppcheck.h" +#include "cppchecklibrarydata.h" +#include "report.h" +#include "showtypes.h" + +#include +#include diff --git a/lib/precompiled.h b/lib/precompiled.h index d1b222012..1a2c9dd84 100644 --- a/lib/precompiled.h +++ b/lib/precompiled.h @@ -17,11 +17,13 @@ */ #pragma once -#include "config.h" -#include "check.h" +#include "astutils.h" +#include "errorlogger.h" #include "library.h" +//#include "matchcompiler.h" +#include "mathlib.h" #include "token.h" -#include "tokenize.h" -#include "valueflow.h" -#include "symboldatabase.h" #include "settings.h" +#include "suppressions.h" +#include "utils.h" +#include "valueflow.h" diff --git a/test/fixture.h b/test/fixture.h index 23d7b43e3..5fb3b0eee 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -135,7 +135,10 @@ public: static std::size_t runTests(const options& args); }; +// TODO: fix these +// NOLINTNEXTLINE(readability-redundant-declaration) extern std::ostringstream errout; +// NOLINTNEXTLINE(readability-redundant-declaration) extern std::ostringstream output; #define TEST_CASE( NAME ) do { if (prepareTest(#NAME)) { setVerbose(false); NAME(); } } while (false) diff --git a/test/precompiled.h b/test/precompiled.h index fe0ae9a2f..1da2e84cd 100644 --- a/test/precompiled.h +++ b/test/precompiled.h @@ -17,8 +17,14 @@ */ #pragma once -#include "fixture.h" -#include "settings.h" -#include "tokenize.h" -#include "library.h" + #include "check.h" +#include "config.h" +#include "importproject.h" +#include "library.h" +#include "mathlib.h" +#include "settings.h" +#include "timer.h" +#include "token.h" +#include "tokenlist.h" +#include "tokenize.h"