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

后端 未结 2 1787
渐次进展
渐次进展 2021-01-03 22:23

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++ warn

相关标签:
2条回答
  • 2021-01-03 23:02

    Clang used to be very bad at documenting what was available. Though from release 4.0.0 on, they have fixed it. For older releases one can try or consult the source code. At the compiler-warnings page on Github you can find an extract of the warnings based upon the source code.

    So you can find the documentation over the latest flags at the documentation pages, as well as the matching documentation for a specific release at their release pages (4.0.0).

    Clang-cl has its own warning flags, of which the mapping can be found on its documentation

    0 讨论(0)
  • 2021-01-03 23:21

    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
      ]>;
    
    0 讨论(0)
提交回复
热议问题