dump: Read platform info from dump file
This commit is contained in:
parent
ef416d318e
commit
dd8b96f4c8
|
@ -478,6 +478,38 @@ class Configuration:
|
||||||
variable.setId(IdMap)
|
variable.setId(IdMap)
|
||||||
|
|
||||||
|
|
||||||
|
class Platform:
|
||||||
|
"""
|
||||||
|
Platform class
|
||||||
|
This class contains type sizes
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
name Name of the platform
|
||||||
|
char_bit CHAR_BIT value
|
||||||
|
short_bit SHORT_BIT value
|
||||||
|
int_bit INT_BIT value
|
||||||
|
long_bit LONG_BIT value
|
||||||
|
long_long_bit LONG_LONG_BIT value
|
||||||
|
pointer_bit POINTER_BIT value
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = ''
|
||||||
|
char_bit = 0
|
||||||
|
short_bit = 0
|
||||||
|
int_bit = 0
|
||||||
|
long_bit = 0
|
||||||
|
long_long_bit = 0
|
||||||
|
pointer_bit = 0
|
||||||
|
|
||||||
|
def __init__(self, platformnode):
|
||||||
|
self.name = platformnode.get('name')
|
||||||
|
self.char_bit = int(platformnode.get('char_bit'))
|
||||||
|
self.short_bit = int(platformnode.get('short_bit'))
|
||||||
|
self.int_bit = int(platformnode.get('int_bit'))
|
||||||
|
self.long_bit = int(platformnode.get('long_bit'))
|
||||||
|
self.long_long_bit = int(platformnode.get('long_long_bit'))
|
||||||
|
self.pointer_bit = int(platformnode.get('pointer_bit'))
|
||||||
|
|
||||||
|
|
||||||
class CppcheckData:
|
class CppcheckData:
|
||||||
"""
|
"""
|
||||||
|
@ -516,6 +548,7 @@ class CppcheckData:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
rawTokens = []
|
rawTokens = []
|
||||||
|
platform = None
|
||||||
configurations = []
|
configurations = []
|
||||||
|
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
@ -523,6 +556,10 @@ class CppcheckData:
|
||||||
|
|
||||||
data = ET.parse(filename)
|
data = ET.parse(filename)
|
||||||
|
|
||||||
|
for platformNode in data.getroot():
|
||||||
|
if platformNode.tag == 'platform':
|
||||||
|
self.platform = Platform(platformNode)
|
||||||
|
|
||||||
for rawTokensNode in data.getroot():
|
for rawTokensNode in data.getroot():
|
||||||
if rawTokensNode.tag != 'rawtokens':
|
if rawTokensNode.tag != 'rawtokens':
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -33,10 +33,12 @@ def simpleMatch(token, pattern):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Platform
|
# Platform
|
||||||
# TODO get this from dump
|
CHAR_BIT = 0
|
||||||
CHAR_BITS = 8
|
SHORT_BIT = 0
|
||||||
SHORT_BITS = 16
|
INT_BIT = 0
|
||||||
INT_BITS = 32
|
LONG_BIT = 0
|
||||||
|
LONG_LONG_BIT = 0
|
||||||
|
POINTER_BIT = 0
|
||||||
|
|
||||||
KEYWORDS = ['auto',
|
KEYWORDS = ['auto',
|
||||||
'break',
|
'break',
|
||||||
|
@ -86,13 +88,12 @@ def bitsOfEssentialType(expr):
|
||||||
type = getEssentialType(expr)
|
type = getEssentialType(expr)
|
||||||
if type is None:
|
if type is None:
|
||||||
return 0
|
return 0
|
||||||
# TODO get --platform type sizes
|
|
||||||
if type == 'char':
|
if type == 'char':
|
||||||
return CHAR_BITS
|
return CHAR_BIT
|
||||||
if type == 'short':
|
if type == 'short':
|
||||||
return SHORT_BITS
|
return SHORT_BIT
|
||||||
if type == 'int':
|
if type == 'int':
|
||||||
return INT_BITS
|
return INT_BIT
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def isFunctionCall(expr):
|
def isFunctionCall(expr):
|
||||||
|
@ -316,9 +317,9 @@ def misra_12_3(data):
|
||||||
|
|
||||||
def misra_12_4(data):
|
def misra_12_4(data):
|
||||||
max_uint = 0
|
max_uint = 0
|
||||||
if INT_BITS == 16:
|
if INT_BIT == 16:
|
||||||
max_uint = 0xffff
|
max_uint = 0xffff
|
||||||
elif INT_BITS == 32:
|
elif INT_BIT == 32:
|
||||||
max_uint = 0xffffffff
|
max_uint = 0xffffffff
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
@ -686,6 +687,13 @@ for arg in sys.argv[1:]:
|
||||||
|
|
||||||
data = cppcheckdata.parsedump(arg)
|
data = cppcheckdata.parsedump(arg)
|
||||||
|
|
||||||
|
CHAR_BIT = data.platform.char_bit
|
||||||
|
SHORT_BIT = data.platform.short_bit
|
||||||
|
INT_BIT = data.platform.int_bit
|
||||||
|
LONG_BIT = data.platform.long_bit
|
||||||
|
LONG_LONG_BIT = data.platform.long_long_bit
|
||||||
|
POINTER_BIT = data.platform.pointer_bit
|
||||||
|
|
||||||
if VERIFY:
|
if VERIFY:
|
||||||
VERIFY_ACTUAL = []
|
VERIFY_ACTUAL = []
|
||||||
VERIFY_EXPECTED = []
|
VERIFY_EXPECTED = []
|
||||||
|
|
Loading…
Reference in New Issue