Skip to content

fixed #12841 - added frontend for shared CLI and GUI code #7579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Checks: >
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix
WarningsAsErrors: '*'
HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z_]+\.h'
HeaderFilterRegex: '(cli|gui|frontend|lib|oss-fuzz|test|triage)\/[a-z_]+\.h'
ExcludeHeaderFilterRegex: 'ui_.*.h'
CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ jobs:
./cppcheck $selfcheck_options externals || ec=1
# self check lib/cli
mkdir b1
./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json cli || ec=1
./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json cli frontend || ec=1
./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json --enable=internal lib || ec=1
# check gui with qt settings
mkdir b2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2"
ec=0
./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli frontend || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2"
ec=0
./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli frontend || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2"
ec=0
./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli frontend || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=69 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1
./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ if(USE_BUNDLED_TINYXML2)
endif()
add_subdirectory(externals/simplecpp)
add_subdirectory(lib) # CppCheck Library
add_subdirectory(frontend)
add_subdirectory(cli) # Client application
add_subdirectory(test) # Tests
add_subdirectory(gui) # Graphical application
Expand Down
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ ifndef INCLUDE_FOR_LIB
INCLUDE_FOR_LIB=-Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2
endif

ifndef INCLUDE_FOR_FE
INCLUDE_FOR_FE=-Ilib
endif

ifndef INCLUDE_FOR_CLI
INCLUDE_FOR_CLI=-Ilib -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2
INCLUDE_FOR_CLI=-Ilib -Ifrontend -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2
endif

ifndef INCLUDE_FOR_TEST
Expand Down Expand Up @@ -252,6 +256,8 @@ LIBOBJ = $(libcppdir)/valueflow.o \
EXTOBJ = externals/simplecpp/simplecpp.o \
externals/tinyxml2/tinyxml2.o

FEOBJ = frontend/frontend.o

CLIOBJ = cli/cmdlineparser.o \
cli/cppcheckexecutor.o \
cli/executor.o \
Expand Down Expand Up @@ -344,12 +350,12 @@ TESTOBJ = test/fixture.o \

###### Targets

cppcheck: $(EXTOBJ) $(LIBOBJ) $(CLIOBJ)
cppcheck: $(EXTOBJ) $(LIBOBJ) $(FEOBJ) $(CLIOBJ)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)

all: cppcheck testrunner

testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ) cli/cmdlineparser.o cli/cppcheckexecutor.o cli/executor.o cli/filelister.o cli/processexecutor.o cli/sehwrapper.o cli/signalhandler.o cli/singleexecutor.o cli/stacktrace.o cli/threadexecutor.o
testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ) $(FEOBJ) cli/cmdlineparser.o cli/cppcheckexecutor.o cli/executor.o cli/filelister.o cli/processexecutor.o cli/sehwrapper.o cli/signalhandler.o cli/singleexecutor.o cli/stacktrace.o cli/threadexecutor.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC)

test: all
Expand Down Expand Up @@ -653,6 +659,9 @@ $(libcppdir)/vf_settokenvalue.o: lib/vf_settokenvalue.cpp lib/addoninfo.h lib/as
$(libcppdir)/vfvalue.o: lib/vfvalue.cpp lib/config.h lib/errortypes.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vfvalue.cpp

frontend/frontend.o: frontend/frontend.cpp frontend/frontend.h
$(CXX) ${INCLUDE_FOR_FE} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ frontend/frontend.cpp

cli/cmdlineparser.o: cli/cmdlineparser.cpp cli/cmdlinelogger.h cli/cmdlineparser.h cli/filelister.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h lib/xml.h
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cmdlineparser.cpp

Expand Down
4 changes: 2 additions & 2 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if (BUILD_CLI)
list(REMOVE_ITEM srcs ${mainfile})

add_library(cli_objs OBJECT ${hdrs} ${srcs})
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/frontend/)
if(USE_BUNDLED_TINYXML2)
target_externals_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
else()
Expand All @@ -26,7 +26,7 @@ if (BUILD_CLI)
set_source_files_properties(processexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier)
endif()

