Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a

ImportProject project;

bool inputAsFilter = false;
bool executorAuto = true;
int8_t logMissingInclude{0};

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

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

if (inputAsFilter) {
// these will not be resolved and be used literally
mSettings.fileFilters.insert(mSettings.fileFilters.cend(), mPathNames.cbegin(), mPathNames.cend());
mPathNames.clear();
}

// Print error only if we have "real" command and expect files
if (mPathNames.empty() && project.guiProject.pathNames.empty() && project.fileSettings.empty()) {
// TODO: this message differs from the one reported in fillSettingsFromArgs()
Expand Down