@@ -382,6 +382,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
382
382
bool def = false ;
383
383
bool maxconfigs = false ;
384
384
bool debug = false ;
385
+ bool inputAsFilter = false ; // set by: --file-filter=+
385
386
386
387
ImportProject::Type projectType = ImportProject::Type::NONE;
387
388
ImportProject project;
@@ -768,6 +769,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
768
769
mLogger .printError (" Failed: --file-filter=-" );
769
770
return Result::Fail;
770
771
}
772
+ } else if (std::strcmp (filter, " +" ) == 0 ) {
773
+ inputAsFilter = true ;
771
774
} else {
772
775
mSettings .fileFilters .emplace_back (filter);
773
776
}
@@ -1582,6 +1585,11 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
1582
1585
// mLogger.printMessage("whole program analysis requires --cppcheck-build-dir to be active with -j.");
1583
1586
}
1584
1587
1588
+ if (inputAsFilter) {
1589
+ mSettings .fileFilters .insert (mSettings .fileFilters .end (), mPathNames .cbegin (), mPathNames .cend ());
1590
+ mPathNames .clear ();
1591
+ }
1592
+
1585
1593
if (!mPathNames .empty () && projectType != ImportProject::Type::NONE) {
1586
1594
mLogger .printError (" --project cannot be used in conjunction with source files." );
1587
1595
return Result::Fail;
@@ -1777,10 +1785,12 @@ void CmdLineParser::printHelp() const
1777
1785
" --exitcode-suppressions=<file>\n "
1778
1786
" Used when certain messages should be displayed but\n "
1779
1787
" 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 "
1782
1792
" Example: --file-filter=*bar.cpp analyzes only files\n "
1783
- " that end with bar.cpp.\n "
1793
+ " that end with bar.cpp.\n "
1784
1794
" --file-list=<file> Specify the files to check in a text file. Add one\n "
1785
1795
" filename per line. When file is '-,' the file list will\n "
1786
1796
" be read from standard input.\n "
0 commit comments