list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs>)
list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $<TARGET_OBJECTS:cli_objs> $<TARGET_OBJECTS:frontend_objs>)
if (NOT BUILD_CORE_DLL)
list(APPEND cppcheck_SOURCES $<TARGET_OBJECTS:cppcheck-core>)
list(APPEND cppcheck_SOURCES $<TARGET_OBJECTS:simplecpp_objs>)
Expand Down
10 changes: 6 additions & 4 deletions cli/cli.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BufferSecurityCheck>true</BufferSecurityCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
Expand Down Expand Up @@ -114,7 +114,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-PCRE|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BufferSecurityCheck>true</BufferSecurityCheck>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
Expand Down Expand Up @@ -143,7 +143,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -181,7 +181,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-PCRE|x64'">
<ClCompile>
<AdditionalIncludeDirectories>..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\lib;..\frontend;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<BufferSecurityCheck>false</BufferSecurityCheck>
<Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down Expand Up @@ -231,6 +231,7 @@
<ClInclude Include="singleexecutor.h" />
<ClInclude Include="stacktrace.h" />
<ClInclude Include="threadexecutor.h" />
<ClInclude Include="..\frontend\frontend.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\cppcheck.vcxproj">
Expand All @@ -254,6 +255,7 @@
<ClCompile Include="singleexecutor.cpp" />
<ClCompile Include="stacktrace.cpp" />
<ClCompile Include="threadexecutor.cpp" />
<ClCompile Include="..\frontend\frontend.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
Expand Down
18 changes: 12 additions & 6 deletions cli/cli.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
<ClInclude Include="cppcheckexecutor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="cppcheckexecutorseh.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="signalhandler.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -44,6 +41,12 @@
<ClInclude Include="singleexecutor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sehwrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\frontend\frontend.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup Label="SourceFiles">
<ClCompile Include="main.cpp">
Expand All @@ -55,9 +58,6 @@
<ClCompile Include="cppcheckexecutor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cppcheckexecutorseh.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="signalhandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -79,6 +79,12 @@
<ClCompile Include="singleexecutor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sehwrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\frontend\frontend.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc">
Expand Down
5 changes: 5 additions & 0 deletions frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")

add_library(frontend_objs OBJECT ${hdrs} ${srcs})
target_include_directories(frontend_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib)
22 changes: 22 additions & 0 deletions frontend/frontend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2025 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 <http://www.gnu.org/licenses/>.
*/

#include "frontend.h"

namespace frontend
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is no code in the frontend I don't understand why we add this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just adds in the framework. The code will be added in the follow-up #7570.

{}
25 changes: 25 additions & 0 deletions frontend/frontend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* -*- C++ -*-
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2025 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 <http://www.gnu.org/licenses/>.
*/

#ifndef FRONTEND_H
#define FRONTEND_H

namespace frontend
{}

#endif // FRONTEND_H
4 changes: 2 additions & 2 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CheckOptions:
list(APPEND cppcheck-gui-deps ${hdrs} ${uis_hdrs} ${resources} ${qms})
add_custom_target(gui-build-deps SOURCES ${cppcheck-gui-deps})

list(APPEND cppcheck-gui_SOURCES ${srcs})
list(APPEND cppcheck-gui_SOURCES ${srcs} $<TARGET_OBJECTS:frontend_objs>)
if (NOT BUILD_CORE_DLL)
list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:cppcheck-core> $<TARGET_OBJECTS:simplecpp_objs>)
if(USE_BUNDLED_TINYXML2)
Expand All @@ -34,7 +34,7 @@ CheckOptions:
add_executable(cppcheck-gui ${cppcheck-gui-deps} ${cppcheck-gui_SOURCES})
set_target_properties(cppcheck-gui PROPERTIES AUTOMOC ON)
set_target_properties(cppcheck-gui PROPERTIES WIN32_EXECUTABLE ON)
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/ ${PROJECT_SOURCE_DIR}/frontend/)
if(USE_BUNDLED_TINYXML2)
target_externals_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
else()
Expand Down
Loading
Loading