@@ -186,30 +186,40 @@ bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* c
186
186
logger.printMessage (" Please use --suppress for ignoring results from the header files." );
187
187
}
188
188
189
- const std::vector<std::string>& pathnames = parser.getPathNames ();
190
- const std::list<FileSettings>& fileSettings = parser.getFileSettings ();
189
+ const std::vector<std::string>& pathnamesRef = parser.getPathNames ();
190
+ const std::list<FileSettings>& fileSettingsRef = parser.getFileSettings ();
191
191
192
192
// the inputs can only be used exclusively - CmdLineParser should already handle this
193
- assert (!(!pathnames .empty () && !fileSettings .empty ()));
193
+ assert (!(!pathnamesRef .empty () && !fileSettingsRef .empty ()));
194
194
195
- if (!fileSettings.empty ()) {
195
+ if (!fileSettingsRef.empty ()) {
196
+ std::list<FileSettings> fileSettings;
196
197
if (!settings.fileFilters .empty ()) {
197
198
// filter only for the selected filenames from all project files
198
- std::copy_if (fileSettings .cbegin (), fileSettings .cend (), std::back_inserter (mFileSettings ), [&](const FileSettings &fs) {
199
+ std::copy_if (fileSettingsRef .cbegin (), fileSettingsRef .cend (), std::back_inserter (fileSettings ), [&](const FileSettings &fs) {
199
200
return matchglobs (settings.fileFilters , fs.filename );
200
201
});
201
- if (mFileSettings .empty ()) {
202
+ if (fileSettings .empty ()) {
202
203
logger.printError (" could not find any files matching the filter." );
203
204
return false ;
204
205
}
205
206
}
206
207
else {
207
- mFileSettings = fileSettings ;
208
+ fileSettings = fileSettingsRef ;
208
209
}
210
+
211
+ // sort the markup last
212
+ std::copy_if (fileSettings.cbegin (), fileSettings.cend (), std::back_inserter (mFileSettings ), [&](const FileSettings &fs) {
213
+ return !settings.library .markupFile (fs.filename ) || !settings.library .processMarkupAfterCode (fs.filename );
214
+ });
215
+
216
+ std::copy_if (fileSettings.cbegin (), fileSettings.cend (), std::back_inserter (mFileSettings ), [&](const FileSettings &fs) {
217
+ return settings.library .markupFile (fs.filename ) && settings.library .processMarkupAfterCode (fs.filename );
218
+ });
209
219
}
210
220
211
- if (!pathnames .empty ()) {
212
- std::list<std::pair<std::string, std::size_t >> files ;
221
+ if (!pathnamesRef .empty ()) {
222
+ std::list<std::pair<std::string, std::size_t >> filesResolved ;
213
223
// TODO: this needs to be inlined into PathMatch as it depends on the underlying filesystem
214
224
#if defined(_WIN32)
215
225
// For Windows we want case-insensitive path matching
@@ -219,26 +229,36 @@ bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* c
219
229
#endif
220
230
// Execute recursiveAddFiles() to each given file parameter
221
231
const PathMatch matcher (ignored, caseSensitive);
222
- for (const std::string &pathname : pathnames ) {
223
- const std::string err = FileLister::recursiveAddFiles (files , Path::toNativeSeparators (pathname), settings.library .markupExtensions (), matcher);
232
+ for (const std::string &pathname : pathnamesRef ) {
233
+ const std::string err = FileLister::recursiveAddFiles (filesResolved , Path::toNativeSeparators (pathname), settings.library .markupExtensions (), matcher);
224
234
if (!err.empty ()) {
225
235
// TODO: bail out?
226
236
logger.printMessage (err);
227
237
}
228
238
}
229
239
240
+ std::list<std::pair<std::string, std::size_t >> files;
230
241
if (!settings.fileFilters .empty ()) {
231
- std::copy_if (files .cbegin (), files .cend (), std::inserter (mFiles , mFiles .end ()), [&](const decltype (files )::value_type& entry) {
242
+ std::copy_if (filesResolved .cbegin (), filesResolved .cend (), std::inserter (files, files .end ()), [&](const decltype (filesResolved )::value_type& entry) {
232
243
return matchglobs (settings.fileFilters , entry.first );
233
244
});
234
- if (mFiles .empty ()) {
245
+ if (files .empty ()) {
235
246
logger.printError (" could not find any files matching the filter." );
236
247
return false ;
237
248
}
238
249
}
239
250
else {
240
- mFiles = files ;
251
+ files = std::move (filesResolved) ;
241
252
}
253
+
254
+ // sort the markup last
255
+ std::copy_if (files.cbegin (), files.cend (), std::inserter (mFiles , mFiles .end ()), [&](const decltype (files)::value_type& entry) {
256
+ return !settings.library .markupFile (entry.first ) || !settings.library .processMarkupAfterCode (entry.first );
257
+ });
258
+
259
+ std::copy_if (files.cbegin (), files.cend (), std::inserter (mFiles , mFiles .end ()), [&](const decltype (files)::value_type& entry) {
260
+ return settings.library .markupFile (entry.first ) && settings.library .processMarkupAfterCode (entry.first );
261
+ });
242
262
}
243
263
244
264
if (mFiles .empty () && mFileSettings .empty ()) {
0 commit comments