misc.py: write debug message when valueType is None
This commit is contained in:
parent
b53c4b2032
commit
3c48e08e6c
|
@ -10,11 +10,14 @@ import cppcheckdata
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
DEBUG = ('-debug' in sys.argv)
|
||||||
VERIFY = ('-verify' in sys.argv)
|
VERIFY = ('-verify' in sys.argv)
|
||||||
VERIFY_EXPECTED = []
|
VERIFY_EXPECTED = []
|
||||||
VERIFY_ACTUAL = []
|
VERIFY_ACTUAL = []
|
||||||
|
|
||||||
def reportError(token, severity, msg, id):
|
def reportError(token, severity, msg, id):
|
||||||
|
if id == 'debug' and DEBUG == False:
|
||||||
|
return
|
||||||
if VERIFY:
|
if VERIFY:
|
||||||
VERIFY_ACTUAL.append(str(token.linenr) + ':' + id)
|
VERIFY_ACTUAL.append(str(token.linenr) + ':' + id)
|
||||||
else:
|
else:
|
||||||
|
@ -86,6 +89,10 @@ def ellipsisStructArg(data):
|
||||||
continue
|
continue
|
||||||
if tok.astOperand1 is None or tok.astOperand2 is None:
|
if tok.astOperand1 is None or tok.astOperand2 is None:
|
||||||
continue
|
continue
|
||||||
|
if tok.astOperand2.str != ',':
|
||||||
|
continue
|
||||||
|
if tok.scope.type in ['Global', 'Class']:
|
||||||
|
continue
|
||||||
if tok.astOperand1.function is None:
|
if tok.astOperand1.function is None:
|
||||||
continue
|
continue
|
||||||
for argnr, argvar in tok.astOperand1.function.argument.items():
|
for argnr, argvar in tok.astOperand1.function.argument.items():
|
||||||
|
@ -96,17 +103,33 @@ def ellipsisStructArg(data):
|
||||||
callArgs = getArguments(tok)
|
callArgs = getArguments(tok)
|
||||||
for i in range(argnr-1, len(callArgs)):
|
for i in range(argnr-1, len(callArgs)):
|
||||||
valueType = callArgs[i].valueType
|
valueType = callArgs[i].valueType
|
||||||
if not valueType:
|
if valueType is None:
|
||||||
|
argStart = callArgs[i].previous
|
||||||
|
while argStart.str != ',':
|
||||||
|
if argStart.str == ')':
|
||||||
|
argStart = argStart.link
|
||||||
|
argStart = argStart.previous
|
||||||
|
argEnd = callArgs[i]
|
||||||
|
while argEnd.str != ',' and argEnd.str != ')':
|
||||||
|
if argEnd.str == '(':
|
||||||
|
argEnd = argEnd.link
|
||||||
|
argEnd = argEnd.next
|
||||||
|
expression = ''
|
||||||
|
argStart = argStart.next
|
||||||
|
while argStart != argEnd:
|
||||||
|
expression = expression + argStart.str
|
||||||
|
argStart = argStart.next
|
||||||
|
reportError(tok, 'debug', 'Bailout, unknown argument type for argument \'' + expression + '\'.', 'debug')
|
||||||
continue
|
continue
|
||||||
if valueType.pointer > 0:
|
if valueType.pointer > 0:
|
||||||
continue
|
continue
|
||||||
if valueType.type != 'record':
|
if valueType.type != 'record' and valueType.type != 'container':
|
||||||
continue
|
continue
|
||||||
reportError(tok, 'style', 'Passing record to ellipsis function \'' + tok.astOperand1.function.name + '\'.', 'ellipsisStructArg')
|
reportError(tok, 'style', 'Passing record to ellipsis function \'' + tok.astOperand1.function.name + '\'.', 'ellipsisStructArg')
|
||||||
break
|
break
|
||||||
|
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if arg == '-verify':
|
if arg in ['-debug', '-verify']:
|
||||||
continue
|
continue
|
||||||
print('Checking ' + arg + '...')
|
print('Checking ' + arg + '...')
|
||||||
data = cppcheckdata.parsedump(arg)
|
data = cppcheckdata.parsedump(arg)
|
||||||
|
|
|
@ -33,6 +33,7 @@ class derived : base {
|
||||||
// Pass struct to ellipsis function
|
// Pass struct to ellipsis function
|
||||||
struct {int x;int y;} s;
|
struct {int x;int y;} s;
|
||||||
void ellipsis(int x, ...);
|
void ellipsis(int x, ...);
|
||||||
void foo(void) {
|
void foo(std::vector<std::string> v) {
|
||||||
ellipsis(321, s); // ellipsisStructArg
|
ellipsis(321, s); // ellipsisStructArg
|
||||||
|
ellipsis(321, v[0]); // ellipsisStructArg
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue