misra; implemented rule 8.5
This commit is contained in:
parent
27bd543566
commit
aa910d3c38
|
@ -1217,16 +1217,18 @@ def ArgumentParser():
|
||||||
|
|
||||||
def get_files(args):
|
def get_files(args):
|
||||||
"""Return dump_files, ctu_info_files"""
|
"""Return dump_files, ctu_info_files"""
|
||||||
dump_files = args.dumpfile
|
all_files = args.dumpfile
|
||||||
ctu_info_files = []
|
|
||||||
if args.file_list:
|
if args.file_list:
|
||||||
with open(args.file_list, 'rt') as f:
|
with open(args.file_list, 'rt') as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
line = line.rstrip()
|
all_files.append(line.rstrip())
|
||||||
if line.endswith('.ctu-info'):
|
dump_files = []
|
||||||
ctu_info_files.append(line)
|
ctu_info_files = []
|
||||||
|
for f in all_files:
|
||||||
|
if f.endswith('.ctu-info'):
|
||||||
|
ctu_info_files.append(f)
|
||||||
else:
|
else:
|
||||||
dump_files.append(line)
|
dump_files.append(f)
|
||||||
return dump_files, ctu_info_files
|
return dump_files, ctu_info_files
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3611,6 +3611,9 @@ class MisraChecker:
|
||||||
|
|
||||||
from cppcheckdata import Location
|
from cppcheckdata import Location
|
||||||
|
|
||||||
|
def is_different_location(loc1, loc2):
|
||||||
|
return loc1['file'] != loc2['file'] or loc1['line'] != loc2['line']
|
||||||
|
|
||||||
for filename in ctu_info_files:
|
for filename in ctu_info_files:
|
||||||
for line in open(filename, 'rt'):
|
for line in open(filename, 'rt'):
|
||||||
if not line.startswith('{'):
|
if not line.startswith('{'):
|
||||||
|
@ -3626,7 +3629,7 @@ class MisraChecker:
|
||||||
for old_typedef_info in all_typedef_info:
|
for old_typedef_info in all_typedef_info:
|
||||||
if old_typedef_info['name'] == new_typedef_info['name']:
|
if old_typedef_info['name'] == new_typedef_info['name']:
|
||||||
found = True
|
found = True
|
||||||
if old_typedef_info['file'] != new_typedef_info['file'] or old_typedef_info['line'] != new_typedef_info['line']:
|
if is_different_location(old_typedef_info, new_typedef_info):
|
||||||
self.reportError(Location(old_typedef_info), 5, 6)
|
self.reportError(Location(old_typedef_info), 5, 6)
|
||||||
self.reportError(Location(new_typedef_info), 5, 6)
|
self.reportError(Location(new_typedef_info), 5, 6)
|
||||||
else:
|
else:
|
||||||
|
@ -3642,7 +3645,7 @@ class MisraChecker:
|
||||||
for old_tagname_info in all_tagname_info:
|
for old_tagname_info in all_tagname_info:
|
||||||
if old_tagname_info['name'] == new_tagname_info['name']:
|
if old_tagname_info['name'] == new_tagname_info['name']:
|
||||||
found = True
|
found = True
|
||||||
if old_tagname_info['file'] != new_tagname_info['file'] or old_tagname_info['line'] != new_tagname_info['line']:
|
if is_different_location(old_tagname_info, new_tagname_info):
|
||||||
self.reportError(Location(old_tagname_info), 5, 7)
|
self.reportError(Location(old_tagname_info), 5, 7)
|
||||||
self.reportError(Location(new_tagname_info), 5, 7)
|
self.reportError(Location(new_tagname_info), 5, 7)
|
||||||
else:
|
else:
|
||||||
|
@ -3664,8 +3667,11 @@ class MisraChecker:
|
||||||
if not found:
|
if not found:
|
||||||
all_macro_info.append(new_macro)
|
all_macro_info.append(new_macro)
|
||||||
|
|
||||||
if summary_type == 'MisraGlobalIdentifiers':
|
if summary_type == 'MisraExternalIdentifiers':
|
||||||
for s in summary_data:
|
for s in summary_data:
|
||||||
|
if s['name'] in all_external_identifiers and is_different_location(s, all_external_identifiers[s['name']]):
|
||||||
|
self.reportError(Location(s), 8, 5)
|
||||||
|
self.reportError(Location(all_external_identifiers[s['name']]), 8, 5)
|
||||||
all_external_identifiers[s['name']] = s
|
all_external_identifiers[s['name']] = s
|
||||||
|
|
||||||
if summary_type == 'MisraInternalIdentifiers':
|
if summary_type == 'MisraInternalIdentifiers':
|
||||||
|
|
|
@ -29,3 +29,7 @@ static void misra_5_8_f(void) {}
|
||||||
static int misra_5_9_count;
|
static int misra_5_9_count;
|
||||||
// cppcheck-suppress misra-c2012-5.9
|
// cppcheck-suppress misra-c2012-5.9
|
||||||
static void misra_5_8_foo(void) {}
|
static void misra_5_8_foo(void) {}
|
||||||
|
|
||||||
|
// cppcheck-suppress misra-c2012-8.4
|
||||||
|
// cppcheck-suppress misra-c2012-8.5
|
||||||
|
extern int misra_8_5;
|
||||||
|
|
|
@ -30,3 +30,7 @@ void misra_5_8_f(void) {
|
||||||
static int misra_5_9_count;
|
static int misra_5_9_count;
|
||||||
// cppcheck-suppress misra-c2012-5.9
|
// cppcheck-suppress misra-c2012-5.9
|
||||||
static void misra_5_8_foo(void) {}
|
static void misra_5_8_foo(void) {}
|
||||||
|
|
||||||
|
// cppcheck-suppress misra-c2012-8.4
|
||||||
|
// cppcheck-suppress misra-c2012-8.5
|
||||||
|
extern int misra_8_5;
|
||||||
|
|
Loading…
Reference in New Issue