Skip to content

Commit

Permalink
iwyu.yml: treat explicit clang include directory in clang-tidy invoca…
Browse files Browse the repository at this point in the history
…tion as a system include / cleaned up includes (#5983)

This gets rid of false positives which suggested to replace the proper
C++ header with a C one (e.g. `climits` -> `limits.h`).
  • Loading branch information
firewave authored Mar 4, 2024
1 parent 0ab4257 commit 2464a9d
Show file tree
Hide file tree
Showing 37 changed files with 52 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
- name: iwyu_tool
run: |
PWD=$(pwd)
iwyu_tool -p cmake.output -j $(nproc) -- -w -Xiwyu --max_line_length=1024 -Xiwyu --comment_style=long -Xiwyu --quoted_includes_first -Xiwyu --update_comments -Xiwyu --mapping_file=$PWD/qt5.imp -I/usr/lib/clang/17/include > iwyu.log
iwyu_tool -p cmake.output -j $(nproc) -- -w -Xiwyu --max_line_length=1024 -Xiwyu --comment_style=long -Xiwyu --quoted_includes_first -Xiwyu --update_comments -Xiwyu --mapping_file=$PWD/qt5.imp -isystem/usr/lib/clang/17/include > iwyu.log
- uses: actions/upload-artifact@v3
if: success() || failure()
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ test/testpostfixoperator.o: test/testpostfixoperator.cpp lib/addoninfo.h lib/che
test/testpreprocessor.o: test/testpreprocessor.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.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/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpreprocessor.cpp

test/testprocessexecutor.o: test/testprocessexecutor.cpp cli/executor.h cli/processexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h
test/testprocessexecutor.o: test/testprocessexecutor.cpp cli/executor.h cli/processexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testprocessexecutor.cpp

test/testsettings.o: test/testsettings.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h
Expand All @@ -823,7 +823,7 @@ test/testsimplifytypedef.o: test/testsimplifytypedef.cpp lib/addoninfo.h lib/che
test/testsimplifyusing.o: test/testsimplifyusing.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.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/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsimplifyusing.cpp

test/testsingleexecutor.o: test/testsingleexecutor.cpp cli/executor.h cli/singleexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h
test/testsingleexecutor.o: test/testsingleexecutor.cpp cli/executor.h cli/singleexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsingleexecutor.cpp

test/testsizeof.o: test/testsizeof.cpp lib/addoninfo.h lib/check.h lib/checksizeof.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h
Expand All @@ -838,13 +838,13 @@ test/teststring.o: test/teststring.cpp lib/addoninfo.h lib/check.h lib/checkstri
test/testsummaries.o: test/testsummaries.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/summaries.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsummaries.cpp

test/testsuppressions.o: test/testsuppressions.cpp cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h
test/testsuppressions.o: test/testsuppressions.cpp cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsuppressions.cpp

test/testsymboldatabase.o: test/testsymboldatabase.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsymboldatabase.cpp

test/testthreadexecutor.o: test/testthreadexecutor.cpp cli/executor.h cli/threadexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h
test/testthreadexecutor.o: test/testthreadexecutor.cpp cli/executor.h cli/threadexecutor.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h
$(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testthreadexecutor.cpp

test/testtimer.o: test/testtimer.cpp lib/addoninfo.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h test/fixture.h
Expand Down
2 changes: 2 additions & 0 deletions cli/signalhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#if defined(USE_UNIX_SIGNAL_HANDLING)

#include <cstdio>

/**
* @param f Output file
*/
Expand Down
2 changes: 2 additions & 0 deletions gui/checkthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "suppressions.h"

#include <atomic>
#include <string>
#include <vector>

#include <QList>
#include <QObject>
Expand Down
1 change: 1 addition & 0 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "report.h"
#include "resultsview.h"
#include "scratchpad.h"
#include "settings.h"
#include "showtypes.h"
#include "statsdialog.h"
#include "settingsdialog.h"
Expand Down
3 changes: 2 additions & 1 deletion gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
#define MAINWINDOW_H

#include "library.h"
#include "settings.h"
#include "platforms.h"

#include <QFileDialog>
#include <QMainWindow>
#include <QObject>
#include <QPair>
#include <QString>
#include <QStringList>

Expand All @@ -43,6 +43,7 @@ class ImportProject;
class QCloseEvent;
class QNetworkAccessManager;
class QNetworkReply;
class Settings;
namespace Ui {
class MainWindow;
}
Expand Down
1 change: 1 addition & 0 deletions gui/projectfiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <list>
#include <string>
#include <utility>

#include <QByteArray>
#include <QCheckBox>
Expand Down
3 changes: 3 additions & 0 deletions gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "common.h"
#include "config.h"
#include "erroritem.h"
#include "errorlogger.h"
#include "errortypes.h"
#include "path.h"
#include "projectfile.h"
Expand All @@ -32,6 +33,8 @@
#include "threadhandler.h"
#include "xmlreportv2.h"

#include <utility>

#include <QAction>
#include <QApplication>
#include <QClipboard>
Expand Down
2 changes: 2 additions & 0 deletions gui/test/projectfile/testprojectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <string>

#include <QFile>
#include <QIODevice>
#include <QList>
#include <QStringList>
#include <QTemporaryDir>
Expand Down
1 change: 0 additions & 1 deletion gui/threadresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <numeric>

#include <QFile>
#include <QMutexLocker>

void ThreadResult::reportOut(const std::string &outmsg, Color /*c*/)
{
Expand Down
3 changes: 3 additions & 0 deletions gui/xmlreportv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
#include "cppcheck.h"
#include "erroritem.h"
#include "report.h"
#include "settings.h"
#include "xmlreport.h"

#include <utility>

#include <QDebug>
#include <QDir>
#include <QFile>
Expand Down
1 change: 1 addition & 0 deletions lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <iterator>
#include <numeric> // std::accumulate
#include <sstream>
#include <utility>

#include "xml.h"

Expand Down
4 changes: 0 additions & 4 deletions lib/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@

#include "xml.h"

namespace CTU {
class FileInfo;
}

//---------------------------------------------------------------------------

static const CWE CWE561(561U); // Dead Code
Expand Down
1 change: 1 addition & 0 deletions lib/clangimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "errortypes.h"
#include "mathlib.h"
#include "settings.h"
#include "standards.h"
#include "symboldatabase.h"
#include "token.h"
#include "tokenize.h"
Expand Down
1 change: 1 addition & 0 deletions lib/cppcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <functional>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <unordered_set>
Expand Down
1 change: 1 addition & 0 deletions lib/errorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "color.h"
#include "cppcheck.h"
#include "path.h"
#include "settings.h"
#include "suppressions.h"
#include "token.h"
#include "tokenlist.h"
Expand Down
5 changes: 3 additions & 2 deletions lib/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
#include "summaries.h"
#include "vfvalue.h"

#include <fstream>
#include <sstream>
#include <cctype>
#include <fstream> // IWYU pragma: keep
#include <sstream> // IWYU pragma: keep

#include "json.h"

Expand Down
3 changes: 3 additions & 0 deletions lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@
#include <atomic>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <unordered_set>
#include <utility>

enum class SHOWTIME_MODES;
namespace ValueFlow {
Expand Down
2 changes: 2 additions & 0 deletions test/fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
#include "standards.h"

#include <cstddef>
#include <cstdint>
#include <list>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>

class options;
Expand Down
1 change: 1 addition & 0 deletions test/signal/test-signalhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <cassert>
#include <cfenv>
#include <cstdlib>
#include <cstring>

// static functions are omitted from trace
Expand Down
2 changes: 1 addition & 1 deletion test/signal/test-signalhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_assert():
if sys.platform == "darwin":
assert stderr.startswith("Assertion failed: (false), function my_assert, file test-signalhandler.cpp, line "), stderr
else:
assert stderr.endswith("test-signalhandler.cpp:32: void my_assert(): Assertion `false' failed.\n"), stderr
assert stderr.endswith("test-signalhandler.cpp:33: void my_assert(): Assertion `false' failed.\n"), stderr
lines = stdout.splitlines()
assert lines[0] == 'Internal error: cppcheck received signal SIGABRT - abort or assertion'
# no stacktrace of MacOs
Expand Down
2 changes: 2 additions & 0 deletions test/signal/test-stacktrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifdef USE_UNIX_BACKTRACE_SUPPORT
#include "stacktrace.h"

#include <cstdio>

// static functions are omitted from trace

/*static*/ void my_func_2()
Expand Down
1 change: 0 additions & 1 deletion test/testcmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "timer.h"
#include "utils.h"

#include <cstdint>
#include <cstdio>
#include <list>
#include <memory>
Expand Down
1 change: 1 addition & 0 deletions test/testerrorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <list>
#include <string>
#include <utility>

#include "xml.h"

Expand Down
1 change: 1 addition & 0 deletions test/testimportproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <map>
#include <sstream> // IWYU pragma: keep
#include <string>
#include <utility>
#include <vector>

class TestImporter : public ImportProject {
Expand Down
2 changes: 2 additions & 0 deletions test/testpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include "path.h"
#include "fixture.h"
#include "helpers.h"
#include "standards.h"

#include <set>
#include <string>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions test/testpathmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "fixture.h"

#include <string>
#include <utility>
#include <vector>


Expand Down
3 changes: 1 addition & 2 deletions test/testprocessexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "checkunusedfunctions.h"
#include "processexecutor.h"
#include "redirect.h"
#include "settings.h"
#include "filesettings.h"
#include "fixture.h"
#include "helpers.h"
#include "suppressions.h"
#include "timer.h"

#include <algorithm>
#include <cstdlib>
#include <list>
#include <memory>
Expand Down
3 changes: 3 additions & 0 deletions test/testsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "settings.h"
#include "fixture.h"
#include "helpers.h"
#include "suppressions.h"



class TestSettings : public TestFixture {
public:
Expand Down
1 change: 1 addition & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "platform.h"
#include "settings.h"
#include "fixture.h"
#include "standards.h"
#include "token.h"
#include "tokenize.h"
#include "tokenlist.h"
Expand Down
3 changes: 1 addition & 2 deletions test/testsingleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "checkunusedfunctions.h"
#include "cppcheck.h"
#include "filesettings.h"
#include "fixture.h"
#include "helpers.h"
#include "redirect.h"
#include "settings.h"
#include "singleexecutor.h"
#include "suppressions.h"
#include "timer.h"

#include <algorithm>
#include <cstdlib>
#include <list>
#include <memory>
Expand Down
2 changes: 0 additions & 2 deletions test/testsuppressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "checkunusedfunctions.h"
#include "config.h"
#include "cppcheck.h"
#include "cppcheckexecutor.h"
Expand All @@ -30,7 +29,6 @@
#include "threadexecutor.h"
#include "singleexecutor.h"

#include <algorithm>
#include <cstddef>
#include <cstring>
#include <list>
Expand Down
3 changes: 0 additions & 3 deletions test/testsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "errortypes.h"
#include "fixture.h"
#include "helpers.h"
#include "library.h"
#include "platform.h"
#include "settings.h"
#include "sourcelocation.h"
Expand All @@ -34,12 +33,10 @@
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <vector>

class TestSymbolDatabase;
Expand Down
Loading

0 comments on commit 2464a9d

Please sign in to comment.