Update the detection of the arguments in Qt's invokeMethod.

invokeMethod can invoke functions by name (string) rather than a
direct function call (i.e. reflection). The old code wasn't
correctly parsing out the argument which contained the name
of the function to call.

This resulted in that function being reported as unused when it is.
This commit is contained in:
Sam Truscott 2014-03-13 16:43:25 +00:00
parent 61eb262244
commit 3d0524ecc6
2 changed files with 17 additions and 4 deletions

View File

@ -63,7 +63,7 @@
<!-- qt can call methods as strings using invokeMethod -->
<reflection>
<call arg="4">invokeMethod</call>
<call arg="2">invokeMethod</call>
</reflection>
<!-- the SLOT/SIGNAL methods can be cause false-positives for pure

View File

@ -170,9 +170,22 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
if (settings->library.isreflection(tok->str())) {
const int index = settings->library.reflectionArgument(tok->str());
if (index >= 0) {
const Token * funcToken = tok->tokAt(index);
if (funcToken) {
std::string value = funcToken->str();
const Token * funcToken = tok->next();
int p = 0;
std::string value;
while(funcToken) {
if (funcToken->str()==",") {
p++;
if (p==index) {
break;
}
value = "";
} else {
value += funcToken->str();
}
funcToken = funcToken->next();
}
if (p==index) {
value = value.substr(1, value.length() - 2);
_functions[value].usedOtherFile = true;
}