Skip to content

Commit f451c4e

Browse files
committed
added -file-filter=+ to treat provided input files as filter [skip ci]
1 parent 9ebed11 commit f451c4e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cli/cmdlineparser.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
369369

370370
ImportProject project;
371371

372+
bool inputAsFilter = false;
372373
bool executorAuto = true;
373374
int8_t logMissingInclude{0};
374375

@@ -711,6 +712,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
711712
mLogger.printError("Failed: --file-filter=-");
712713
return Result::Fail;
713714
}
715+
} if (std::strcmp(filter, "+") == 0) {
716+
inputAsFilter = true;
714717
} else {
715718
mSettings.fileFilters.emplace_back(filter);
716719
}
@@ -1441,11 +1444,17 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
14411444
//mLogger.printMessage("whole program analysis requires --cppcheck-build-dir to be active with -j.");
14421445
}
14431446

1444-
if (!mPathNames.empty() && project.projectType != ImportProject::Type::NONE) {
1447+
if (!inputAsFilter && !mPathNames.empty() && project.projectType != ImportProject::Type::NONE) {
14451448
mLogger.printError("--project cannot be used in conjunction with source files.");
14461449
return Result::Fail;
14471450
}
14481451

1452+
if (inputAsFilter) {
1453+
// these will not be resolved and be used literally
1454+
mSettings.fileFilters.insert(mSettings.fileFilters.cend(), mPathNames.cbegin(), mPathNames.cend());
1455+
mPathNames.clear();
1456+
}
1457+
14491458
// Print error only if we have "real" command and expect files
14501459
if (mPathNames.empty() && project.guiProject.pathNames.empty() && project.fileSettings.empty()) {
14511460
// TODO: this message differs from the one reported in fillSettingsFromArgs()

0 commit comments

Comments
 (0)