ExprEngine: Clarify when analysis is aborted

This commit is contained in:
Daniel Marjamäki 2019-09-28 10:59:28 +02:00
parent a3cad7fa51
commit 0de3e76b2d
2 changed files with 8 additions and 3 deletions

View File

@ -820,6 +820,9 @@ static ExprEngine::ValuePtr executeFunctionCall(const Token *tok, Data &data)
}
}
if (!tok->valueType())
throw std::runtime_error("Expression '" + tok->expressionString() + "' has unknown type!");
auto val = getValueRangeFromValueType(data.getNewSymbolName(), tok->valueType(), *data.settings);
call(data.callbacks, tok, val);
return val;
@ -1011,8 +1014,10 @@ void ExprEngine::executeAllFunctions(const Tokenizer *tokenizer, const Settings
for (const Scope *functionScope : symbolDatabase->functionScopes) {
try {
executeFunction(functionScope, tokenizer, settings, callbacks);
} catch (const std::exception &) {
} catch (const std::exception &e) {
// FIXME.. there should not be exceptions
std::string functionName = functionScope->function->name();
std::cout << "Verify: Aborted analysis of function '" << functionName << "': " << e.what();
}
}
}

View File

@ -163,7 +163,7 @@ private:
}
void functionCall3() {
ASSERT_EQUALS("-2147483648:2147483647", getRange("void f() { int x = -1; fgets(stdin, \"%d\", &x); x=x; }", "x=x"));
ASSERT_EQUALS("-2147483648:2147483647", getRange("int fgets(int, const char *, void *); void f() { int x = -1; fgets(stdin, \"%d\", &x); x=x; }", "x=x"));
}
void if1() {
@ -195,7 +195,7 @@ private:
}
void localArray2() {
ASSERT_EQUALS("0:255", getRange("int f() { unsigned char arr[10] = \"\"; dostuff(arr); return arr[4]; }", "arr[4]"));
ASSERT_EQUALS("0:255", getRange("void dostuff(unsigned char *); int f() { unsigned char arr[10] = \"\"; dostuff(arr); return arr[4]; }", "arr[4]"));
}
void localArray3() {