some small *.py script cleanup (#1328)

* added CLion project folder to .gitignore

* adjusted project name in CMakeLists.txt

* avoid warning when compiling "Debug" with Visual Studio via CMake

There was a GCC-style compiler flag in the common flags in compileroptions.cmake which caused the following warning:
cl : Command line warning D9002 : ignoring unknown option '-O0'

* compileroptions.cmake: restored original formatting

* some small *.py script cleanups
This commit is contained in:
Oliver Stöneberg 2018-08-05 20:36:21 +02:00 committed by Daniel Marjamäki
parent a24c3b1d36
commit 13cf982b77
5 changed files with 13 additions and 12 deletions

View File

@ -35,7 +35,7 @@ def isUnpackedStruct(token):
if token.valueType is None: if token.valueType is None:
return False return False
if token.valueType.typeScope is None: if token.valueType.typeScope is None:
return False; return False
if token.valueType.typeScope.type != "Struct": if token.valueType.typeScope.type != "Struct":
return False return False
startToken = token.valueType.typeScope.bodyStart startToken = token.valueType.typeScope.bodyStart
@ -78,7 +78,8 @@ def getArgumentsRecursive(tok, arguments):
getArgumentsRecursive(tok.astOperand1, arguments) getArgumentsRecursive(tok.astOperand1, arguments)
getArgumentsRecursive(tok.astOperand2, arguments) getArgumentsRecursive(tok.astOperand2, arguments)
else: else:
arguments.append(tok); arguments.append(tok)
def getArguments(ftok): def getArguments(ftok):
arguments = [] arguments = []

View File

@ -776,7 +776,7 @@ def reportError(template, callstack=(), severity='', message='', errorId='', sup
:param template: format string, or 'gcc', 'vs' or 'edit'. :param template: format string, or 'gcc', 'vs' or 'edit'.
:param callstack: e.g. [['file1.cpp',10],['file2.h','20'], ... ] :param callstack: e.g. [['file1.cpp',10],['file2.h','20'], ... ]
:param severity: e.g. 'error', 'warning' ... :param severity: e.g. 'error', 'warning' ...
:param id: message ID. :param errorId: message ID.
:param message: message text. :param message: message text.
""" """
# expand predefined templates # expand predefined templates

View File

@ -39,7 +39,7 @@ def getArgumentsRecursive(tok, arguments):
getArgumentsRecursive(tok.astOperand1, arguments) getArgumentsRecursive(tok.astOperand1, arguments)
getArgumentsRecursive(tok.astOperand2, arguments) getArgumentsRecursive(tok.astOperand2, arguments)
else: else:
arguments.append(tok); arguments.append(tok)
def getArguments(ftok): def getArguments(ftok):
arguments = [] arguments = []

View File

@ -299,7 +299,7 @@ def isFloatCounterInWhileLoop(whileToken):
else: else:
return False return False
token = whileBodyStart token = whileBodyStart
while (token != whileBodyStart.link): while token != whileBodyStart.link:
token = token.next token = token.next
for counterToken in counterTokens: for counterToken in counterTokens:
if not counterToken.valueType or not counterToken.valueType.isFloat(): if not counterToken.valueType or not counterToken.valueType.isFloat():
@ -480,7 +480,7 @@ def isHexDigit(c):
def isOctalDigit(c): def isOctalDigit(c):
return (c >= '0' and c <= '7') return c >= '0' and c <= '7'
def isNoReturnScope(tok): def isNoReturnScope(tok):
@ -591,7 +591,7 @@ def misra_5_2(data):
else: else:
reportError(variable2.nameToken, 5, 2) reportError(variable2.nameToken, 5, 2)
for innerscope in scopeVars[scope]["scopelist"]: for innerscope in scopeVars[scope]["scopelist"]:
if (variable1.nameToken.str[:31] == innerscope.className[:31]): if variable1.nameToken.str[:31] == innerscope.className[:31]:
if int(variable1.nameToken.linenr) > int(innerscope.bodyStart.linenr): if int(variable1.nameToken.linenr) > int(innerscope.bodyStart.linenr):
reportError(variable1.nameToken, 5, 2) reportError(variable1.nameToken, 5, 2)
else: else:
@ -600,7 +600,7 @@ def misra_5_2(data):
continue continue
for i, scopename1 in enumerate(scopeVars[scope]["scopelist"]): for i, scopename1 in enumerate(scopeVars[scope]["scopelist"]):
for scopename2 in scopeVars[scope]["scopelist"][i + 1:]: for scopename2 in scopeVars[scope]["scopelist"][i + 1:]:
if (scopename1.className[:31] == scopename2.className[:31]): if scopename1.className[:31] == scopename2.className[:31]:
if int(scopename1.bodyStart.linenr) > int(scopename2.bodyStart.linenr): if int(scopename1.bodyStart.linenr) > int(scopename2.bodyStart.linenr):
reportError(scopename1.bodyStart, 5, 2) reportError(scopename1.bodyStart, 5, 2)
else: else:
@ -642,7 +642,7 @@ def misra_5_3(data):
reportError(outerVar.nameToken, 5, 3) reportError(outerVar.nameToken, 5, 3)
outerScope = outerScope.nestedIn outerScope = outerScope.nestedIn
for scope in data.scopes: for scope in data.scopes:
if (scope.className and innerVar.nameToken.str[:31] == scope.className[:31]): if scope.className and innerVar.nameToken.str[:31] == scope.className[:31]:
if int(innerVar.nameToken.linenr) > int(scope.bodyStart.linenr): if int(innerVar.nameToken.linenr) > int(scope.bodyStart.linenr):
reportError(innerVar.nameToken, 5, 3) reportError(innerVar.nameToken, 5, 3)
else: else:
@ -656,7 +656,7 @@ def misra_5_3(data):
reportError(innerScope.bodyStart, 5, 3) reportError(innerScope.bodyStart, 5, 3)
for e in enum: for e in enum:
for scope in data.scopes: for scope in data.scopes:
if (scope.className and scope.className[:31] == e[:31]): if scope.className and scope.className[:31] == e[:31]:
reportError(scope.bodyStart, 5, 3) reportError(scope.bodyStart, 5, 3)

View File

@ -27,7 +27,7 @@ def clang_ast(sourcefile):
while len(line)>1 and line[-1] in ' \r\n': while len(line)>1 and line[-1] in ' \r\n':
line = line[:-1] line = line[:-1]
if line.find('/usr/') > 0: if line.find('/usr/') > 0:
continue continue
if line.startswith('<Function'): if line.startswith('<Function'):
ret.append(line) ret.append(line)
ret.sort() ret.sort()
@ -54,7 +54,7 @@ def cppcheck_ast(sourcefile):
continue continue
argStart = scope.bodyStart argStart = scope.bodyStart
while argStart and argStart.str != '(': while argStart and argStart.str != '(':
argStart = argStart.previous argStart = argStart.previous
s = '<Function' s = '<Function'
s = s + ' name="' + scope.className + '"' s = s + ' name="' + scope.className + '"'
s = s + ' filename="' + argStart.file + '"' s = s + ' filename="' + argStart.file + '"'