diff --git a/cfg/std.cfg b/cfg/std.cfg
index 047894a4f..d71e675e6 100644
--- a/cfg/std.cfg
+++ b/cfg/std.cfg
@@ -10,7 +10,7 @@
false
- arg1>0?arg1:-arg1
+ arg1>0?arg1:-arg1
diff --git a/lib/library.cpp b/lib/library.cpp
index 27b70c4b6..7aff6a0f3 100644
--- a/lib/library.cpp
+++ b/lib/library.cpp
@@ -545,9 +545,12 @@ 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())
+ else if (functionnodename == "returnValue" && functionnode->GetText()) {
_returnValue[name] = functionnode->GetText();
- else if (functionnodename == "arg") {
+ const char *type = functionnode->Attribute("type");
+ if (type)
+ _returnValueType[name] = type;
+ } else if (functionnodename == "arg") {
const char* argNrString = functionnode->Attribute("nr");
if (!argNrString)
return Error(MISSING_ATTRIBUTE, "nr");
@@ -995,6 +998,14 @@ std::string Library::returnValue(const Token *ftok) const
return it != _returnValue.end() ? it->second : std::string();
}
+std::string Library::returnValueType(const Token *ftok) const
+{
+ if (isNotLibraryFunction(ftok))
+ return std::string();
+ std::map::const_iterator it = _returnValueType.find(getFunctionName(ftok));
+ return it != _returnValueType.end() ? it->second : std::string();
+}
+
bool Library::isnoreturn(const Token *ftok) const
{
if (ftok->function() && ftok->function()->isAttributeNoreturn())
diff --git a/lib/library.h b/lib/library.h
index 282558f30..d57ca6755 100644
--- a/lib/library.h
+++ b/lib/library.h
@@ -166,6 +166,7 @@ public:
bool isUseRetVal(const Token* ftok) const;
std::string returnValue(const Token *ftok) const;
+ std::string returnValueType(const Token *ftok) const;
bool isnoreturn(const Token *ftok) const;
bool isnotnoreturn(const Token *ftok) const;
@@ -481,6 +482,7 @@ private:
std::set _functions;
std::map _noreturn; // is function noreturn?
std::map _returnValue;
+ std::map _returnValueType;
std::set _ignorefunction; // ignore functions/macros from a library (gtk, qt etc)
std::map _reporterrors;
std::map _processAfterCode;
diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp
index d57eac848..b9b563cb1 100644
--- a/lib/symboldatabase.cpp
+++ b/lib/symboldatabase.cpp
@@ -4602,6 +4602,12 @@ 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);