During COMPILERWARNING
analysis for Gcc family tools, such as Gcc and Clang,
TiCS can not always identify compiler warning violations based on the tool's warning messages. This can be caused by
a Gcc family tool of a certain version not providing a warning flag, usually specified inside a bracket, or we can call it a [-W] block,
after a warning message. Another possible cause is when the given warning flag is too generic such as [enabled by default]
or [-Wextra]
that can represent multiple specific warning flags. A generic warning flag should
be mapped to a more specific warning flag so that TICS can properly identify the violation for that compiler warning.
To solve this issue, we can add the mapping of these unidentifiable compiler warnings in the MISSINGWARNINGS
property of file rules.json
.
This rules.json file can be found in compiler warning rulesets of each Gcc family tool.
The MISSINGWARNINGS
property represents a list of mappings between Gcc warning message regex patterns to a specific warning flag as shown below:
{ "MISSINGWARNINGS" : [ { "WARNING_PATTERNS" : ["GccWarningMessageRegexPattern"], "WARNING_FLAG" : "GccWarningTypeStartingWithADash" }, { "WARNING_PATTERNS" : ["GccWarningMessageRegexPatternOne", "GccWarningMessageRegexPatternTwo"], "WARNING_FLAG" : "GccWarningTypeStartingWithADash" }, ] }
An example of these mappings is shown below:
{ "MISSINGWARNINGS" : [ { "WARNING_PATTERNS" : ["discards .*? qualifier"], "WARNING_FLAG" : "-Wdiscarded-qualifiers" }, { "WARNING_PATTERNS" : ["hides constructor for"], "WARNING_FLAG" : "-Wshadow" }, { "WARNING_PATTERNS" : ["casts away constness"], "WARNING_FLAG" : "-Wcast-qual" }, { "WARNING_PATTERNS" : ["_.+ redefined"], "WARNING_FLAG" : "-Wmacro-redefined" }, { "WARNING_PATTERNS" : ["#warning .*"], "WARNING_FLAG" : "-Wcpp" }, { "WARNING_PATTERNS" : [".*typedef.* was ignored in this declaration"], "WARNING_FLAG" : "-Wunused-local-typedefs" }, ] }