Skip to content
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
63 changes: 63 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: include-what-you-use

on: workflow_dispatch

jobs:
build:

runs-on: ubuntu-20.04

container:
image: "kalilinux/kali-rolling"

steps:
- uses: actions/checkout@v2

# TODO: the necessary packages are excessive - mostly because of Qt - use a pre-built image
- name: Install missing software
run: |
apt-get update
apt-get install -y cmake g++ make libz3-dev libpcre3-dev
apt-get install -y qtbase5-dev qttools5-dev libqt5charts5-dev
apt-get install -y wget iwyu

- name: Prepare CMake
run: |
mkdir cmake.output
cd cmake.output
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DUSE_Z3=On -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off ..
cd ..

- name: Prepare CMake dependencies
run: |
# make sure the precompiled headers exist
#make -C cmake.output lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx
#make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx
# make sure the auto-generated GUI sources exist
make -C cmake.output autogen
# make sure the auto-generated GUI dependencies exist
make -C cmake.output gui-build-deps

- name: Build Qt mappings
run: |
wget https://raw.githubusercontent.com/include-what-you-use/include-what-you-use/master/mapgen/iwyu-mapgen-qt.py
python3 iwyu-mapgen-qt.py /usr/include/x86_64-linux-gnu/qt5/ > qt5.imp

# TODO: the mapping file causes a massive slowdown so we cannot use it at the moment.
# add "-Xiwyu --mapping_file=qt5.imp" at the end of the whole command if we can use them.
- name: iwyu_tool
run: |
# do not fail for now so the output is being saved
iwyu_tool -p cmake.output -j $(nproc) -- -w > iwyu.log || true

- uses: actions/upload-artifact@v2
with:
name: Qt Mappings
path: ./qt5.imp

- uses: actions/upload-artifact@v2
with:
name: Logs
path: ./*.log
3 changes: 1 addition & 2 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
# include <ucontext.h>
#endif
#ifdef __linux__
#include <sys/syscall.h>
#include <sys/types.h>
#include <syscall.h>
Copy link
Copy Markdown

@alejandro-colomar alejandro-colomar May 1, 2022

Choose a reason for hiding this comment

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

This change is incorrect. I've been improving the man-pages so that the correct includes are more clear; see syscall(2):

SYNOPSIS
       #include <sys/syscall.h>      /* Definition of SYS_* constants */
       #include <unistd.h>

       long syscall(long number, ...);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       syscall():
           Since glibc 2.19:
               _DEFAULT_SOURCE
           Before glibc 2.19:
               _BSD_SOURCE || _SVID_SOURCE

https://man7.org/linux/man-pages/man2/syscall.2.html

I opened an issue in iwyu(1) regarding that:

include-what-you-use/include-what-you-use#1036

The BSDs also use <sys/syscall.h>:
https://man.openbsd.org/man2/syscall.2
https://www.freebsd.org/cgi/man.cgi?query=syscall&apropos=0&sektion=0&manpath=FreeBSD+13.0-RELEASE+and+Ports&arch=default&format=html

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@alejandro-colomar
Thanks for pointing that out. I implicitly addressed this in the refactoring that is #4359.

#endif
#endif

Expand Down
8 changes: 4 additions & 4 deletions cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
*/


#include "errortypes.h"
#include "cppcheckexecutor.h"

#ifdef NDEBUG
#include "errortypes.h"

#include <cstdlib>
#include <exception>
#include <string>

#ifdef NDEBUG
#include <iostream>
#include <string>
#endif

#ifdef _WIN32
Expand Down
3 changes: 3 additions & 0 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,18 @@
#ifdef __SVR4 // Solaris
#include <sys/loadavg.h>
#endif

#ifdef THREADING_MODEL_FORK
#if defined(__linux__)
#include <sys/prctl.h>
#endif
#include <sys/select.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <csignal>
#include <unistd.h>
#endif

#ifdef THREADING_MODEL_WIN
#include <future>
#include <numeric>
Expand Down
5 changes: 3 additions & 2 deletions externals/simplecpp/simplecpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
#include <cstdlib>
#include <cstring>
#include <exception>
#include <fstream>
#include <fstream> // IWYU pragma: keep
#include <iostream>
#include <limits>
#include <sstream>
#include <sstream> // IWYU pragma: keep
#include <stack>
#include <stdexcept>
#include <type_traits>
#include <utility>

#ifdef SIMPLECPP_WINDOWS
Expand Down
2 changes: 1 addition & 1 deletion lib/analyzerinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <tinyxml2.h>
#include <cstring>
#include <map>
#include <sstream>
#include <sstream> // IWYU pragma: keep

AnalyzerInformation::~AnalyzerInformation()
{
Expand Down
1 change: 0 additions & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include <memory>
#include <ostream>
#include <set>
#include <type_traits>
#include <utility>

//---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <unistd.h>
#endif
#include <cstddef>
#include <sstream>
#include <sstream> // IWYU pragma: keep

#ifdef _WIN32
std::ostream& operator<<(std::ostream& os, const Color& /*c*/)
Expand Down
1 change: 1 addition & 0 deletions lib/errorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "path.h"
#include "token.h"
#include "tokenlist.h"
#include "utils.h"

#include <algorithm>
#include <array>
Expand Down
2 changes: 1 addition & 1 deletion lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <fstream> // IWYU pragma: keep
#include <iostream>
#include <iterator>

Expand Down
1 change: 1 addition & 0 deletions lib/pathanalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <memory>
#include <string>
#include <tuple>
#include <type_traits>

const Scope* PathAnalysis::findOuterScope(const Scope * scope)
{
Expand Down
1 change: 0 additions & 1 deletion lib/programmemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <list>
#include <memory>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion lib/templatesimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <map>
#include <memory>
#include <stack>
#include <type_traits>
#include <utility>

static Token *skipRequires(Token *tok)
Expand Down
7 changes: 4 additions & 3 deletions test/testrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "errortypes.h"
#include "options.h"
#include "preprocessor.h"
#include "testsuite.h"

#include <cstdlib>
#include <exception>
#include <string>

#ifdef NDEBUG
#include "errortypes.h" // for InternalError

#include <exception>
#include <iostream>
#include <string>
#endif

int main(int argc, char *argv[])
Expand Down