diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 8f019eabb..e267c6065 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3769,3 +3769,32 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens) } } } + +std::string ValueType::str() const +{ + std::string ret; + if (isIntegral()) { + if (sign == SIGNED) + ret = "signed "; + else if (sign == UNSIGNED) + ret = "unsigned "; + if (type == BOOL) + ret += "bool"; + else if (type == CHAR) + ret += "char"; + else if (type == SHORT) + ret += "short"; + else if (type == INT) + ret += "int"; + else if (type == LONG) + ret += "long"; + else if (type == LONGLONG) + ret += "long long"; + } else if (type == FLOAT) + ret = "float"; + else if (type == DOUBLE) + ret = "double"; + for (unsigned int p = 0; p < pointer; p++) + ret += "*"; + return ret; +} diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index aea05da64..d828b348b 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1039,7 +1039,7 @@ private: }; /** Value type */ -class ValueType { +class CPPCHECKLIB ValueType { public: enum Sign {UNKNOWN_SIGN, SIGNED, UNSIGNED} sign; enum Type {UNKNOWN_TYPE, NONSTD, BOOL, CHAR, SHORT, INT, LONG, LONGLONG, FLOAT, DOUBLE} type; @@ -1052,33 +1052,7 @@ public: return (type >= ValueType::Type::BOOL && type <= ValueType::Type::LONGLONG); } - std::string str() const { - std::string ret; - if (isIntegral()) { - if (sign == SIGNED) - ret = "signed "; - else if (sign == UNSIGNED) - ret = "unsigned "; - if (type == BOOL) - ret += "bool"; - else if (type == CHAR) - ret += "char"; - else if (type == SHORT) - ret += "short"; - else if (type == INT) - ret += "int"; - else if (type == LONG) - ret += "long"; - else if (type == LONGLONG) - ret += "long long"; - } else if (type == FLOAT) - ret = "float"; - else if (type == DOUBLE) - ret = "double"; - for (unsigned int p = 0; p < pointer; p++) - ret += "*"; - return ret; - } + std::string str() const; }; diff --git a/lib/valueflow.h b/lib/valueflow.h index 9587eeed3..c61110bee 100644 --- a/lib/valueflow.h +++ b/lib/valueflow.h @@ -30,7 +30,7 @@ class ErrorLogger; class Settings; namespace ValueFlow { - class Value { + class CPPCHECKLIB Value { public: explicit Value(long long val = 0) : intvalue(val), tokvalue(nullptr), varvalue(val), condition(0), varId(0U), conditional(false), inconclusive(false), defaultArg(false), valueKind(ValueKind::Possible) {} Value(const Token *c, long long val) : intvalue(val), tokvalue(nullptr), varvalue(val), condition(c), varId(0U), conditional(false), inconclusive(false), defaultArg(false), valueKind(ValueKind::Possible) {}