Visit Mozilla.org

Building with static checking

From MDC

Note: This documentation describes features which are only available in the mozilla-central code repository. They are not present in CVS trunk or any released version of Firefox.

In addition to the normal errors and warnings provided by C++ compiler, there are often code patterns in Mozilla which are legal C++ but are nevertheless incorrect in various ways. Mozilla can now use a tool called Dehydra GCC to detect incorrect code and provide authors with instant feedback during the compile process.

[edit] Using Static Checking

Follow these steps to use static checking:

  • Build GCC with plugin support (see instructions on the Dehydra GCC page)
  • Build Dehydra GCC
  • Add the following line to your .mozconfig file:
CXX=/path/to/gcc-with-plugin-support/bin/g++
ac_add_options --with-static-checking=/path/to/gcc_dehydra.so

As each C++ file in Mozilla is built, g++ will pass compilation information to xpcom/analysis/static-checking.js. This script will perform Mozilla-specific code checking.

[edit] Annotations

The following macros are currently used to annotate classes: