Giter Site home page Giter Site logo

compiler-warnings's Introduction

C/C++/Objective-C compiler warning flags collection and parsers

This project includes tools and lists to figure out all warning flags that clang compiler and GNU Compiler Collection have for C family languages (C, C++, and Objective-C). This also shows all aliases and warning flags that a certain flag enables (prefixed with "#" character) so that you can easily see which flag is enabled by what. There are also warning flags that do nothing for compatibility or deprecation reasons. They are suffixed with "# DUMMY switch" text.

The purpose of these collections is to make it more easy to use the static code analysis tools that compilers provide.

Clang warning flags

Clang includes -Weverything flag, that is not shown in these lists, that enables all warnings. Clang documentation provides reference for some of the diagnostic flags in Clang.

GCC warning flags

If you need a full list of GCC warning options, for a specific version of GCC that you have, you can run GCC with gcc --help=warnings to get that list. Otherwise some plain GCC warning options lists are available below:

Examining differences

One use case for these kinds of lists is to see what differences there are between different compilers and compiler versions. I have made available rudimentary compiler flag differences between two consequent compiler versions as diff-files, but for more specific differences you need to use some (visual) diff program, as shown below:

Some GCC 5 and 6 -Wall differences shown with meld

Development Build Status

This uses ANTLR as a parser generator with some supporting Python code to parse warning flags from actual compiler option data files. Other requirements are following (plus their dependencies):

Building

After you have installed all the requirements and are able to run ANTLR with antlr4 command, just use following commands in parsers/ directory to generate these lists yourself:

ninja
./parse-clang-diagnostic-groups.py <path-to-clang-source>/include/clang/Basic/DiagnosticGroups.td
./parse-gcc-warning-options.py <path-to-gcc-source>/gcc/{common.opt,c-family/c.opt}

And you'll get the list of all individual warning flags and their dependencies that are in the requested compiler version.

To generate filtered lists, you may use --top-level and --unique switches.

  • --top-level switch does not include warnings that are enabled by some other switch in the list.
  • --unique lists all warnings without any information what other warnings they enable. Diffs on this page are created from these files.

Tests

There are some unit tests testing the low level functionality. You may run time with ninja test command in parsers/ directory to verify that unit tests pass.

Processing git repositories

When parser gets a change that affects formatting or other output for multiple files these warning lists need to be recreated. There are process-clang-git.sh and process-gcc-git.sh scripts that take the git repository root as their first parameter and apply all different variants of these commands to create final text files.

compiler-warnings's People

Contributors

barro avatar pkolbus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.