SymbolDatabase::findFunction: Use ValueType::matchParameter for float literal parameters
This commit is contained in:
parent
cccbfaa0e4
commit
ed5ae7c5fa
|
@ -59,6 +59,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
createSymbolDatabaseVariableSymbolTable();
|
createSymbolDatabaseVariableSymbolTable();
|
||||||
createSymbolDatabaseSetScopePointers();
|
createSymbolDatabaseSetScopePointers();
|
||||||
createSymbolDatabaseSetVariablePointers();
|
createSymbolDatabaseSetVariablePointers();
|
||||||
|
setValueTypeInTokenList();
|
||||||
createSymbolDatabaseSetFunctionPointers(true);
|
createSymbolDatabaseSetFunctionPointers(true);
|
||||||
createSymbolDatabaseSetTypePointers();
|
createSymbolDatabaseSetTypePointers();
|
||||||
createSymbolDatabaseEnums();
|
createSymbolDatabaseEnums();
|
||||||
|
@ -4265,32 +4266,13 @@ const Function* Scope::findFunction(const Token *tok, bool requireConst) const
|
||||||
fallback2++;
|
fallback2++;
|
||||||
}
|
}
|
||||||
} else if (!funcarg->isPointer()) {
|
} else if (!funcarg->isPointer()) {
|
||||||
bool exactMatch = false;
|
ValueType::MatchResult res = ValueType::matchParameter(arguments[j]->valueType(), funcarg->valueType());
|
||||||
if (arguments[j]->str().find('f') != std::string::npos ||
|
if (res == ValueType::MatchResult::SAME)
|
||||||
arguments[j]->str().find('F') != std::string::npos) {
|
++same;
|
||||||
if (funcarg->typeStartToken()->str() == "float") {
|
else if (res == ValueType::MatchResult::FALLBACK1)
|
||||||
exactMatch = true;
|
++fallback1;
|
||||||
}
|
else if (res == ValueType::MatchResult::FALLBACK2)
|
||||||
} else if (arguments[j]->str().find('l') != std::string::npos ||
|
++fallback2;
|
||||||
arguments[j]->str().find('L') != std::string::npos) {
|
|
||||||
if (funcarg->typeStartToken()->isLong() &&
|
|
||||||
funcarg->typeStartToken()->str() == "double") {
|
|
||||||
exactMatch = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!funcarg->typeStartToken()->isLong() &&
|
|
||||||
funcarg->typeStartToken()->str() == "double") {
|
|
||||||
exactMatch = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (exactMatch)
|
|
||||||
same++;
|
|
||||||
else {
|
|
||||||
if (Token::Match(funcarg->typeStartToken(), "float|double"))
|
|
||||||
fallback1++;
|
|
||||||
else if (Token::Match(funcarg->typeStartToken(), "wchar_t|char|short|int|long"))
|
|
||||||
fallback2++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5902,12 +5884,23 @@ ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const Va
|
||||||
return ValueType::MatchResult::UNKNOWN; // TODO
|
return ValueType::MatchResult::UNKNOWN; // TODO
|
||||||
if ((call->constness | func->constness) != func->constness)
|
if ((call->constness | func->constness) != func->constness)
|
||||||
return ValueType::MatchResult::UNKNOWN;
|
return ValueType::MatchResult::UNKNOWN;
|
||||||
if (call->sign != func->sign)
|
if (call->type != func->type) {
|
||||||
return ValueType::MatchResult::UNKNOWN; // TODO
|
if (call->isIntegral() && func->isIntegral())
|
||||||
if (call->type != func->type)
|
return ValueType::MatchResult::FALLBACK1;
|
||||||
|
else if (call->isFloat() && func->isFloat())
|
||||||
|
return ValueType::MatchResult::FALLBACK1;
|
||||||
|
else if (call->isIntegral() && func->isFloat())
|
||||||
|
return ValueType::MatchResult::FALLBACK2;
|
||||||
|
else if (call->isFloat() && func->isIntegral())
|
||||||
|
return ValueType::MatchResult::FALLBACK2;
|
||||||
return ValueType::MatchResult::UNKNOWN; // TODO
|
return ValueType::MatchResult::UNKNOWN; // TODO
|
||||||
|
}
|
||||||
|
|
||||||
if (func->type < ValueType::Type::VOID || func->type == ValueType::Type::UNKNOWN_INT)
|
if (func->type < ValueType::Type::VOID || func->type == ValueType::Type::UNKNOWN_INT)
|
||||||
return ValueType::MatchResult::UNKNOWN;
|
return ValueType::MatchResult::UNKNOWN;
|
||||||
|
|
||||||
|
if (call->isIntegral() && func->isIntegral() && call->sign != func->sign)
|
||||||
|
return ValueType::MatchResult::UNKNOWN; // TODO
|
||||||
|
|
||||||
return ValueType::MatchResult::SAME;
|
return ValueType::MatchResult::SAME;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ public:
|
||||||
|
|
||||||
static Type typeFromString(const std::string &typestr, bool longType);
|
static Type typeFromString(const std::string &typestr, bool longType);
|
||||||
|
|
||||||
enum class MatchResult { UNKNOWN, SAME, FALLBACK };
|
enum class MatchResult { UNKNOWN, SAME, FALLBACK1, FALLBACK2 };
|
||||||
static MatchResult matchParameter(const ValueType *call, const ValueType *func);
|
static MatchResult matchParameter(const ValueType *call, const ValueType *func);
|
||||||
|
|
||||||
bool isIntegral() const {
|
bool isIntegral() const {
|
||||||
|
|
Loading…
Reference in New Issue