parent
873861df4a
commit
7d0075357e
|
@ -11,17 +11,21 @@
|
|||
import cppcheckdata
|
||||
import sys
|
||||
|
||||
|
||||
def reportError(token, severity, msg):
|
||||
sys.stderr.write('[' + token.file + ':' + str(token.linenr) + '] (' + severity + ') cert.py: ' + msg + '\n')
|
||||
|
||||
|
||||
def isLocalStruct(arg):
|
||||
if arg and arg.str == '&' and not arg.astOperand2:
|
||||
arg = arg.astOperand1
|
||||
return arg and arg.variable and arg.variable.isClass and (arg.variable.isLocal or arg.variable.isArgument)
|
||||
|
||||
|
||||
def isBitwiseOp(token):
|
||||
return token and (token.str in ['&', '|', '^'])
|
||||
|
||||
|
||||
def isComparisonOp(token):
|
||||
return token and (token.str in ['==', '!=', '>', '>=', '<', '<='])
|
||||
|
||||
|
@ -48,6 +52,8 @@ def exp42(data):
|
|||
# EXP46-C
|
||||
# Do not use a bitwise operator with a Boolean-like operand
|
||||
# int x = (a == b) & c;
|
||||
|
||||
|
||||
def exp46(data):
|
||||
for token in data.tokenlist:
|
||||
if isBitwiseOp(token) and (isComparisonOp(token.astOperand1) or isComparisonOp(token.astOperand2)):
|
||||
|
|
|
@ -3,72 +3,75 @@
|
|||
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
## Token class. Contains information about each token in the source code.
|
||||
# Token class. Contains information about each token in the source code.
|
||||
|
||||
|
||||
class Token:
|
||||
Id = None
|
||||
## Token string
|
||||
# Token string
|
||||
str = None
|
||||
## Next token in tokenlist. For last token, next is None.
|
||||
# Next token in tokenlist. For last token, next is None.
|
||||
next = None
|
||||
## Previous token in tokenlist. For first token, previous is None,
|
||||
# Previous token in tokenlist. For first token, previous is None,
|
||||
previous = None
|
||||
linkId = None
|
||||
## Linked token in tokenlist. Each '(', '[' and '{' are linked to the
|
||||
# Linked token in tokenlist. Each '(', '[' and '{' are linked to the
|
||||
# corresponding '}', ']' and ')'. For templates, the '<' is linked to
|
||||
# the corresponding '>'.
|
||||
link = None
|
||||
scopeId = None
|
||||
## Scope information for this token. See the Scope class.
|
||||
# Scope information for this token. See the Scope class.
|
||||
scope = None
|
||||
## Is this token a symbol name
|
||||
# Is this token a symbol name
|
||||
isName = False
|
||||
## Is this token a number, for example 123, 12.34
|
||||
# Is this token a number, for example 123, 12.34
|
||||
isNumber = False
|
||||
## Is this token a int value such as 1234
|
||||
# Is this token a int value such as 1234
|
||||
isInt = False
|
||||
## Is this token a int value such as 12.34
|
||||
# Is this token a int value such as 12.34
|
||||
isFloat = False
|
||||
## Is this token a string literal such as "hello"
|
||||
# Is this token a string literal such as "hello"
|
||||
isString = False
|
||||
## string length for string literal
|
||||
# string length for string literal
|
||||
strlen = None
|
||||
## Is this token a char literal such as 'x'
|
||||
# Is this token a char literal such as 'x'
|
||||
isChar = False
|
||||
## Is this token a operator
|
||||
# Is this token a operator
|
||||
isOp = False
|
||||
## Is this token a arithmetic operator
|
||||
# Is this token a arithmetic operator
|
||||
isArithmeticalOp = False
|
||||
## Is this token a assignment operator
|
||||
# Is this token a assignment operator
|
||||
isAssignmentOp = False
|
||||
## Is this token a comparison operator
|
||||
# Is this token a comparison operator
|
||||
isComparisonOp = False
|
||||
## Is this token a logical operator: && ||
|
||||
# Is this token a logical operator: && ||
|
||||
isLogicalOp = False
|
||||
## varId for token, each variable has a unique non-zero id
|
||||
# varId for token, each variable has a unique non-zero id
|
||||
varId = None
|
||||
variableId = None
|
||||
## Variable information for this token. See the Variable class.
|
||||
# Variable information for this token. See the Variable class.
|
||||
variable = None
|
||||
functionId = None
|
||||
## If this token points at a function call, this attribute has the Function information. See the Function class.
|
||||
# If this token points at a function call, this attribute has the Function
|
||||
# information. See the Function class.
|
||||
function = None
|
||||
valuesId = None
|
||||
## Possible values of token
|
||||
# Possible values of token
|
||||
values = None
|
||||
|
||||
astParentId = None
|
||||
## syntax tree parent
|
||||
# syntax tree parent
|
||||
astParent = None
|
||||
astOperand1Id = None
|
||||
## syntax tree operand1
|
||||
# syntax tree operand1
|
||||
astOperand1 = None
|
||||
astOperand2Id = None
|
||||
## syntax tree operand2
|
||||
# syntax tree operand2
|
||||
astOperand2 = None
|
||||
|
||||
## file name
|
||||
# file name
|
||||
file = None
|
||||
## line number
|
||||
# line number
|
||||
linenr = None
|
||||
|
||||
def __init__(self, element):
|
||||
|
@ -189,6 +192,7 @@ class Function:
|
|||
self.argument[argnr] = IdMap[argid]
|
||||
self.tokenDef = IdMap[self.tokenDefId]
|
||||
|
||||
|
||||
class Variable:
|
||||
Id = None
|
||||
nameTokenId = None
|
||||
|
|
|
@ -19,6 +19,7 @@ for arg in sys.argv[1:]:
|
|||
elif arg[:11] == '--function=':
|
||||
RE_FUNCTIONNAME = arg[11:]
|
||||
|
||||
|
||||
def reportError(token, severity, msg):
|
||||
sys.stderr.write('[' + token.file + ':' + str(token.linenr) + '] (' + severity + ') naming.py: ' + msg + '\n')
|
||||
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
import cppcheckdata
|
||||
import sys
|
||||
|
||||
|
||||
def reportError(token, severity, msg):
|
||||
sys.stderr.write('[' + token.file + ':' + str(token.linenr) + '] (' + severity + ') threadsafety.py: ' + msg + '\n')
|
||||
|
||||
|
||||
def checkstatic(data):
|
||||
for var in data.variables:
|
||||
if var.isStatic == True and var.isLocal == True and var.isClass == True:
|
||||
|
|
|
@ -120,6 +120,7 @@ def removeLargeFiles(path):
|
|||
if path.find('/clang/INPUTS/') > 0 or statinfo.st_size > 100000:
|
||||
os.remove(g)
|
||||
|
||||
|
||||
def dumpfiles(path):
|
||||
ret = []
|
||||
for g in glob.glob(path + '*'):
|
||||
|
@ -132,6 +133,7 @@ def dumpfiles(path):
|
|||
ret.append(g)
|
||||
return ret
|
||||
|
||||
|
||||
def scanarchive(filepath, jobs):
|
||||
# remove all files/folders except results.txt
|
||||
removeAllExceptResults()
|
||||
|
|
|
@ -695,4 +695,3 @@ def main():
|
|||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
|
@ -68,4 +68,3 @@ $ make reduce
|
|||
### * tools/times.sh
|
||||
|
||||
Script to generate a `times.log` file that contains timing information of the last 20 revisions.
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ if len(sys.argv) == 2:
|
|||
PASSWORD = sys.argv[1]
|
||||
|
||||
# Upload file to sourceforge web server using scp
|
||||
|
||||
|
||||
def upload(file_to_upload, destination):
|
||||
if not os.path.isfile(file_to_upload):
|
||||
return
|
||||
|
@ -29,6 +31,7 @@ def upload(file_to_upload, destination):
|
|||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
|
||||
def daca2(foldernum):
|
||||
folders = '0123456789abcdefghijklmnopqrstuvwxyz'
|
||||
folder = folders[foldernum % len(folders)]
|
||||
|
@ -55,5 +58,3 @@ foldernum = 0
|
|||
while True:
|
||||
daca2(foldernum)
|
||||
foldernum = foldernum + 1
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ if len(sys.argv) == 2:
|
|||
PASSWORD = sys.argv[1]
|
||||
|
||||
# Upload file to sourceforge web server using scp
|
||||
|
||||
|
||||
def upload(file_to_upload, destination):
|
||||
if not os.path.isfile(file_to_upload):
|
||||
return
|
||||
|
@ -29,6 +31,7 @@ def upload(file_to_upload, destination):
|
|||
except pexpect.TIMEOUT:
|
||||
pass
|
||||
|
||||
|
||||
def daca2(foldernum):
|
||||
folders = '0123456789abcdefghijklmnopqrstuvwxyz'
|
||||
folder = folders[foldernum % len(folders)]
|
||||
|
@ -55,4 +58,3 @@ foldernum = 0
|
|||
while True:
|
||||
daca2(foldernum)
|
||||
foldernum = foldernum + 1
|
||||
|
||||
|
|
|
@ -137,7 +137,8 @@ class MatchCompilerTest(unittest.TestCase):
|
|||
|
||||
def test_parseStringComparison(self):
|
||||
input = 'str == "abc"'
|
||||
res = self.mc._parseStringComparison(input, 5) # offset '5' is chosen as an abritary start offset to look for "
|
||||
# offset '5' is chosen as an abritary start offset to look for
|
||||
res = self.mc._parseStringComparison(input, 5)
|
||||
self.assertEqual(2, len(res))
|
||||
self.assertEqual('str == MatchCompiler::makeConstString("abc")', input[:res[0]] + "MatchCompiler::makeConstString(" + input[res[0]:res[1]] + ")" + input[res[1]:])
|
||||
|
||||
|
|
|
@ -21,5 +21,3 @@ do
|
|||
git checkout master
|
||||
git branch -D "$i"
|
||||
done
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue