Skip to content

Commit

Permalink
Addons; split up possible/known values and impossible values. This is…
Browse files Browse the repository at this point in the history
… inconsistent with core Cppcheck, however the addons do not handle impossible values in general. A future improvement might be to clarify this somehow, maybe renaming Token.values.
  • Loading branch information
danmar committed Feb 23, 2021
1 parent fc1cfba commit 22727ee
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions addons/cppcheckdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ class Token:
variable Variable information for this token. See the Variable class.
function If this token points at a function call, this attribute has the Function
information. See the Function class.
values Possible values of token
values Possible/Known values of token
impossible_values Impossible values of token
valueType type information
typeScope type scope (token->type()->classScope)
astParent ast parent
Expand Down Expand Up @@ -198,6 +199,7 @@ class Token:
function = None
valuesId = None
values = None
impossible_values = None
valueType = None

typeScopeId = None
Expand Down Expand Up @@ -299,7 +301,14 @@ def setId(self, IdMap):
self.link = IdMap[self.linkId]
self.variable = IdMap[self.variableId]
self.function = IdMap[self.functionId]
self.values = IdMap[self.valuesId]
self.values = []
self.impossible_values = []
if IdMap[self.valuesId]:
for v in IdMap[self.valuesId]:
if v.isImpossible():
self.impossible_values.append(v)
else:
self.values.append(v)
self.typeScope = IdMap[self.typeScopeId]
self.astParent = IdMap[self.astParentId]
self.astOperand1 = IdMap[self.astOperand1Id]
Expand Down Expand Up @@ -571,6 +580,9 @@ def isKnown(self):
def isPossible(self):
return self.valueKind and self.valueKind == 'possible'

def isImpossible(self):
return self.valueKind and self.valueKind == 'impossible'

def __init__(self, element):
self.intvalue = element.get('intvalue')
if self.intvalue:
Expand All @@ -585,6 +597,8 @@ def __init__(self, element):
self.valueKind = 'known'
elif element.get('possible'):
self.valueKind = 'possible'
elif element.get('impossible'):
self.valueKind = 'impossible'
if element.get('inconclusive'):
self.inconclusive = True

Expand Down

0 comments on commit 22727ee

Please sign in to comment.