Skip to content

[clang-tidy] suppress dump of disabled checks options when running --dump-config #146693

@vbvictor

Description

@vbvictor

When running clang-tidy --dump-config, the output includes CheckOptions for checks that are currently disabled in the Checks configuration. This creates unnecessary noise and can be confusing for users trying to understand their active configuration.

Need to filter out disabled check options: Only show CheckOptions for checks that are actually enabled in the current Checks configuration

Here is an example when running on LLVM codebase:
clang-tidy -p build --dump-config clang-tools-extra/clang-tidy/ClangTidy.cpp

---
Checks:          'clang-diagnostic-*,clang-analyzer-*,-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming,-misc-include-cleaner'
WarningsAsErrors: ''
HeaderFileExtensions:
  - ''
  - h
  - hh
  - hpp
  - hxx
ImplementationFileExtensions:
  - c
  - cc
  - cpp
  - cxx
HeaderFilterRegex: ''
ExcludeHeaderFilterRegex: ''
FormatStyle:     none
User:            victor
CheckOptions:
  cert-arr39-c.WarnOnSizeOfCompareToConstant: 'false'
  cert-arr39-c.WarnOnSizeOfConstant: 'false'
  cert-arr39-c.WarnOnSizeOfIntegerExpression: 'false'
  cert-arr39-c.WarnOnSizeOfPointer: 'false'
  cert-arr39-c.WarnOnSizeOfPointerToAggregate: 'false'
  cert-arr39-c.WarnOnSizeOfThis: 'false'
  cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
  cert-err33-c.AllowCastToVoid: 'true'
  cert-err33-c.CheckedFunctions: '^::aligned_alloc;^::asctime_s;^::at_quick_exit;^::atexit;^::bsearch;^::bsearch_s;^::btowc;^::c16rtomb;^::c32rtomb;^::calloc;^::clock;^::cnd_broadcast;^::cnd_init;^::cnd_signal;^::cnd_timedwait;^::cnd_wait;^::ctime_s;^::fclose;^::fflush;^::fgetc;^::fgetpos;^::fgets;^::fgetwc;^::fopen;^::fopen_s;^::fprintf;^::fprintf_s;^::fputc;^::fputs;^::fputwc;^::fputws;^::fread;^::freopen;^::freopen_s;^::fscanf;^::fscanf_s;^::fseek;^::fsetpos;^::ftell;^::fwprintf;^::fwprintf_s;^::fwrite;^::fwscanf;^::fwscanf_s;^::getc;^::getchar;^::getenv;^::getenv_s;^::gets_s;^::getwc;^::getwchar;^::gmtime;^::gmtime_s;^::localtime;^::localtime_s;^::malloc;^::mbrtoc16;^::mbrtoc32;^::mbsrtowcs;^::mbsrtowcs_s;^::mbstowcs;^::mbstowcs_s;^::memchr;^::mktime;^::mtx_init;^::mtx_lock;^::mtx_timedlock;^::mtx_trylock;^::mtx_unlock;^::printf_s;^::putc;^::putwc;^::raise;^::realloc;^::remove;^::rename;^::scanf;^::scanf_s;^::setlocale;^::setvbuf;^::signal;^::snprintf;^::snprintf_s;^::sprintf;^::sprintf_s;^::sscanf;^::sscanf_s;^::strchr;^::strerror_s;^::strftime;^::strpbrk;^::strrchr;^::strstr;^::strtod;^::strtof;^::strtoimax;^::strtok;^::strtok_s;^::strtol;^::strtold;^::strtoll;^::strtoul;^::strtoull;^::strtoumax;^::strxfrm;^::swprintf;^::swprintf_s;^::swscanf;^::swscanf_s;^::thrd_create;^::thrd_detach;^::thrd_join;^::thrd_sleep;^::time;^::timespec_get;^::tmpfile;^::tmpfile_s;^::tmpnam;^::tmpnam_s;^::tss_create;^::tss_get;^::tss_set;^::ungetc;^::ungetwc;^::vfprintf;^::vfprintf_s;^::vfscanf;^::vfscanf_s;^::vfwprintf;^::vfwprintf_s;^::vfwscanf;^::vfwscanf_s;^::vprintf_s;^::vscanf;^::vscanf_s;^::vsnprintf;^::vsnprintf_s;^::vsprintf;^::vsprintf_s;^::vsscanf;^::vsscanf_s;^::vswprintf;^::vswprintf_s;^::vswscanf;^::vswscanf_s;^::vwprintf_s;^::vwscanf;^::vwscanf_s;^::wcrtomb;^::wcschr;^::wcsftime;^::wcspbrk;^::wcsrchr;^::wcsrtombs;^::wcsrtombs_s;^::wcsstr;^::wcstod;^::wcstof;^::wcstoimax;^::wcstok;^::wcstok_s;^::wcstol;^::wcstold;^::wcstoll;^::wcstombs;^::wcstombs_s;^::wcstoul;^::wcstoull;^::wcstoumax;^::wcsxfrm;^::wctob;^::wctrans;^::wctype;^::wmemchr;^::wprintf_s;^::wscanf;^::wscanf_s;'
  cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
  cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
  cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
  google-readability-braces-around-statements.ShortStatementLines: '1'
  google-readability-function-size.StatementThreshold: '800'
  google-readability-namespace-comments.ShortNamespaceLines: '10'
  google-readability-namespace-comments.SpacesBeforeComments: '2'
  llvm-else-after-return.WarnOnConditionVariables: 'false'
  llvm-else-after-return.WarnOnUnfixable: 'false'
  llvm-namespace-comment.ShortNamespaceLines: '1'
  llvm-namespace-comment.SpacesBeforeComments: '1'
  llvm-qualified-auto.AddConstToQualified: 'false'
  misc-coroutine-hostile-raii.RAIITypesList: 'std::lock_guard;std::scoped_lock'
  misc-coroutine-hostile-raii.SafeAwaitableList: ''
  misc-header-include-cycle.IgnoredFilesList: ''
  misc-throw-by-value-catch-by-reference.CheckThrowTemporaries: 'true'
  misc-throw-by-value-catch-by-reference.MaxSize: '18446744073709551615'
  misc-throw-by-value-catch-by-reference.WarnOnLargeObjects: 'false'
  misc-uniqueptr-reset-release.IncludeStyle: llvm
  misc-use-internal-linkage.FixMode: UseStatic
  readability-identifier-naming.AggressiveDependentMemberLookup: 'false'
  readability-identifier-naming.CheckAnonFieldInParent: 'false'
  readability-identifier-naming.ClassCase: CamelCase
  readability-identifier-naming.ClassHungarianPrefix: Off
  readability-identifier-naming.ClassIgnoredRegexp: ''
  readability-identifier-naming.ClassPrefix: ''
  readability-identifier-naming.ClassSuffix: ''
  readability-identifier-naming.EnumCase: CamelCase
  readability-identifier-naming.EnumHungarianPrefix: Off
  readability-identifier-naming.EnumIgnoredRegexp: ''
  readability-identifier-naming.EnumPrefix: ''
  readability-identifier-naming.EnumSuffix: ''
  readability-identifier-naming.FunctionCase: camelBack
  readability-identifier-naming.FunctionHungarianPrefix: Off
  readability-identifier-naming.FunctionIgnoredRegexp: LLVMFuzzerTestOneInput
  readability-identifier-naming.FunctionPrefix: ''
  readability-identifier-naming.FunctionSuffix: ''
  readability-identifier-naming.GetConfigPerFile: 'true'
  readability-identifier-naming.IgnoreFailedSplit: 'false'
  readability-identifier-naming.IgnoreMainLikeFunctions: 'true'
  readability-identifier-naming.MemberCase: CamelCase
  readability-identifier-naming.MemberHungarianPrefix: Off
  readability-identifier-naming.MemberIgnoredRegexp: ''
  readability-identifier-naming.MemberPrefix: ''
  readability-identifier-naming.MemberSuffix: ''
  readability-identifier-naming.ParameterCase: CamelCase
  readability-identifier-naming.ParameterHungarianPrefix: Off
  readability-identifier-naming.ParameterIgnoredRegexp: ''
  readability-identifier-naming.ParameterPrefix: ''
  readability-identifier-naming.ParameterSuffix: ''
  readability-identifier-naming.UnionCase: CamelCase
  readability-identifier-naming.UnionHungarianPrefix: Off
  readability-identifier-naming.UnionIgnoredRegexp: ''
  readability-identifier-naming.UnionPrefix: ''
  readability-identifier-naming.UnionSuffix: ''
  readability-identifier-naming.VariableCase: CamelCase
  readability-identifier-naming.VariableHungarianPrefix: Off
  readability-identifier-naming.VariableIgnoredRegexp: ''
  readability-identifier-naming.VariablePrefix: ''
  readability-identifier-naming.VariableSuffix: ''
SystemHeaders:   false
...

Clearly https://github.com/llvm/llvm-project/blob/main/.clang-tidy doesn't have any cert or google checks enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions