* MISRA: Refactor many top level functions into a class
All the checker operations were implemented as individual functions. In
order to share data globals were used.
By refactoring all these into class methods data can be shared between
them without resorting to globals.
This change is scope only. No functional change for any of the methods.
Data is still shared via globals.
* MISRA: Refactor non-option globals into MisraChecker class
- Move all non-option global variables into the MisraChecker class
- Allows data to be shared among the class methods without needing
globals.
- Move global VERIFY_EXPECTED to class variable verify_expected
- Move global VERIFY_ACTUAL to class variable verify_actual
- Move global VIOLATIONS to class variable violations
- Move global suppressRules to class variable suppressedRules
- Move global suppressions to class variable dumpfileSuppressions
This refactoring is in anticipation of parsing and using the
suppressions added into the dump file by cppcheck.
Only variable naming and scope changed. No functional change for any of the
methods.
* MISRA: Restore original summary behavior
Version 1.84 introduced a regression in the behavior of the rule summary
output due to changes in the way multiple input files were handled.
The intended behavior of the summary was to output the total number of
violations after all files have been processed.
Commit aa831ce972 restored the input file
handling behavior but left summary behavior such that a summary output
was produced for each file that caused a violation instead of the total
number of violations after all files were processed.
Move the -verify logic up into the main loop so that the exit calls are
in the top level and restore the original behavior of the summary
output.
* MISRA: Support per file rule suppressions
Parse the suppressions list from cppcheck and extract MISRA rule strings from
the suppressions class by matching for errorId strings that begin with
'MISRA' or 'misra'. Extract the MISRA rule from those strings by
looking for a '_' or a '.' to separate rule numbers.
Store the rule number, filename, line number, and symbol name from the
suppression entry into a structure that allows for dictionary lookups
by the rule number and then the filename. All the line number
and symbol entries for that filename are are stored in list of tuples of
(line number, symbol name). A rule entry that has a value of None for
the filename is treated as a global suppression for all files. A
filename entry that has None for the rule items list is treated as a
suppression for the entire file. If the rule item list exist then it is
searched for matching line numbers.
Although symbol names are parsed and added int the list of rule items
they are not used for rule matching. Symbol names can include regular
expressions. Adding support for symbol names and regular expressions is
left as a future feature.
The existing global suppression method provided by the --suppress-rules
option is supported. Those rules are added into the suppressions
structure as if they were provided by the suppressions list as global
suppressions. ie A rule with a None for the filename value.
newer versions of git use a variable lenght proportional to the
repository size (9 for cppcheck)
remove old chomp helper function and make copying the revision
smarter to hopefully cover for edge case that needed it
isVariableDeclaration did not handle pointer to const pointer, or
pointer to volatile pointer. This resulted in FPs in examples like the
following:
class Fred {
public:
const char *const *data;
const char *const *getData() { return data; };
}
where cppcheck would say getData could be static, since it didn't
recognize const char *const *data as a variable declaration.
* PCRE: added pcre_study to improve regex matching speed.
* PCRE: catch return values from pcre_exec and return an error message in case it fails.
* Formatted the code. There are no functional changes intended.
* PCRE: decode internal PCRE error messages.
* Integrating comments from PR.
* PCRE: Use pcre_study() only in case PCRE_CONFIG_JIT is defined.
* PCRE: Fixed potential resource leak. In case prce_compile worked, but pcre_study() returns an error, the allocated resources by pcre_compile() can be freed.
* Make travis happy.
* PCRE: Improved output message format.
* PCRE: Attempt to be compliant to older PCRE versions and fix travis build.