From 22727ee3abe1dd2a00d956e815a6a6b89c6f7ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 23 Feb 2021 22:40:49 +0100 Subject: [PATCH] Addons; split up possible/known values and impossible values. This is 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. --- addons/cppcheckdata.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index 2752a6d35..aaddd31ff 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -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 @@ -198,6 +199,7 @@ class Token: function = None valuesId = None values = None + impossible_values = None valueType = None typeScopeId = None @@ -299,7 +301,14 @@ class Token: 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] @@ -571,6 +580,9 @@ class Value: 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: @@ -585,6 +597,8 @@ class Value: self.valueKind = 'known' elif element.get('possible'): self.valueKind = 'possible' + elif element.get('impossible'): + self.valueKind = 'impossible' if element.get('inconclusive'): self.inconclusive = True