MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / ellipsisStructArg

Function ellipsisStructArg

addons/misc.py:87–131  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

85 reportError(function.tokenDef, 'style', 'Function \'' + function.name + '\' overrides base class function but is not marked with \'virtual\' keyword.', 'implicitlyVirtual')
86
87def ellipsisStructArg(data):
88 for cfg in data.iterconfigurations():
89 for tok in cfg.tokenlist:
90 if tok.str != '(':
91 continue
92 if tok.astOperand1 is None or tok.astOperand2 is None:
93 continue
94 if tok.astOperand2.str != ',':
95 continue
96 if tok.scope.type in ['Global', 'Class']:
97 continue
98 if tok.astOperand1.function is None:
99 continue
100 for argnr, argvar in tok.astOperand1.function.argument.items():
101 if argnr < 1:
102 continue
103 if not simpleMatch(argvar.typeStartToken, '...'):
104 continue
105 callArgs = getArguments(tok)
106 for i in range(argnr-1, len(callArgs)):
107 valueType = callArgs[i].valueType
108 if valueType is None:
109 argStart = callArgs[i].previous
110 while argStart.str != ',':
111 if argStart.str == ')':
112 argStart = argStart.link
113 argStart = argStart.previous
114 argEnd = callArgs[i]
115 while argEnd.str != ',' and argEnd.str != ')':
116 if argEnd.str == '(':
117 argEnd = argEnd.link
118 argEnd = argEnd.next
119 expression = ''
120 argStart = argStart.next
121 while argStart != argEnd:
122 expression = expression + argStart.str
123 argStart = argStart.next
124 reportError(tok, 'debug', 'Bailout, unknown argument type for argument \'' + expression + '\'.', 'debug')
125 continue
126 if valueType.pointer > 0:
127 continue
128 if valueType.type != 'record' and valueType.type != 'container':
129 continue
130 reportError(tok, 'style', 'Passing record to ellipsis function \'' + tok.astOperand1.function.name + '\'.', 'ellipsisStructArg')
131 break
132
133for arg in sys.argv[1:]:
134 if arg in ['-debug', '-verify', '--cli']:

Callers 1

misc.pyFile · 0.85

Calls 4

iterconfigurationsMethod · 0.80
simpleMatchFunction · 0.70
getArgumentsFunction · 0.70
reportErrorFunction · 0.70

Tested by

no test coverage detected