0

I am trying to change the Pedantic option in clang-analyzer-optin.cplusplus.UninitializedObject by create a .clang-tidy file optin-cplusplus-uninitializedobject

here is the YAML version of .clang-tidy config-file:

Checks: >
  cppcoreguidelines-*,
WarningsAsErrors: "*"
CheckOptions:
  - { key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor,       value: true }
  - { key: clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic,       value: true }

when trying to -dump-config option I can see that the clang-analyzer-* check is used:

---
Checks:          "clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,\\n"
WarningsAsErrors: '*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle:     none

CheckOptions:
modernize-replace-auto-ptr.IncludeStyle: llvm
cppcoreguidelines-no-malloc.Reallocations: '::realloc'
cppcoreguidelines-owning-memory.LegacyResourceConsumers: '::free;::realloc;::freopen;::fclose'
cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues: 'false'
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions: 'false'
cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false'
cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
cppcoreguidelines-macro-usage.CheckCapsOnly: 'false'
modernize-loop-convert.MaxCopySize: '16'
cppcoreguidelines-pro-bounds-constant-array-index.GslHeader: ''
cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors: 'false'
cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes: ''
cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false'
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;'
cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal: 'false'
google-readability-braces-around-statements.ShortStatementLines: '1'
cppcoreguidelines-pro-type-member-init.IgnoreArrays: 'false'
cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;'
cppcoreguidelines-macro-usage.IgnoreCommandLineMacros: 'true'
cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle: llvm
cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation: 'false'
cppcoreguidelines-owning-memory.LegacyResourceProducers: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true'
cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth: 'true'
cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues: '1;2;3;4;'
cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false'
modernize-loop-convert.MinConfidence: reasonable
cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues: 'false'
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false'
google-readability-namespace-comments.ShortNamespaceLines: '10'
google-readability-namespace-comments.SpacesBeforeComments: '2'
cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true'
cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths: 'true'
cppcoreguidelines-no-malloc.Allocations: '::malloc;::calloc'
cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true'
cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true'
cppcoreguidelines-prefer-member-initializer.UseAssignment: 'false'
cppcoreguidelines-explicit-virtual-functions.FinalSpelling: final
llvm-qualified-auto.AddConstToQualified: 'false'
modernize-loop-convert.NamingStyle: CamelCase
cppcoreguidelines-pro-type-member-init.UseAssignment: 'false'
cppcoreguidelines-init-variables.MathHeader: '\<math.h\>'
google-readability-function-size.StatementThreshold: '800'
llvm-else-after-return.WarnOnConditionVariables: 'false'
cppcoreguidelines-init-variables.IncludeStyle: llvm
modernize-pass-by-value.IncludeStyle: llvm
cppcoreguidelines-explicit-virtual-functions.OverrideSpelling: override
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'true'
modernize-use-nullptr.NullMacros: 'NULL'
cppcoreguidelines-no-malloc.Deallocations: '::free'
cppcoreguidelines-macro-usage.AllowedRegexp: '^DEBUG\_\*'
cppcoreguidelines-narrowing-conversions.PedanticMode: 'false'
llvm-else-after-return.WarnOnUnfixable: 'false'
...

when executing -verify-config:

command-line option '-config': warning: unknown check option 'clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic' [-verify-config]

How to change Pedantic option to true in .clang-tidy file?the description in optin-cplusplus-uninitializedobject is not clear for me

Am_A
  • 1
  • 1
  • 1
    From the docs, it looks like there should be a colon before `Pedantic` rather than a period. Did you try using a colon? – Scott McPeak Feb 07 '23 at 15:35
  • `:` doesn't work `/.clang-tidy:54:62: error: Found unexpected ':' while scanning a plain scalar - { key: clang-analyzer-optin.cplusplus.UninitializedObject:Pedantic, value: true }` – Am_A Feb 08 '23 at 10:13

0 Answers0