Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What warnings are included in Clang's -Wall and -Wextra?

Tags:

I've found Clang's documentation to be quite poor. I haven't been able to find much of a list of available Clang warning flags. I'm interested particularly in C/C++ warnings, but this is a bit of a general issue.

GCC lists and describes warnings here, and also lists what is included in -Wall and -Wextra: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options

What warning flags are included with Clang's -Wall and -Wextra?

I can scour the Clang release notes for each version to see what new warning flags are introduced each time (e.g. http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html), but is there an easier list and/or description of Clang's warnings? This would be extremely useful. I need to know what is included in -Wall and what is not, so I can consider turning on those that are not.

(I know that -Weverything exists for Clang - might I have to resort to using that and just explicitly disabling the ones I don't like? More documentation would make this much more ideal.)

like image 866
Jetski S-type Avatar asked Jul 23 '14 07:07

Jetski S-type


People also ask

What are clang tidy warnings?

Clang-tidy is a standalone linter tool for checking C and C++ source code files. It provides an additional set of compiler warnings—called checks—that go above and beyond what is typically included in a C or C++ compiler.

What are clang tools?

Clang Tools are standalone command line (and potentially GUI) tools designed for use by C++ developers who are already using and enjoying Clang as their compiler. These tools provide developer-oriented functionality such as fast syntax checking, automatic formatting, refactoring, etc.

What is Clang C++?

clang is a C, C++, and Objective-C compiler which encompasses preprocessing, parsing, optimization, code generation, assembly, and linking. Depending on which high-level mode setting is passed, Clang will stop before doing a full link.


1 Answers

You can check the source code:

For example,

def : DiagGroup<"all", [Most, Parentheses, Switch]>;  // Warnings enabled by -pedantic.  This is magically filled in by TableGen. def Pedantic : DiagGroup<"pedantic">;  // Aliases. def : DiagGroup<"", [Extra]>;                   // -W = -Wextra 

For -Wall look at the Most, Parentheses, Switch. You can find:

def Most : DiagGroup<"most", [  .... 

further down the file. Similarly, for extra:

def Extra : DiagGroup<"extra", [     MissingFieldInitializers,     IgnoredQualifiers,     InitializerOverrides,     SemiBeforeMethodBody,     MissingMethodReturnType,     SignCompare,     UnusedParameter   ]>; 
like image 134
perreal Avatar answered Dec 28 '22 09:12

perreal