From 63bd29d644aef8c9f53a519a095218dedf95c10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 23 Jun 2019 13:54:33 +0200 Subject: [PATCH] addons/cppcheckdata.py: Add 'cppcheckdata.getArguments' function --- addons/cppcheckdata.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/addons/cppcheckdata.py b/addons/cppcheckdata.py index d5097937f..4e067fc92 100755 --- a/addons/cppcheckdata.py +++ b/addons/cppcheckdata.py @@ -757,6 +757,25 @@ class CppcheckData: self.configurations.append(Configuration(cfgnode)) +# Get function arguments +def getArgumentsRecursive(tok, arguments): + if tok is None: + return + if tok.str == ',': + getArgumentsRecursive(tok.astOperand1, arguments) + getArgumentsRecursive(tok.astOperand2, arguments) + else: + arguments.append(tok) + + +def getArguments(ftok): + if (not ftok.isName) or (ftok.next is None) or ftok.next.str != '(': + return None + args = [] + getArgumentsRecursive(ftok.next.astOperand2, args) + return args + + def parsedump(filename): """ parse a cppcheck dump file