4 ms·
gcc and clang have optional warnings for some of these issues, without needing to use clang-tidy. For NULL, 0, and nullptr, gcc and clang already treat NULL as
by cpeterso 11y ago
gcc and clang have optional warnings for some of these issues, without needing to use clang-tidy.
For NULL, 0, and nullptr, gcc and clang already treat NULL as a magic __null value and -Wconversion-null (enabled by default) can warn about using NULL as a non-pointer value. gcc also can break 0-as-a-null-pointer with the -Wzero-as-null-pointer-constant flag. I had hoped to fix these warnings in Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=777515 https://bugzilla.mozilla.org/show_bug.cgi?id=777515) bug there were thousands of warnings because gcc warns about using NULL, not just 0.
For override, gcc has -Wsuggest-override and -Woverloaded-virtual warnings that may help here. clang has -Winconsistent-missing-override.
For uninitialized variables, gcc and clang have -Wuninitialized. However, gcc -Wuninitialized has historically reported a lot of false positives. Fortunately, recent gcc version moved the flakier uninitialized warnings to a new -Wmaybe-uninitialized flag. In my experience with Firefox, -Wmaybe-uninitialized warnings are false positives about 90% of the time. On the other hand, clang has a -Wsometimes-uninitialized which is reliable.
For bool++, clang has -Wdeprecated-increment-bool.
btw, clang does not document its warning flags, but some resources I've used are the http://fuckingclangwarnings.com/ http://fuckingclangwarnings.com/ reference, searching through clang's source code at https://github.com/llvm-mirror/clang/blob/master/include/clang/Basic/DiagnosticGroups.td https://github.com/llvm-mirror/clang/blob/master/include/cla..., and clang's -Weverything flag (which truly is everything, including contradictory warnings).