MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / parseDump

Method parseDump

addons/misra.py:4668–4858  ·  view source on GitHub ↗
(self, dumpfile, path_premium_addon=None)

Source from the content-addressed store, hash-verified

4666 check_function(*args)
4667
4668 def parseDump(self, dumpfile, path_premium_addon=None):
4669 def fillVerifyExpected(verify_expected, tok):
4670 """Add expected suppressions to verify_expected list."""
4671 rule_re = re.compile(r'[0-9]+\.[0-9]+')
4672 if tok.str.startswith('//') and 'TODO' not in tok.str:
4673 for word in tok.str[2:].split(' '):
4674 if rule_re.match(word) or word == "config":
4675 verify_expected.append('%s:%d %s' % (tok.file, tok.linenr, word))
4676
4677 data = cppcheckdata.parsedump(dumpfile)
4678 typeBits['CHAR'] = data.platform.char_bit
4679 typeBits['SHORT'] = data.platform.short_bit
4680 typeBits['INT'] = data.platform.int_bit
4681 typeBits['LONG'] = data.platform.long_bit
4682 typeBits['LONG_LONG'] = data.platform.long_long_bit
4683 typeBits['POINTER'] = data.platform.pointer_bit
4684
4685 if self.settings.verify:
4686 # Add suppressions from the current file
4687 for tok in data.rawTokens:
4688 fillVerifyExpected(self.verify_expected, tok)
4689 # Add suppressions from the included headers
4690 include_re = re.compile(r'^#include [<"]([a-zA-Z0-9]+[a-zA-Z\-_./\\0-9]*)[">]$')
4691 dump_dir = os.path.dirname(data.filename)
4692 for conf in data.configurations:
4693 for directive in conf.directives:
4694 m = re.match(include_re, directive.str)
4695 if not m:
4696 continue
4697 header_dump_path = os.path.join(dump_dir, m.group(1) + '.dump')
4698 if not os.path.exists(header_dump_path):
4699 continue
4700 header_data = cppcheckdata.parsedump(header_dump_path)
4701 for tok in header_data.rawTokens:
4702 fillVerifyExpected(self.verify_expected, tok)
4703 else:
4704 self.printStatus('Checking ' + dumpfile + '...')
4705
4706 self.is_cpp = data.language == 'cpp'
4707
4708 for cfgNumber, cfg in enumerate(data.iterconfigurations()):
4709 if not self.settings.quiet:
4710 self.printStatus('Checking %s, config %s...' % (dumpfile, cfg.name))
4711
4712 self.executeCheck(102, self.misra_1_2, cfg)
4713 if not path_premium_addon:
4714 self.executeCheck(104, self.misra_1_4, cfg)
4715 self.executeCheck(202, self.misra_2_2, cfg)
4716 self.executeCheck(203, self.misra_2_3, dumpfile, cfg.typedefInfo)
4717 self.executeCheck(204, self.misra_2_4, dumpfile, cfg)
4718 self.executeCheck(205, self.misra_2_5, dumpfile, cfg)
4719 self.executeCheck(207, self.misra_2_7, cfg)
4720 # data.rawTokens is same for all configurations
4721 if cfgNumber == 0:
4722 self.executeCheck(301, self.misra_3_1, data.rawTokens)
4723 #self.executeCheck(302, self.misra_3_2, data.rawTokens)
4724 self.executeCheck(401, self.misra_4_1, data.rawTokens)
4725 self.executeCheck(402, self.misra_4_2, data.rawTokens)

Callers 6

mainFunction · 0.95
test_json_outFunction · 0.80
test_rules_suppressionFunction · 0.80
test_platformFunction · 0.80

Calls 8

printStatusMethod · 0.95
executeCheckMethod · 0.95
misra_configMethod · 0.95
compileMethod · 0.80
iterconfigurationsMethod · 0.80
matchMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45

Tested by 5

test_json_outFunction · 0.64
test_rules_suppressionFunction · 0.64
test_platformFunction · 0.64