From e08ee3bac771bc5e8ebf4b2c3862a80d28ff04a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 24 Jul 2021 19:34:11 +0200 Subject: [PATCH] addons; Add get_function_call_name_args --- addons/cppcheckdata.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index ec0e73b8f..24d9c642d 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -1275,6 +1275,36 @@ def simpleMatch(token, pattern): token = token.next return True +def get_function_call_name_args(token): + """Get function name and arguments for function call + name, args = get_function_call_name_args(tok) + """ + if token is None: + return None, None + if not token.isName or not token.scope.isExecutable: + return None, None + if not simpleMatch(token.next, '('): + return None, None + if token.function: + nametok = token.function.token + if token in (token.function.token, token.function.tokenDef): + return None, None + name = nametok.str + while nametok.previous and nametok.previous.previous and nametok.previous.str == '::' and nametok.previous.previous.isName: + name = nametok.previous.previous.str + '::' + name + nametok = nametok.previous.previous + scope = token.function.nestedIn + while scope: + if scope.className: + name = scope.className + '::' + name + scope = scope.nestedIn + else: + nametok = token + name = nametok.str + while nametok.previous and nametok.previous.previous and nametok.previous.str == '::' and nametok.previous.previous.isName: + name = nametok.previous.previous.str + '::' + name + nametok = nametok.previous.previous + return name, getArguments(token) def is_suppressed(location, message, errorId): for suppression in current_dumpfile_suppressions: