Update cppcheckdata.py (#5149)
* Update cppcheckdata.py - added links to cpp-file/function that writes this part of the dump-file - updated documentation (Added list of possible return values for a number of variables) - added MacroUsage isKnownValue - added ValueType reference - added Token isBoolean - added Token isCast - added Token externLang - added Token isComplex - added Token isRestrict - added Token isAttributeExport - added Token originalName - added Scope functions - added Scope definedType - added Function hasVirtualSpecifier - removed Function isVirtual - added Function isAttributeNoreturn - added Function overriddenFunction - added Variable isVolatile - class Container added - added Value movedValue - added Value uninit - added Value bufferSize - removed Value inconclusive and added it to valueKind * Update cppcheckdata.py removed encoding from open (needed to make python 2.7 check pass) where python 2.7 should not be used anymore * Update cppcheckdata.py after feedback made sure that attributes I added to the class always have a value added some missing attributes in the print
This commit is contained in:
parent
b462d070bf
commit
b689ca8d89
|
@ -76,6 +76,7 @@ class Directive:
|
||||||
print(directive.str)
|
print(directive.str)
|
||||||
@endcode
|
@endcode
|
||||||
"""
|
"""
|
||||||
|
#preprocessor.cpp/Preprocessor::dump
|
||||||
|
|
||||||
str = None
|
str = None
|
||||||
file = None
|
file = None
|
||||||
|
@ -96,7 +97,15 @@ class Directive:
|
||||||
class MacroUsage:
|
class MacroUsage:
|
||||||
"""
|
"""
|
||||||
Tracks preprocessor macro usage
|
Tracks preprocessor macro usage
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
name Name of the macro
|
||||||
|
usefile
|
||||||
|
useline
|
||||||
|
usecolumn
|
||||||
|
isKnownValue
|
||||||
"""
|
"""
|
||||||
|
#preprocessor.cpp/Preprocessor::dump
|
||||||
|
|
||||||
name = None # Macro name
|
name = None # Macro name
|
||||||
file = None
|
file = None
|
||||||
|
@ -112,9 +121,10 @@ class MacroUsage:
|
||||||
self.usefile = element.get('usefile')
|
self.usefile = element.get('usefile')
|
||||||
self.useline = element.get('useline')
|
self.useline = element.get('useline')
|
||||||
self.usecolumn = element.get('usecolumn')
|
self.usecolumn = element.get('usecolumn')
|
||||||
|
self.isKnownValue = element.get('is-known-value', 'false') == 'true'
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["name", "file", "linenr", "column", "usefile", "useline", "usecolumn"]
|
attrs = ["name", "file", "linenr", "column", "usefile", "useline", "usecolumn", "isKnownValue"]
|
||||||
return "{}({})".format(
|
return "{}({})".format(
|
||||||
"MacroUsage",
|
"MacroUsage",
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
|
@ -124,7 +134,12 @@ class MacroUsage:
|
||||||
class PreprocessorIfCondition:
|
class PreprocessorIfCondition:
|
||||||
"""
|
"""
|
||||||
Information about #if/#elif conditions
|
Information about #if/#elif conditions
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
E
|
||||||
|
result
|
||||||
"""
|
"""
|
||||||
|
#preprocessor.cpp/Preprocessor::dump
|
||||||
|
|
||||||
file = None
|
file = None
|
||||||
linenr = None
|
linenr = None
|
||||||
|
@ -144,11 +159,22 @@ class PreprocessorIfCondition:
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ValueType:
|
class ValueType:
|
||||||
"""
|
"""
|
||||||
ValueType class. Contains (promoted) type information for each node in the AST.
|
ValueType class. Contains (promoted) type information for each node in the AST.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
type nonstd/pod/record/smart-pointer/container/iterator/void/bool/char/short/wchar_t/int/long/long long/unknown int/float/double/long double
|
||||||
|
sign signed/unsigned
|
||||||
|
bits
|
||||||
|
pointer
|
||||||
|
constness
|
||||||
|
reference
|
||||||
|
typeScopeId
|
||||||
|
originalTypeName bool/const char */long/char */size_t/int/double/std::string/..
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
#symboldatabase.cpp/ValueType::dump
|
||||||
|
|
||||||
type = None
|
type = None
|
||||||
sign = None
|
sign = None
|
||||||
|
@ -163,10 +189,13 @@ class ValueType:
|
||||||
self.type = element.get('valueType-type')
|
self.type = element.get('valueType-type')
|
||||||
self.sign = element.get('valueType-sign')
|
self.sign = element.get('valueType-sign')
|
||||||
self.bits = int(element.get('valueType-bits', 0))
|
self.bits = int(element.get('valueType-bits', 0))
|
||||||
|
self.pointer = int(element.get('valueType-pointer', 0))
|
||||||
|
self.constness = int(element.get('valueType-constness', 0))
|
||||||
|
self.reference = element.get('valueType-reference')
|
||||||
self.typeScopeId = element.get('valueType-typeScope')
|
self.typeScopeId = element.get('valueType-typeScope')
|
||||||
self.originalTypeName = element.get('valueType-originalTypeName')
|
self.originalTypeName = element.get('valueType-originalTypeName')
|
||||||
self.constness = int(element.get('valueType-constness', 0))
|
#valueType-containerId TODO add
|
||||||
self.pointer = int(element.get('valueType-pointer', 0))
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName",
|
attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName",
|
||||||
|
@ -206,36 +235,44 @@ class Token:
|
||||||
corresponding '}', ']' and ')'. For templates, the '<' is linked to
|
corresponding '}', ']' and ')'. For templates, the '<' is linked to
|
||||||
the corresponding '>'.
|
the corresponding '>'.
|
||||||
scope Scope information for this token. See the Scope class.
|
scope Scope information for this token. See the Scope class.
|
||||||
|
type Type information: name/op/number/string/..
|
||||||
isName Is this token a symbol name
|
isName Is this token a symbol name
|
||||||
|
isUnsigned Is this token a unsigned type
|
||||||
|
isSigned Is this token a signed type
|
||||||
isNumber Is this token a number, for example 123, 12.34
|
isNumber Is this token a number, for example 123, 12.34
|
||||||
isInt Is this token a int value such as 1234
|
isInt Is this token a int value such as 1234
|
||||||
isFloat Is this token a float value such as 12.34
|
isFloat Is this token a float value such as 12.34
|
||||||
isString Is this token a string literal such as "hello"
|
isString Is this token a string literal such as "hello"
|
||||||
strlen string length for string literal
|
strlen string length for string literal
|
||||||
isChar Is this token a char literal such as 'x'
|
isChar Is this token a char literal such as 'x'
|
||||||
|
isBoolean Is this token a boolean
|
||||||
isOp Is this token a operator
|
isOp Is this token a operator
|
||||||
isArithmeticalOp Is this token a arithmetic operator
|
isArithmeticalOp Is this token a arithmetic operator
|
||||||
isAssignmentOp Is this token a assignment operator
|
isAssignmentOp Is this token a assignment operator
|
||||||
isComparisonOp Is this token a comparison operator
|
isComparisonOp Is this token a comparison operator
|
||||||
isLogicalOp Is this token a logical operator: && ||
|
isLogicalOp Is this token a logical operator: && ||
|
||||||
isUnsigned Is this token a unsigned type
|
isCast
|
||||||
isSigned Is this token a signed type
|
externLang
|
||||||
isExpandedMacro Is this token a expanded macro token
|
isExpandedMacro Is this token a expanded macro token
|
||||||
isRemovedVoidParameter Has void parameter been removed?
|
isRemovedVoidParameter Has void parameter been removed?
|
||||||
isSplittedVarDeclComma Is this a comma changed to semicolon in a split variable declaration ('int a,b;' => 'int a; int b;')
|
isSplittedVarDeclComma Is this a comma changed to semicolon in a split variable declaration ('int a,b;' => 'int a; int b;')
|
||||||
isSplittedVarDeclEq Is this a '=' changed to semicolon in a split variable declaration ('int a=5;' => 'int a; a=5;')
|
isSplittedVarDeclEq Is this a '=' changed to semicolon in a split variable declaration ('int a=5;' => 'int a; a=5;')
|
||||||
isImplicitInt Is this token an implicit "int"?
|
isImplicitInt Is this token an implicit "int"?
|
||||||
|
isComplex
|
||||||
|
isRestrict
|
||||||
|
isAttributeExport
|
||||||
varId varId for token, each variable has a unique non-zero id
|
varId varId for token, each variable has a unique non-zero id
|
||||||
|
exprId exprId for token, each expression has a unique non-zero id
|
||||||
variable Variable information for this token. See the Variable class.
|
variable Variable information for this token. See the Variable class.
|
||||||
function If this token points at a function call, this attribute has the Function
|
function If this token points at a function call, this attribute has the Function
|
||||||
information. See the Function class.
|
information. See the Function class.
|
||||||
values Possible/Known values of token
|
values Possible/Known values of token
|
||||||
impossible_values Impossible values of token
|
|
||||||
valueType type information
|
|
||||||
typeScope type scope (token->type()->classScope)
|
typeScope type scope (token->type()->classScope)
|
||||||
astParent ast parent
|
astParent ast parent
|
||||||
astOperand1 ast operand1
|
astOperand1 ast operand1
|
||||||
astOperand2 ast operand2
|
astOperand2 ast operand2
|
||||||
|
orriginalName orriginal name of the token
|
||||||
|
valueType type information: container/..
|
||||||
file file name
|
file file name
|
||||||
linenr line number
|
linenr line number
|
||||||
column column
|
column column
|
||||||
|
@ -250,6 +287,7 @@ class Token:
|
||||||
print(code)
|
print(code)
|
||||||
@endcode
|
@endcode
|
||||||
"""
|
"""
|
||||||
|
#tokenize.cpp/Tokenizer::dump
|
||||||
|
|
||||||
Id = None
|
Id = None
|
||||||
str = None
|
str = None
|
||||||
|
@ -266,11 +304,13 @@ class Token:
|
||||||
isString = False
|
isString = False
|
||||||
strlen = None
|
strlen = None
|
||||||
isChar = False
|
isChar = False
|
||||||
|
isBoolean = False
|
||||||
isOp = False
|
isOp = False
|
||||||
isArithmeticalOp = False
|
isArithmeticalOp = False
|
||||||
isAssignmentOp = False
|
isAssignmentOp = False
|
||||||
isComparisonOp = False
|
isComparisonOp = False
|
||||||
isLogicalOp = False
|
isLogicalOp = False
|
||||||
|
isCast = False
|
||||||
isUnsigned = False
|
isUnsigned = False
|
||||||
isSigned = False
|
isSigned = False
|
||||||
isExpandedMacro = False
|
isExpandedMacro = False
|
||||||
|
@ -278,6 +318,9 @@ class Token:
|
||||||
isSplittedVarDeclComma = False
|
isSplittedVarDeclComma = False
|
||||||
isSplittedVarDeclEq = False
|
isSplittedVarDeclEq = False
|
||||||
isImplicitInt = False
|
isImplicitInt = False
|
||||||
|
isComplex = False
|
||||||
|
isRestrict = False
|
||||||
|
isAttributeExport = False
|
||||||
exprId = None
|
exprId = None
|
||||||
varId = None
|
varId = None
|
||||||
variableId = None
|
variableId = None
|
||||||
|
@ -328,6 +371,8 @@ class Token:
|
||||||
self.strlen = int(element.get('strlen'))
|
self.strlen = int(element.get('strlen'))
|
||||||
elif type == 'char':
|
elif type == 'char':
|
||||||
self.isChar = True
|
self.isChar = True
|
||||||
|
elif type == 'boolean':
|
||||||
|
self.isBoolean = True
|
||||||
elif type == 'op':
|
elif type == 'op':
|
||||||
self.isOp = True
|
self.isOp = True
|
||||||
if element.get('isArithmeticalOp'):
|
if element.get('isArithmeticalOp'):
|
||||||
|
@ -338,6 +383,9 @@ class Token:
|
||||||
self.isComparisonOp = True
|
self.isComparisonOp = True
|
||||||
elif element.get('isLogicalOp'):
|
elif element.get('isLogicalOp'):
|
||||||
self.isLogicalOp = True
|
self.isLogicalOp = True
|
||||||
|
if element.get('isCast'):
|
||||||
|
self.isCast = True
|
||||||
|
self.externLang = element.get('externLang')
|
||||||
if element.get('isExpandedMacro'):
|
if element.get('isExpandedMacro'):
|
||||||
self.isExpandedMacro = True
|
self.isExpandedMacro = True
|
||||||
if element.get('isRemovedVoidParameter'):
|
if element.get('isRemovedVoidParameter'):
|
||||||
|
@ -348,6 +396,12 @@ class Token:
|
||||||
self.isSplittedVarDeclEq = True
|
self.isSplittedVarDeclEq = True
|
||||||
if element.get('isImplicitInt'):
|
if element.get('isImplicitInt'):
|
||||||
self.isImplicitInt = True
|
self.isImplicitInt = True
|
||||||
|
if element.get('isComplex'):
|
||||||
|
self.isComplex = True
|
||||||
|
if element.get('isRestrict'):
|
||||||
|
self.isRestrict = True
|
||||||
|
if element.get('isAttributeExport'):
|
||||||
|
self.isAttributeExport = True
|
||||||
self.linkId = element.get('link')
|
self.linkId = element.get('link')
|
||||||
self.link = None
|
self.link = None
|
||||||
if element.get('varId'):
|
if element.get('varId'):
|
||||||
|
@ -360,10 +414,6 @@ class Token:
|
||||||
self.function = None
|
self.function = None
|
||||||
self.valuesId = element.get('values')
|
self.valuesId = element.get('values')
|
||||||
self.values = None
|
self.values = None
|
||||||
if element.get('valueType-type'):
|
|
||||||
self.valueType = ValueType(element)
|
|
||||||
else:
|
|
||||||
self.valueType = None
|
|
||||||
self.typeScopeId = element.get('type-scope')
|
self.typeScopeId = element.get('type-scope')
|
||||||
self.typeScope = None
|
self.typeScope = None
|
||||||
self.astParentId = element.get('astParent')
|
self.astParentId = element.get('astParent')
|
||||||
|
@ -372,15 +422,21 @@ class Token:
|
||||||
self.astOperand1 = None
|
self.astOperand1 = None
|
||||||
self.astOperand2Id = element.get('astOperand2')
|
self.astOperand2Id = element.get('astOperand2')
|
||||||
self.astOperand2 = None
|
self.astOperand2 = None
|
||||||
|
self.originalName = element.get('originalName')
|
||||||
|
if element.get('valueType-type'):
|
||||||
|
self.valueType = ValueType(element)
|
||||||
|
else:
|
||||||
|
self.valueType = None
|
||||||
_load_location(self, element)
|
_load_location(self, element)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["Id", "str", "scopeId", "isName", "isUnsigned", "isSigned",
|
attrs = ["Id", "str", "scopeId", "isName", "isUnsigned", "isSigned",
|
||||||
"isNumber", "isInt", "isFloat", "isString", "strlen",
|
"isNumber", "isInt", "isFloat", "isString", "strlen",
|
||||||
"isChar", "isOp", "isArithmeticalOp", "isComparisonOp",
|
"isChar", "isBoolean", "isOp", "isArithmeticalOp", "isAssignmentOp",
|
||||||
"isLogicalOp", "isExpandedMacro", "isSplittedVarDeclComma",
|
"isComparisonOp", "isLogicalOp", "isCast", "externLang", "isExpandedMacro",
|
||||||
"isSplittedVarDeclEq", "isImplicitInt", "linkId", "varId",
|
"isRemovedVoidParameter", "isSplittedVarDeclComma", "isSplittedVarDeclEq",
|
||||||
"variableId", "functionId", "valuesId", "valueType",
|
"isImplicitInt", "isComplex", "isRestrict", "isAttributeExport", "linkId",
|
||||||
|
"varId", "variableId", "functionId", "valuesId", "valueType",
|
||||||
"typeScopeId", "astParentId", "astOperand1Id", "file",
|
"typeScopeId", "astParentId", "astOperand1Id", "file",
|
||||||
"linenr", "column"]
|
"linenr", "column"]
|
||||||
return "{}({})".format(
|
return "{}({})".format(
|
||||||
|
@ -492,8 +548,13 @@ class Scope:
|
||||||
For a class scope, this is the class name.
|
For a class scope, this is the class name.
|
||||||
function If this scope belongs at a function call, this attribute
|
function If this scope belongs at a function call, this attribute
|
||||||
has the Function information. See the Function class.
|
has the Function information. See the Function class.
|
||||||
type Type of scope: Global, Function, Class, If, While
|
functions if this is a Class type, it may have functions defined
|
||||||
|
nestedIn
|
||||||
|
type Type of scope: Function, If/Else/For/While/Switch/Global/Enum/Struct/Namespace/Class/Constructor/Destructor
|
||||||
|
isExecutable True when the type is: Function/If/Else/For/While/Do/Switch/Try/Catch/Unconditional/Lambda
|
||||||
|
definedType
|
||||||
"""
|
"""
|
||||||
|
#symboldatabase.cpp/SymbolDatabase::printXml
|
||||||
|
|
||||||
Id = None
|
Id = None
|
||||||
bodyStartId = None
|
bodyStartId = None
|
||||||
|
@ -515,6 +576,7 @@ class Scope:
|
||||||
self.className = element.get('className')
|
self.className = element.get('className')
|
||||||
self.functionId = element.get('function')
|
self.functionId = element.get('function')
|
||||||
self.function = None
|
self.function = None
|
||||||
|
self.functions = []
|
||||||
self.bodyStartId = element.get('bodyStart')
|
self.bodyStartId = element.get('bodyStart')
|
||||||
self.bodyStart = None
|
self.bodyStart = None
|
||||||
self.bodyEndId = element.get('bodyEnd')
|
self.bodyEndId = element.get('bodyEnd')
|
||||||
|
@ -522,14 +584,16 @@ class Scope:
|
||||||
self.nestedInId = element.get('nestedIn')
|
self.nestedInId = element.get('nestedIn')
|
||||||
self.nestedIn = None
|
self.nestedIn = None
|
||||||
self.type = element.get('type')
|
self.type = element.get('type')
|
||||||
|
self.definedType = element.get('definedType')
|
||||||
self.isExecutable = (self.type in ('Function', 'If', 'Else', 'For', 'While', 'Do',
|
self.isExecutable = (self.type in ('Function', 'If', 'Else', 'For', 'While', 'Do',
|
||||||
'Switch', 'Try', 'Catch', 'Unconditional', 'Lambda'))
|
'Switch', 'Try', 'Catch', 'Unconditional', 'Lambda'))
|
||||||
|
|
||||||
self.varlistId = list()
|
self.varlistId = list()
|
||||||
self.varlist = list()
|
self.varlist = list()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["Id", "className", "functionId", "bodyStartId", "bodyEndId",
|
attrs = ["Id", "className", "functionId", "bodyStartId", "bodyEndId",
|
||||||
"nestedInId", "nestedIn", "type", "isExecutable"]
|
"nestedInId", "nestedIn", "type", "definedType", "isExecutable", "functions"]
|
||||||
return "{}({})".format(
|
return "{}({})".format(
|
||||||
"Scope",
|
"Scope",
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
|
@ -553,14 +617,20 @@ class Function:
|
||||||
https://cppcheck.sourceforge.io/devinfo/doxyoutput/classFunction.html
|
https://cppcheck.sourceforge.io/devinfo/doxyoutput/classFunction.html
|
||||||
|
|
||||||
Attributes
|
Attributes
|
||||||
argument Argument list
|
argument Argument list (dict of argument number and variable)
|
||||||
token Token in function implementation
|
token Token in function implementation
|
||||||
tokenDef Token in function definition
|
tokenDef Token in function definition
|
||||||
isVirtual Is this function is virtual
|
name
|
||||||
|
type Constructor/CopyConstructor/MoveConstructor/OperatorEqual/Destructor/Function/Lambda/Unknown
|
||||||
|
hasVirtualSpecifier Is this function is virtual
|
||||||
isImplicitlyVirtual Is this function is virtual this in the base classes
|
isImplicitlyVirtual Is this function is virtual this in the base classes
|
||||||
|
access Public/Protected/Private
|
||||||
isInlineKeyword Is inline keyword used
|
isInlineKeyword Is inline keyword used
|
||||||
isStatic Is this function static?
|
isStatic Is this function static
|
||||||
|
isAttributeNoreturn
|
||||||
|
overriddenFunction
|
||||||
"""
|
"""
|
||||||
|
#symboldatabase.cpp/SymbolDatabase::printXml
|
||||||
|
|
||||||
Id = None
|
Id = None
|
||||||
argument = None
|
argument = None
|
||||||
|
@ -571,10 +641,13 @@ class Function:
|
||||||
tokenDefId = None
|
tokenDefId = None
|
||||||
name = None
|
name = None
|
||||||
type = None
|
type = None
|
||||||
isVirtual = None
|
access = None
|
||||||
isImplicitlyVirtual = None
|
isImplicitlyVirtual = None
|
||||||
|
hasVirtualSpecifier = None
|
||||||
isInlineKeyword = None
|
isInlineKeyword = None
|
||||||
isStatic = None
|
isStatic = None
|
||||||
|
isAttributeNoreturn = None
|
||||||
|
overriddenFunction = None
|
||||||
nestedIn = None
|
nestedIn = None
|
||||||
|
|
||||||
def __init__(self, element, nestedIn):
|
def __init__(self, element, nestedIn):
|
||||||
|
@ -583,18 +656,22 @@ class Function:
|
||||||
self.tokenDefId = element.get('tokenDef')
|
self.tokenDefId = element.get('tokenDef')
|
||||||
self.name = element.get('name')
|
self.name = element.get('name')
|
||||||
self.type = element.get('type')
|
self.type = element.get('type')
|
||||||
|
self.hasVirtualSpecifier = element.get('hasVirtualSpecifier', 'false') == 'true'
|
||||||
self.isImplicitlyVirtual = element.get('isImplicitlyVirtual', 'false') == 'true'
|
self.isImplicitlyVirtual = element.get('isImplicitlyVirtual', 'false') == 'true'
|
||||||
self.isVirtual = element.get('isVirtual', 'false') == 'true'
|
self.access = element.get('access')
|
||||||
self.isInlineKeyword = element.get('isInlineKeyword', 'false') == 'true'
|
self.isInlineKeyword = element.get('isInlineKeyword', 'false') == 'true'
|
||||||
self.isStatic = element.get('isStatic', 'false') == 'true'
|
self.isStatic = element.get('isStatic', 'false') == 'true'
|
||||||
|
self.isAttributeNoreturn = element.get('isAttributeNoreturn', 'false') == 'true'
|
||||||
|
self.overriddenFunction = element.get('overriddenFunction', 'false') == 'true'
|
||||||
self.nestedIn = nestedIn
|
self.nestedIn = nestedIn
|
||||||
|
|
||||||
self.argument = {}
|
self.argument = {}
|
||||||
self.argumentId = {}
|
self.argumentId = {}
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["Id", "tokenId", "tokenDefId", "name", "type", "isVirtual",
|
attrs = ["Id", "tokenId", "tokenDefId", "name", "type", "hasVirtualSpecifier",
|
||||||
"isImplicitlyVirtual", "isInlineKeyword", "isStatic", "argumentId"]
|
"isImplicitlyVirtual", "access", "isInlineKeyword", "isStatic",
|
||||||
|
"isAttributeNoreturn", "overriddenFunction", "nestedIn", "argumentId"]
|
||||||
return "{}({})".format(
|
return "{}({})".format(
|
||||||
"Function",
|
"Function",
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
|
@ -607,6 +684,10 @@ class Function:
|
||||||
self.tokenDef = IdMap[self.tokenDefId]
|
self.tokenDef = IdMap[self.tokenDefId]
|
||||||
|
|
||||||
|
|
||||||
|
#todo add class Types:
|
||||||
|
#symboldatabase.cpp/SymbolDatabase::printXml
|
||||||
|
|
||||||
|
|
||||||
class Variable:
|
class Variable:
|
||||||
"""
|
"""
|
||||||
Information about a variable
|
Information about a variable
|
||||||
|
@ -617,20 +698,22 @@ class Variable:
|
||||||
nameToken Name token in variable declaration
|
nameToken Name token in variable declaration
|
||||||
typeStartToken Start token of variable declaration
|
typeStartToken Start token of variable declaration
|
||||||
typeEndToken End token of variable declaration
|
typeEndToken End token of variable declaration
|
||||||
access Global/Local/Namespace/Public/Protected/Public/Throw/Argument
|
access Global/Local/Namespace/Public/Protected/Public/Throw/Argument/Unknown
|
||||||
scope Variable scope
|
scope Variable scope
|
||||||
|
constness Variable constness (same encoding as ValueType::constness)
|
||||||
isArgument Is this variable a function argument?
|
isArgument Is this variable a function argument?
|
||||||
|
isGlobal Is this variable a global variable?
|
||||||
|
isLocal Is this variable a local variable?
|
||||||
isArray Is this variable an array?
|
isArray Is this variable an array?
|
||||||
isClass Is this variable a class or struct?
|
isClass Is this variable a class or struct?
|
||||||
isConst Is this variable a const variable?
|
isConst Is this variable a const variable?
|
||||||
isGlobal Is this variable a global variable?
|
|
||||||
isExtern Is this variable an extern variable?
|
isExtern Is this variable an extern variable?
|
||||||
isLocal Is this variable a local variable?
|
|
||||||
isPointer Is this variable a pointer
|
isPointer Is this variable a pointer
|
||||||
isReference Is this variable a reference
|
isReference Is this variable a reference
|
||||||
isStatic Is this variable static?
|
isStatic Is this variable static?
|
||||||
constness Variable constness (same encoding as ValueType::constness)
|
isVolatile Is this variable volatile?
|
||||||
"""
|
"""
|
||||||
|
#symboldatabase.cpp/SymbolDatabase::printXml
|
||||||
|
|
||||||
Id = None
|
Id = None
|
||||||
nameTokenId = None
|
nameTokenId = None
|
||||||
|
@ -652,6 +735,7 @@ class Variable:
|
||||||
isPointer = False
|
isPointer = False
|
||||||
isReference = False
|
isReference = False
|
||||||
isStatic = False
|
isStatic = False
|
||||||
|
isVolatile = False
|
||||||
constness = 0
|
constness = 0
|
||||||
|
|
||||||
def __init__(self, element):
|
def __init__(self, element):
|
||||||
|
@ -663,25 +747,26 @@ class Variable:
|
||||||
self.typeEndTokenId = element.get('typeEndToken')
|
self.typeEndTokenId = element.get('typeEndToken')
|
||||||
self.typeEndToken = None
|
self.typeEndToken = None
|
||||||
self.access = element.get('access')
|
self.access = element.get('access')
|
||||||
|
self.isArgument = (self.access and self.access == 'Argument')
|
||||||
|
self.isGlobal = (self.access and self.access == 'Global')
|
||||||
|
self.isLocal = (self.access and self.access == 'Local')
|
||||||
self.scopeId = element.get('scope')
|
self.scopeId = element.get('scope')
|
||||||
self.scope = None
|
self.scope = None
|
||||||
self.isArgument = (self.access and self.access == 'Argument')
|
self.constness = int(element.get('constness',0))
|
||||||
self.isArray = element.get('isArray') == 'true'
|
self.isArray = element.get('isArray') == 'true'
|
||||||
self.isClass = element.get('isClass') == 'true'
|
self.isClass = element.get('isClass') == 'true'
|
||||||
self.isConst = element.get('isConst') == 'true'
|
self.isConst = element.get('isConst') == 'true'
|
||||||
self.isGlobal = (self.access and self.access == 'Global')
|
|
||||||
self.isExtern = element.get('isExtern') == 'true'
|
self.isExtern = element.get('isExtern') == 'true'
|
||||||
self.isLocal = (self.access and self.access == 'Local')
|
|
||||||
self.isPointer = element.get('isPointer') == 'true'
|
self.isPointer = element.get('isPointer') == 'true'
|
||||||
self.isReference = element.get('isReference') == 'true'
|
self.isReference = element.get('isReference') == 'true'
|
||||||
self.isStatic = element.get('isStatic') == 'true'
|
self.isStatic = element.get('isStatic') == 'true'
|
||||||
self.constness = int(element.get('constness',0))
|
self.isVolatile = element.get('isVolatile') == 'true'
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["Id", "nameTokenId", "typeStartTokenId", "typeEndTokenId",
|
attrs = ["Id", "nameTokenId", "typeStartTokenId", "typeEndTokenId",
|
||||||
"access", "scopeId", "isArgument", "isArray", "isClass",
|
"access", "scopeId", "isArgument", "isArray", "isClass",
|
||||||
"isConst", "isGlobal", "isExtern", "isLocal", "isPointer",
|
"isConst", "isGlobal", "isExtern", "isLocal", "isPointer",
|
||||||
"isReference", "isStatic", "constness", ]
|
"isReference", "isStatic", "isVolatile", "constness"]
|
||||||
return "{}({})".format(
|
return "{}({})".format(
|
||||||
"Variable",
|
"Variable",
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
|
@ -693,11 +778,32 @@ class Variable:
|
||||||
self.typeEndToken = IdMap[self.typeEndTokenId]
|
self.typeEndToken = IdMap[self.typeEndTokenId]
|
||||||
self.scope = IdMap[self.scopeId]
|
self.scope = IdMap[self.scopeId]
|
||||||
|
|
||||||
|
class Container:
|
||||||
|
"""
|
||||||
|
Container class -- information about containers
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
array-like-index-op true/false
|
||||||
|
stdStringLike true/false
|
||||||
|
"""
|
||||||
|
#tokenizer.cpp/tokenizer::dump
|
||||||
|
Id = None
|
||||||
|
|
||||||
|
def __init__(self, element):
|
||||||
|
self.Id = element.get('id')
|
||||||
|
self.arrayLikeIndexOp = element.get('array-like-index-op') == 'true'
|
||||||
|
self.stdStringLike = element.get('std-string-like') == 'true'
|
||||||
|
|
||||||
class TypedefInfo:
|
class TypedefInfo:
|
||||||
"""
|
"""
|
||||||
TypedefInfo class -- information about typedefs
|
TypedefInfo class -- information about typedefs
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
name name of the typedef
|
||||||
|
used 0/1
|
||||||
"""
|
"""
|
||||||
|
#tokenizer.cpp/tokenizer::dump
|
||||||
|
|
||||||
name = None
|
name = None
|
||||||
used = None
|
used = None
|
||||||
file = None
|
file = None
|
||||||
|
@ -717,11 +823,19 @@ class Value:
|
||||||
intvalue integer value
|
intvalue integer value
|
||||||
tokvalue token value
|
tokvalue token value
|
||||||
floatvalue float value
|
floatvalue float value
|
||||||
|
movedValue
|
||||||
|
uninit
|
||||||
containerSize container size
|
containerSize container size
|
||||||
|
bufferSize buffer size
|
||||||
|
lifetimeScope Local/Argument/SubFunction/ThisPointer/ThisValue
|
||||||
|
lifetimeKind Object/SubObject/Lambda/Iterator/Address
|
||||||
|
symbolicDelta
|
||||||
condition condition where this Value comes from
|
condition condition where this Value comes from
|
||||||
valueKind 'known' or 'possible'
|
bound Upper/Lower/Point
|
||||||
inconclusive Is value inconclusive?
|
valueKind known/possible/impossible/inconclusive
|
||||||
|
path 0/1/2/3/..
|
||||||
"""
|
"""
|
||||||
|
#token.cpp/token::printValueFlow
|
||||||
|
|
||||||
intvalue = None
|
intvalue = None
|
||||||
tokvalue = None
|
tokvalue = None
|
||||||
|
@ -729,7 +843,6 @@ class Value:
|
||||||
containerSize = None
|
containerSize = None
|
||||||
condition = None
|
condition = None
|
||||||
valueKind = None
|
valueKind = None
|
||||||
inconclusive = False
|
|
||||||
|
|
||||||
def isKnown(self):
|
def isKnown(self):
|
||||||
return self.valueKind and self.valueKind == 'known'
|
return self.valueKind and self.valueKind == 'known'
|
||||||
|
@ -740,12 +853,18 @@ class Value:
|
||||||
def isImpossible(self):
|
def isImpossible(self):
|
||||||
return self.valueKind and self.valueKind == 'impossible'
|
return self.valueKind and self.valueKind == 'impossible'
|
||||||
|
|
||||||
|
def isInconclusive(self):
|
||||||
|
return self.valueKind and self.valueKind == 'inconclusive'
|
||||||
|
|
||||||
def __init__(self, element):
|
def __init__(self, element):
|
||||||
self.intvalue = element.get('intvalue')
|
self.intvalue = element.get('intvalue')
|
||||||
if self.intvalue:
|
if self.intvalue:
|
||||||
self.intvalue = int(self.intvalue)
|
self.intvalue = int(self.intvalue)
|
||||||
self._tokvalueId = element.get('tokvalue')
|
self._tokvalueId = element.get('tokvalue')
|
||||||
self.floatvalue = element.get('floatvalue')
|
self.floatvalue = element.get('floatvalue')
|
||||||
|
self.movedvalue = element.get('movedvalue')
|
||||||
|
self.uninit = element.get('uninit')
|
||||||
|
self.bufferSize = element.get('buffer-size')
|
||||||
self.containerSize = element.get('container-size')
|
self.containerSize = element.get('container-size')
|
||||||
self.iteratorStart = element.get('iterator-start')
|
self.iteratorStart = element.get('iterator-start')
|
||||||
self.iteratorEnd = element.get('iterator-end')
|
self.iteratorEnd = element.get('iterator-end')
|
||||||
|
@ -754,9 +873,8 @@ class Value:
|
||||||
self.lifetimeKind = element.get('lifetime-kind')
|
self.lifetimeKind = element.get('lifetime-kind')
|
||||||
self._symbolicId = element.get('symbolic')
|
self._symbolicId = element.get('symbolic')
|
||||||
self.symbolicDelta = element.get('symbolic-delta')
|
self.symbolicDelta = element.get('symbolic-delta')
|
||||||
self.condition = element.get('condition-line')
|
|
||||||
self.bound = element.get('bound')
|
self.bound = element.get('bound')
|
||||||
self.path = element.get('path')
|
self.condition = element.get('condition-line')
|
||||||
if self.condition:
|
if self.condition:
|
||||||
self.condition = int(self.condition)
|
self.condition = int(self.condition)
|
||||||
if element.get('known'):
|
if element.get('known'):
|
||||||
|
@ -765,8 +883,9 @@ class Value:
|
||||||
self.valueKind = 'possible'
|
self.valueKind = 'possible'
|
||||||
elif element.get('impossible'):
|
elif element.get('impossible'):
|
||||||
self.valueKind = 'impossible'
|
self.valueKind = 'impossible'
|
||||||
if element.get('inconclusive'):
|
elif element.get('inconclusive'):
|
||||||
self.inconclusive = True
|
self.valueKind = 'inconclusive'
|
||||||
|
self.path = element.get('path')
|
||||||
|
|
||||||
def setId(self, IdMap):
|
def setId(self, IdMap):
|
||||||
self.tokvalue = IdMap.get(self._tokvalueId)
|
self.tokvalue = IdMap.get(self._tokvalueId)
|
||||||
|
@ -774,8 +893,8 @@ class Value:
|
||||||
self.symbolic = IdMap.get(self._symbolicId)
|
self.symbolic = IdMap.get(self._symbolicId)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["intvalue", "tokvalue", "floatvalue", "containerSize",
|
attrs = ["intvalue", "tokvalue", "floatvalue", "movedValue", "uninit",
|
||||||
"condition", "valueKind", "inconclusive"]
|
"bufferSize", "containerSize", "condition", "valueKind"]
|
||||||
return "{}({})".format(
|
return "{}({})".format(
|
||||||
"Value",
|
"Value",
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
|
@ -861,6 +980,7 @@ class Configuration:
|
||||||
preprocessor_if_conditions List of preprocessor if conditions that was evaluated during preprocessing
|
preprocessor_if_conditions List of preprocessor if conditions that was evaluated during preprocessing
|
||||||
tokenlist List of Token items
|
tokenlist List of Token items
|
||||||
scopes List of Scope items
|
scopes List of Scope items
|
||||||
|
containers List of Container items
|
||||||
functions List of Function items
|
functions List of Function items
|
||||||
variables List of Variable items
|
variables List of Variable items
|
||||||
valueflow List of ValueFlow values
|
valueflow List of ValueFlow values
|
||||||
|
@ -873,6 +993,7 @@ class Configuration:
|
||||||
preprocessor_if_conditions = []
|
preprocessor_if_conditions = []
|
||||||
tokenlist = []
|
tokenlist = []
|
||||||
scopes = []
|
scopes = []
|
||||||
|
containers = []
|
||||||
functions = []
|
functions = []
|
||||||
variables = []
|
variables = []
|
||||||
typedefInfo = []
|
typedefInfo = []
|
||||||
|
@ -887,6 +1008,7 @@ class Configuration:
|
||||||
self.preprocessor_if_conditions = []
|
self.preprocessor_if_conditions = []
|
||||||
self.tokenlist = []
|
self.tokenlist = []
|
||||||
self.scopes = []
|
self.scopes = []
|
||||||
|
self.containers = []
|
||||||
self.functions = []
|
self.functions = []
|
||||||
self.variables = []
|
self.variables = []
|
||||||
self.typedefInfo = []
|
self.typedefInfo = []
|
||||||
|
@ -909,6 +1031,8 @@ class Configuration:
|
||||||
IdMap[token.Id] = token
|
IdMap[token.Id] = token
|
||||||
for scope in self.scopes:
|
for scope in self.scopes:
|
||||||
IdMap[scope.Id] = scope
|
IdMap[scope.Id] = scope
|
||||||
|
for container in self.containers:
|
||||||
|
IdMap[container.Id] = container
|
||||||
for function in self.functions:
|
for function in self.functions:
|
||||||
IdMap[function.Id] = function
|
IdMap[function.Id] = function
|
||||||
for variable in self.variables:
|
for variable in self.variables:
|
||||||
|
@ -921,6 +1045,8 @@ class Configuration:
|
||||||
token.setId(IdMap)
|
token.setId(IdMap)
|
||||||
for scope in self.scopes:
|
for scope in self.scopes:
|
||||||
scope.setId(IdMap)
|
scope.setId(IdMap)
|
||||||
|
#for container in self.containers:
|
||||||
|
# container.setId(IdMap)
|
||||||
for function in self.functions:
|
for function in self.functions:
|
||||||
function.setId(IdMap)
|
function.setId(IdMap)
|
||||||
for variable in self.variables:
|
for variable in self.variables:
|
||||||
|
@ -942,7 +1068,7 @@ class Platform:
|
||||||
This class contains type sizes
|
This class contains type sizes
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
name Name of the platform
|
name Name of the platform: unspecified/native/win32A/win32W/win64/unix32/unix64/platformFile
|
||||||
char_bit CHAR_BIT value
|
char_bit CHAR_BIT value
|
||||||
short_bit SHORT_BIT value
|
short_bit SHORT_BIT value
|
||||||
int_bit INT_BIT value
|
int_bit INT_BIT value
|
||||||
|
@ -1056,7 +1182,7 @@ class CppcheckData:
|
||||||
self.rawTokens = []
|
self.rawTokens = []
|
||||||
self.platform = None
|
self.platform = None
|
||||||
self.suppressions = []
|
self.suppressions = []
|
||||||
self.files = []
|
self.files = [] # source files for elements occurred in this configuration
|
||||||
|
|
||||||
platform_done = False
|
platform_done = False
|
||||||
rawtokens_done = False
|
rawtokens_done = False
|
||||||
|
@ -1136,7 +1262,6 @@ class CppcheckData:
|
||||||
'line': int(node.get('line')),
|
'line': int(node.get('line')),
|
||||||
'column': int(node.get('column')),
|
'column': int(node.get('column')),
|
||||||
'message': node.get('message')})
|
'message': node.get('message')})
|
||||||
|
|
||||||
# Parse standards
|
# Parse standards
|
||||||
elif node.tag == "standards" and event == 'start':
|
elif node.tag == "standards" and event == 'start':
|
||||||
continue
|
continue
|
||||||
|
@ -1150,7 +1275,6 @@ class CppcheckData:
|
||||||
# Parse directives list
|
# Parse directives list
|
||||||
elif node.tag == 'directive' and event == 'start':
|
elif node.tag == 'directive' and event == 'start':
|
||||||
cfg.directives.append(Directive(node))
|
cfg.directives.append(Directive(node))
|
||||||
|
|
||||||
# Parse macro usage
|
# Parse macro usage
|
||||||
elif node.tag == 'macro' and event == 'start':
|
elif node.tag == 'macro' and event == 'start':
|
||||||
cfg.macro_usage.append(MacroUsage(node))
|
cfg.macro_usage.append(MacroUsage(node))
|
||||||
|
@ -1204,12 +1328,22 @@ class CppcheckData:
|
||||||
else:
|
else:
|
||||||
cfg_arguments.append(var)
|
cfg_arguments.append(var)
|
||||||
|
|
||||||
|
# Parse containers
|
||||||
|
elif node.tag == 'containers' and event == 'start':
|
||||||
|
continue
|
||||||
|
elif node.tag == 'container' and event == 'start':
|
||||||
|
cfg.containers.append(Container(node))
|
||||||
|
|
||||||
# Parse typedef info
|
# Parse typedef info
|
||||||
elif node.tag == 'typedef-info':
|
elif node.tag == 'typedef-info':
|
||||||
iter_typedef_info = (event == 'start')
|
iter_typedef_info = (event == 'start')
|
||||||
elif iter_typedef_info and node.tag == 'info' and event == 'start':
|
elif iter_typedef_info and node.tag == 'info' and event == 'start':
|
||||||
cfg.typedefInfo.append(TypedefInfo(node))
|
cfg.typedefInfo.append(TypedefInfo(node))
|
||||||
|
|
||||||
|
# Parse template-token
|
||||||
|
#elif node.tag == 'TokenAndName' and event == 'start': #todo add processing of containers
|
||||||
|
# cfg.containers.append(Container(node))
|
||||||
|
|
||||||
# Parse valueflows (list of values)
|
# Parse valueflows (list of values)
|
||||||
elif node.tag == 'valueflow' and event == 'start':
|
elif node.tag == 'valueflow' and event == 'start':
|
||||||
continue
|
continue
|
||||||
|
@ -1345,7 +1479,6 @@ def get_files(args):
|
||||||
dump_files.append(f)
|
dump_files.append(f)
|
||||||
return dump_files, ctu_info_files
|
return dump_files, ctu_info_files
|
||||||
|
|
||||||
|
|
||||||
def simpleMatch(token, pattern):
|
def simpleMatch(token, pattern):
|
||||||
for p in pattern.split(' '):
|
for p in pattern.split(' '):
|
||||||
if not token or token.str != p:
|
if not token or token.str != p:
|
||||||
|
@ -1526,4 +1659,3 @@ def cmd_output(cmd):
|
||||||
if p.returncode == 1 and len(comm[1]) > 2:
|
if p.returncode == 1 and len(comm[1]) > 2:
|
||||||
out = comm[1]
|
out = comm[1]
|
||||||
return out.decode(encoding='utf-8', errors='ignore')
|
return out.decode(encoding='utf-8', errors='ignore')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue