From aab5b39e2d9b49b85f12299bb06af540c49489b0 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Mon, 9 Aug 2021 15:46:56 +0700 Subject: [PATCH] feat: add support for .ipp and .ixx extensions (#3383) --- cli/cmdlineparser.cpp | 4 ++-- gui/filelist.cpp | 2 +- gui/test/data/files/foo8.ipp | 1 + gui/test/data/files/foo9.ixx | 1 + gui/test/filelist/testfilelist.cpp | 16 +++++++++++----- lib/path.cpp | 2 ++ tools/donate_cpu_lib.py | 2 +- tools/triage/mainwindow.cpp | 2 +- 8 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 gui/test/data/files/foo8.ipp create mode 100644 gui/test/data/files/foo9.ixx diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 5c579260a..ad38b6b5d 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -971,8 +971,8 @@ void CmdLineParser::printHelp() "Syntax:\n" " cppcheck [OPTIONS] [files or paths]\n" "\n" - "If a directory is given instead of a filename, *.cpp, *.cxx, *.cc, *.c++, *.c,\n" - "*.tpp, and *.txx files are checked recursively from the given directory.\n\n" + "If a directory is given instead of a filename, *.cpp, *.cxx, *.cc, *.c++, *.c, *.ipp,\n" + "*.ixx, *.tpp, and *.txx files are checked recursively from the given directory.\n\n" "Options:\n" " --addon=\n" " Execute addon. i.e. --addon=cert. If options must be\n" diff --git a/gui/filelist.cpp b/gui/filelist.cpp index da0342905..e06a53089 100644 --- a/gui/filelist.cpp +++ b/gui/filelist.cpp @@ -24,7 +24,7 @@ QStringList FileList::getDefaultFilters() { QStringList extensions; - extensions << "*.cpp" << "*.cxx" << "*.cc" << "*.c" << "*.c++" << "*.txx" << "*.tpp"; + extensions << "*.cpp" << "*.cxx" << "*.cc" << "*.c" << "*.c++" << "*.txx" << "*.tpp" << "*.ipp" << "*.ixx"; return extensions; } diff --git a/gui/test/data/files/foo8.ipp b/gui/test/data/files/foo8.ipp new file mode 100644 index 000000000..e4294ad5e --- /dev/null +++ b/gui/test/data/files/foo8.ipp @@ -0,0 +1 @@ +Dummy test file. diff --git a/gui/test/data/files/foo9.ixx b/gui/test/data/files/foo9.ixx new file mode 100644 index 000000000..e4294ad5e --- /dev/null +++ b/gui/test/data/files/foo9.ixx @@ -0,0 +1 @@ +Dummy test file. diff --git a/gui/test/filelist/testfilelist.cpp b/gui/test/filelist/testfilelist.cpp index 66cd246f9..dc25d78b8 100644 --- a/gui/test/filelist/testfilelist.cpp +++ b/gui/test/filelist/testfilelist.cpp @@ -24,7 +24,7 @@ void TestFileList::addFile() { - // Accepted extensions: *.cpp, *.cxx, *.cc, *.c, *.c++, *.txx, *.tpp" + // Accepted extensions: *.cpp, *.cxx, *.cc, *.c, *.c++, *.txx, *.tpp, *.ipp, *.ixx" FileList list; list.addFile(QString(SRCDIR) + "/../data/files/foo1.cpp"); list.addFile(QString(SRCDIR) + "/../data/files/foo2.cxx"); @@ -33,13 +33,15 @@ void TestFileList::addFile() list.addFile(QString(SRCDIR) + "/../data/files/foo5.c++"); list.addFile(QString(SRCDIR) + "/../data/files/foo6.txx"); list.addFile(QString(SRCDIR) + "/../data/files/foo7.tpp"); + list.addFile(QString(SRCDIR) + "/../data/files/foo8.ipp"); + list.addFile(QString(SRCDIR) + "/../data/files/foo9.ixx"); QStringList files = list.getFileList(); - QCOMPARE(files.size(), 7); + QCOMPARE(files.size(), 9); } void TestFileList::addPathList() { - // Accepted extensions: *.cpp, *.cxx, *.cc, *.c, *.c++, *.txx, *.tpp" + // Accepted extensions: *.cpp, *.cxx, *.cc, *.c, *.c++, *.txx, *.tpp, *.ipp, *.ixx" QStringList paths; paths << QString(SRCDIR) + "/../data/files/foo1.cpp"; paths << QString(SRCDIR) + "/../data/files/foo2.cxx"; @@ -48,10 +50,12 @@ void TestFileList::addPathList() paths << QString(SRCDIR) + "/../data/files/foo5.c++"; paths << QString(SRCDIR) + "/../data/files/foo6.txx"; paths << QString(SRCDIR) + "/../data/files/foo7.tpp"; + paths << QString(SRCDIR) + "/../data/files/foo8.ipp"; + paths << QString(SRCDIR) + "/../data/files/foo9.ixx"; FileList list; list.addPathList(paths); QStringList files = list.getFileList(); - QCOMPARE(files.size(), 7); + QCOMPARE(files.size(), 9); } void TestFileList::addFile_notexist() @@ -105,8 +109,10 @@ void TestFileList::filterFiles() list.addFile(QString(SRCDIR) + "/../data/files/foo5.c++"); list.addFile(QString(SRCDIR) + "/../data/files/foo6.txx"); list.addFile(QString(SRCDIR) + "/../data/files/foo7.tpp"); + list.addFile(QString(SRCDIR) + "/../data/files/foo8.ipp"); + list.addFile(QString(SRCDIR) + "/../data/files/foo9.ixx"); QStringList files = list.getFileList(); - QCOMPARE(files.size(), 5); + QCOMPARE(files.size(), 7); QDir dir(QString(SRCDIR) + "/../data/files"); QString base = dir.canonicalPath(); QVERIFY(!files.contains(base + "/foo1.cpp")); diff --git a/lib/path.cpp b/lib/path.cpp index 8e839ae48..49e4d3d34 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -195,6 +195,8 @@ bool Path::isCPP(const std::string &path) extension == ".hh" || extension == ".tpp" || extension == ".txx" || + extension == ".ipp" || + extension == ".ixx" || getFilenameExtension(path) == ".C"; // In unix, ".C" is considered C++ file } diff --git a/tools/donate_cpu_lib.py b/tools/donate_cpu_lib.py index ed8e9582b..7795dac8d 100644 --- a/tools/donate_cpu_lib.py +++ b/tools/donate_cpu_lib.py @@ -224,7 +224,7 @@ def unpack_package(work_path, tgz): # Skip dangerous file names continue elif member.name.lower().endswith(('.c', '.cpp', '.cxx', '.cc', '.c++', '.h', '.hpp', - '.h++', '.hxx', '.hh', '.tpp', '.txx', '.qml')): + '.h++', '.hxx', '.hh', '.tpp', '.txx', '.ipp', '.ixx', '.qml')): try: tf.extract(member.name) found = True diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index 9edfd2010..99e1cdd5a 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -22,7 +22,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), mVersionRe("^(master|main|your|head|[12].[0-9][0-9]?) (.*)"), - hFiles{"*.hpp", "*.h", "*.hxx", "*.hh", "*.tpp", "*.txx"}, + hFiles{"*.hpp", "*.h", "*.hxx", "*.hh", "*.tpp", "*.txx", "*.ipp", "*.ixx"}, srcFiles{"*.cpp", "*.cxx", "*.cc", "*.c++", "*.C", "*.c", "*.cl"} { ui->setupUi(this);