@@ -187,26 +187,27 @@ bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* c
187187 }
188188
189189 const std::vector<std::string>& pathnames = parser.getPathNames ();
190+ const std::list<FileSettings>& fileSettings = parser.getFileSettings ();
190191
191192#if defined(_WIN32)
192193 // For Windows we want case-insensitive path matching
193194 const bool caseSensitive = false ;
194195#else
195196 const bool caseSensitive = true ;
196197#endif
197- if (!settings.fileSettings .empty () && !settings.fileFilters .empty ()) {
198- // filter only for the selected filenames from all project files
199- std::list<FileSettings> newList;
200-
201- const std::list<FileSettings>& fileSettings = settings.fileSettings ;
202- std::copy_if (fileSettings.cbegin (), fileSettings.cend (), std::back_inserter (newList), [&](const FileSettings& fs) {
203- return matchglobs (settings.fileFilters , fs.filename );
204- });
205- if (!newList.empty ())
206- settings.fileSettings = newList;
198+ if (!fileSettings.empty ()) {
199+ if (!settings.fileFilters .empty ()) {
200+ // filter only for the selected filenames from all project files
201+ std::copy_if (fileSettings.cbegin (), fileSettings.cend (), std::back_inserter (mFileSettings ), [&](const FileSettings &fs) {
202+ return matchglobs (settings.fileFilters , fs.filename );
203+ });
204+ if (mFileSettings .empty ()) {
205+ logger.printError (" could not find any files matching the filter." );
206+ return false ;
207+ }
208+ }
207209 else {
208- logger.printError (" could not find any files matching the filter." );
209- return false ;
210+ mFileSettings = fileSettings;
210211 }
211212 } else if (!pathnames.empty ()) {
212213 // Execute recursiveAddFiles() to each given file parameter
@@ -220,13 +221,13 @@ bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* c
220221 }
221222 }
222223
223- if (mFiles .empty () && settings. fileSettings .empty ()) {
224+ if (mFiles .empty () && fileSettings.empty ()) {
224225 logger.printError (" could not find or open any of the paths given." );
225226 if (!ignored.empty ())
226227 logger.printMessage (" Maybe all paths were ignored?" );
227228 return false ;
228229 }
229- if (!settings.fileFilters .empty () && settings. fileSettings .empty ()) {
230+ if (!settings.fileFilters .empty () && fileSettings.empty ()) {
230231 std::map<std::string, std::size_t > newMap;
231232 for (std::map<std::string, std::size_t >::const_iterator i = mFiles .cbegin (); i != mFiles .cend (); ++i)
232233 if (matchglobs (settings.fileFilters , i->first )) {
@@ -319,7 +320,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
319320 std::list<std::string> fileNames;
320321 for (std::map<std::string, std::size_t >::const_iterator i = mFiles .cbegin (); i != mFiles .cend (); ++i)
321322 fileNames.emplace_back (i->first );
322- AnalyzerInformation::writeFilesTxt (settings.buildDir , fileNames, settings.userDefines , settings. fileSettings );
323+ AnalyzerInformation::writeFilesTxt (settings.buildDir , fileNames, settings.userDefines , mFileSettings );
323324 }
324325
325326 if (!settings.checkersReportFilename .empty ())
@@ -328,18 +329,18 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
328329 unsigned int returnValue = 0 ;
329330 if (settings.useSingleJob ()) {
330331 // Single process
331- SingleExecutor executor (cppcheck, mFiles , settings, settings.nomsg , *this );
332+ SingleExecutor executor (cppcheck, mFiles , mFileSettings , settings, settings.nomsg , *this );
332333 returnValue = executor.check ();
333334 } else {
334335#if defined(THREADING_MODEL_THREAD)
335- ThreadExecutor executor (mFiles , settings, settings.nomsg , *this , CppCheckExecutor::executeCommand);
336+ ThreadExecutor executor (mFiles , mFileSettings , settings, settings.nomsg , *this , CppCheckExecutor::executeCommand);
336337#elif defined(THREADING_MODEL_FORK)
337- ProcessExecutor executor (mFiles , settings, settings.nomsg , *this , CppCheckExecutor::executeCommand);
338+ ProcessExecutor executor (mFiles , mFileSettings , settings, settings.nomsg , *this , CppCheckExecutor::executeCommand);
338339#endif
339340 returnValue = executor.check ();
340341 }
341342
342- cppcheck.analyseWholeProgram (settings.buildDir , mFiles );
343+ cppcheck.analyseWholeProgram (settings.buildDir , mFiles , mFileSettings );
343344
344345 if (settings.severity .isEnabled (Severity::information) || settings.checkConfiguration ) {
345346 const bool err = reportSuppressions (settings, cppcheck.isUnusedFunctionCheckEnabled (), mFiles , *this );
0 commit comments