Skip to content

Commit 5b43ac6

Browse files
committed
add --deduplicate option for controlling deduplication of FileSettings
1 parent f2c346f commit 5b43ac6

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

cli/cmdlineparser.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
250250
fs.computeHash();
251251
}
252252

253-
{
253+
if (mSettings.deduplicate) {
254254
auto it = fileSettings.begin();
255255
while (it != fileSettings.end()) {
256256
fileSettings.erase(std::remove_if(std::next(it), fileSettings.end(), [&](const FileSettings& fs) {
@@ -651,6 +651,9 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
651651
else if (std::strcmp(argv[i], "--debug-clang-output") == 0)
652652
mSettings.debugClangOutput = true;
653653

654+
else if (std::strcmp(argv[i], "--deduplicate") == 0)
655+
mSettings.deduplicate = true;
656+
654657
// Show debug messages for ignored files
655658
else if (std::strcmp(argv[i], "--debug-ignore") == 0)
656659
mSettings.debugignore = true;
@@ -1718,6 +1721,8 @@ void CmdLineParser::printHelp() const
17181721
" be considered for evaluation.\n"
17191722
" --config-excludes-file=<file>\n"
17201723
" A file that contains a list of config-excludes\n"
1724+
" --deduplicate Remove duplicate entries when reading project files.\n"
1725+
" Takes both compilation flags and filenames in to account.\n"
17211726
" --disable=<id> Disable individual checks.\n"
17221727
" Please refer to the documentation of --enable=<id>\n"
17231728
" for further details.\n"

lib/settings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ class CPPCHECKLIB WARN_UNUSED Settings {
220220
/** @brief Do not filter duplicated errors. */
221221
bool emitDuplicates{};
222222

223+
/** @brief De-duplicate files with identical path and config. */
224+
bool deduplicate{};
225+
223226
/** @brief Name of the language that is enforced. Empty per default. */
224227
Standards::Language enforcedLang{};
225228

man/cppcheck.1.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
150150
<arg choice="opt">
151151
<option>--config-excludes-file=&lt;file&gt;</option>
152152
</arg>
153+
<arg choice="opt">
154+
<option>--deduplicate</option>
155+
</arg>
153156
<arg choice="opt">
154157
<option>--include=&lt;file&gt;</option>
155158
</arg>
@@ -441,6 +444,14 @@ First given path is searched for contained header files first. If paths are rela
441444
<para>A file that contains a list of config-excludes.</para>
442445
</listitem>
443446
</varlistentry>
447+
<varlistentry>
448+
<term>
449+
<option>--deduplicate</option>
450+
</term>
451+
<listitem>
452+
<para>Remove duplicate entries when reading project files. Takes both compilation flags and filenames in to account.</para>
453+
</listitem>
454+
</varlistentry>
444455
<varlistentry>
445456
<term>
446457
<option>--include=&lt;file&gt;</option>

0 commit comments

Comments
 (0)