ExprEngine: Guess function call return value
This commit is contained in:
parent
5c07cfd2e8
commit
6e17853ea9
|
@ -606,7 +606,7 @@ static ExprEngine::ValuePtr executeExpression(const Token *tok, Data &data)
|
||||||
if (tok->astOperand1() && tok->astOperand2() && tok->str() == "[")
|
if (tok->astOperand1() && tok->astOperand2() && tok->str() == "[")
|
||||||
return executeArrayIndex(tok, data);
|
return executeArrayIndex(tok, data);
|
||||||
|
|
||||||
if (tok->str() == "(" && tok->astOperand2())
|
if (tok->str() == "(" && !tok->isCast())
|
||||||
return executeFunctionCall(tok, data);
|
return executeFunctionCall(tok, data);
|
||||||
|
|
||||||
if (tok->str() == ".")
|
if (tok->str() == ".")
|
||||||
|
|
|
@ -41,6 +41,7 @@ private:
|
||||||
TEST_CASE(exprAssign1);
|
TEST_CASE(exprAssign1);
|
||||||
|
|
||||||
TEST_CASE(functionCall1);
|
TEST_CASE(functionCall1);
|
||||||
|
TEST_CASE(functionCall2);
|
||||||
|
|
||||||
TEST_CASE(if1);
|
TEST_CASE(if1);
|
||||||
TEST_CASE(if2);
|
TEST_CASE(if2);
|
||||||
|
@ -127,6 +128,17 @@ private:
|
||||||
ASSERT_EQUALS("-2147483648:2147483647", getRange("int atoi(const char *p); void f() { int x = atoi(a); x = x; }", "x=x"));
|
ASSERT_EQUALS("-2147483648:2147483647", getRange("int atoi(const char *p); void f() { int x = atoi(a); x = x; }", "x=x"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void functionCall2() {
|
||||||
|
const char code[] = "namespace NS {\n"
|
||||||
|
" short getValue();\n"
|
||||||
|
"}"
|
||||||
|
"void f() {\n"
|
||||||
|
" short value = NS::getValue();\n"
|
||||||
|
" value = value;\n"
|
||||||
|
"}";
|
||||||
|
ASSERT_EQUALS("-32768:32767", getRange(code, "value=value"));
|
||||||
|
}
|
||||||
|
|
||||||
void if1() {
|
void if1() {
|
||||||
ASSERT_EQUALS("7:32768", getRange("inf f(short x) { if (x > 5) a = x + 1; }", "x+1"));
|
ASSERT_EQUALS("7:32768", getRange("inf f(short x) { if (x > 5) a = x + 1; }", "x+1"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue