SymbolDatabase: Refactoring handling of library-function return type

This commit is contained in:
Daniel Marjamäki 2016-10-23 23:20:36 +02:00
parent c8f831b70d
commit f973a9a9d5
2 changed files with 19 additions and 10 deletions

View File

@ -545,10 +545,10 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
leakignore.insert(name);
else if (functionnodename == "use-retval")
_useretval.insert(name);
else if (functionnodename == "returnValue" && functionnode->GetText()) {
_returnValue[name] = functionnode->GetText();
const char *type = functionnode->Attribute("type");
if (type)
else if (functionnodename == "returnValue") {
if (const char *expr = functionnode->GetText())
_returnValue[name] = expr;
if (const char *type = functionnode->Attribute("type"))
_returnValueType[name] = type;
} else if (functionnodename == "arg") {
const char* argNrString = functionnode->Attribute("nr");

View File

@ -4602,12 +4602,6 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens, bool cpp, const Sett
::setValueType(tok, valuetype, cpp, defsign, settings);
}
// library function
else if (tok->previous() && settings->library.returnValueType(tok->previous()) == "int") {
ValueType valuetype(ValueType::Sign::SIGNED, ValueType::Type::INT, 0U);
::setValueType(tok, valuetype, cpp, defsign, settings);
}
else if (Token::simpleMatch(tok->previous(), "sizeof (")) {
// TODO: use specified size_t type
ValueType valuetype(ValueType::Sign::UNSIGNED, ValueType::Type::LONG, 0U);
@ -4621,6 +4615,21 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens, bool cpp, const Sett
}
}
}
// library function
else if (tok->previous()) {
const std::string typestr(settings->library.returnValueType(tok->previous()));
if (typestr.empty())
continue;
TokenList tokenList(settings);
std::istringstream istr(typestr+";");
if (tokenList.createTokens(istr)) {
ValueType vt;
if (parsedecl(tokenList.front(), &vt, defsign, settings)) {
setValueType(tok, vt, cpp, defsign, settings);
}
}
}
} else if (tok->variable()) {
setValueType(tok, *tok->variable(), cpp, defsign, settings);
} else if (tok->enumerator()) {