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

Method analyse_ctu_info

addons/misra.py:4873–5008  ·  view source on GitHub ↗
(self, ctu_info_files)

Source from the content-addressed store, hash-verified

4871 return ctu_info
4872
4873 def analyse_ctu_info(self, ctu_info_files):
4874 all_typedef_info = {}
4875 all_tagname_info = {}
4876 all_macro_info = {}
4877 all_external_identifiers_decl = {}
4878 all_external_identifiers_def = {}
4879 all_internal_identifiers = {}
4880 all_local_identifiers = {}
4881 all_usage_files = {}
4882
4883 from cppcheckdata import Location
4884
4885 def is_different_location(loc1, loc2):
4886 return loc1['file'] != loc2['file'] or loc1['line'] != loc2['line']
4887
4888 def is_different_file(loc1, loc2):
4889 return loc1['file'] != loc2['file']
4890
4891 try:
4892 for filename in ctu_info_files:
4893 for line in open(filename, 'rt'):
4894 s = self.read_ctu_info_line(line)
4895 if s is None:
4896 continue
4897 summary_type = s.get('summary', '')
4898 summary_data = s.get('data', None)
4899
4900 if summary_type == 'MisraTypedefInfo':
4901 for new_typedef_info in summary_data:
4902 key = new_typedef_info['name']
4903 existing_typedef_info = all_typedef_info.get(key, None)
4904 if existing_typedef_info:
4905 if is_different_location(existing_typedef_info, new_typedef_info):
4906 self.reportError(Location(existing_typedef_info), 5, 6)
4907 self.reportError(Location(new_typedef_info), 5, 6)
4908 else:
4909 existing_typedef_info['used'] = existing_typedef_info['used'] or new_typedef_info['used']
4910 else:
4911 all_typedef_info[key] = new_typedef_info
4912
4913 if summary_type == 'MisraTagName':
4914 for new_tagname_info in summary_data:
4915 key = new_tagname_info['name']
4916 existing_tagname_info = all_tagname_info.get(key, None)
4917 if existing_tagname_info:
4918 if is_different_location(existing_tagname_info, new_tagname_info):
4919 self.reportError(Location(existing_tagname_info), 5, 7)
4920 self.reportError(Location(new_tagname_info), 5, 7)
4921 else:
4922 existing_tagname_info['used'] = existing_tagname_info['used'] or new_tagname_info['used']
4923 else:
4924 all_tagname_info[key] = new_tagname_info
4925
4926 if summary_type == 'MisraMacro':
4927 for new_macro in summary_data:
4928 key = new_macro['name']
4929 existing_macro = all_macro_info.get(key, None)
4930 if existing_macro:

Callers 1

mainFunction · 0.95

Calls 5

read_ctu_info_lineMethod · 0.95
reportErrorMethod · 0.95
LocationClass · 0.90
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected