@@ -382,6 +382,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
382382 bool def = false ;
383383 bool maxconfigs = false ;
384384 bool debug = false ;
385+ bool inputAsFilter = false ; // set by: --file-filter=+
385386
386387 ImportProject::Type projectType = ImportProject::Type::NONE;
387388 ImportProject project;
@@ -768,6 +769,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
768769 mLogger .printError (" Failed: --file-filter=-" );
769770 return Result::Fail;
770771 }
772+ } else if (std::strcmp (filter, " +" ) == 0 ) {
773+ inputAsFilter = true ;
771774 } else {
772775 mSettings .fileFilters .emplace_back (filter);
773776 }
@@ -1582,6 +1585,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
15821585 // mLogger.printMessage("whole program analysis requires --cppcheck-build-dir to be active with -j.");
15831586 }
15841587
1588+ if (inputAsFilter) {
1589+ mSettings .fileFilters .insert (mSettings .fileFilters .end (), mPathNames .cbegin (), mPathNames .cend ());
1590+ mPathNames .clear ();
1591+ }
1592+
15851593 if (!mPathNames .empty () && projectType != ImportProject::Type::NONE) {
15861594 mLogger .printError (" --project cannot be used in conjunction with source files." );
15871595 return Result::Fail;
@@ -1777,10 +1785,12 @@ void CmdLineParser::printHelp() const
17771785 " --exitcode-suppressions=<file>\n "
17781786 " Used when certain messages should be displayed but\n "
17791787 " should not cause a non-zero exitcode.\n "
1780- " --file-filter=<str> Analyze only those files matching the given filter str\n "
1781- " Can be used multiple times\n "
1788+ " --file-filter=<str> Analyze only those files matching the given filter str.\n "
1789+ " Can be used multiple times. When str is '-', the file\n "
1790+ " filter will be read from standard input. When str is '+',\n "
1791+ " all path arguments are treated as file filters.\n "
17821792 " Example: --file-filter=*bar.cpp analyzes only files\n "
1783- " that end with bar.cpp.\n "
1793+ " that end with bar.cpp.\n "
17841794 " --file-list=<file> Specify the files to check in a text file. Add one\n "
17851795 " filename per line. When file is '-,' the file list will\n "
17861796 " be read from standard input.\n "
0 commit comments