ValueType: Allow that type is library-container

This commit is contained in:
Daniel Marjamäki 2017-03-05 02:09:52 +01:00
parent c832b2f40b
commit 115ea08544
2 changed files with 23 additions and 13 deletions

View File

@ -4649,14 +4649,21 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
if (type->str() == "const")
valuetype->constness |= (1 << (valuetype->pointer - pointer0));
else if (Token::Match(type, "%name% :: %name%")) {
const Library::Container *container = settings->library.detectContainer(type);
if (container) {
valuetype->type = ValueType::Type::NONSTD;
valuetype->container = container;
} else {
std::string typestr;
const Token *end = type;
while (Token::Match(end, "%name% :: %name%")) {
typestr += end->str() + "::";
end = end->tokAt(2);
}
if (valuetype->fromLibraryType(typestr + end->str(), settings))
typestr += end->str();
if (valuetype->fromLibraryType(typestr, settings))
type = end;
}
} else if (ValueType::Type::UNKNOWN_TYPE != ValueType::typeFromString(type->str(), type->isLong()))
valuetype->type = ValueType::typeFromString(type->str(), type->isLong());
else if (type->str() == "auto") {
@ -4989,6 +4996,8 @@ std::string ValueType::str() const
scope = scope->nestedIn;
}
ret += ' ' + className;
} else if (type == NONSTD && container) {
ret += " container(" + container->startPattern + ')';
}
for (unsigned int p = 0; p < pointer; p++) {
ret += " *";

View File

@ -31,11 +31,11 @@
#include "config.h"
#include "token.h"
#include "mathlib.h"
#include "library.h"
class Tokenizer;
class Settings;
class ErrorLogger;
class Library;
class Scope;
class SymbolDatabase;
@ -1163,13 +1163,14 @@ public:
unsigned int pointer; // 0=>not pointer, 1=>*, 2=>**, 3=>***, etc
unsigned int constness; // bit 0=data, bit 1=*, bit 2=**
const Scope *typeScope;
const Library::Container *container;
std::string originalTypeName;
ValueType() : sign(UNKNOWN_SIGN), type(UNKNOWN_TYPE), pointer(0U), constness(0U), typeScope(nullptr) {}
ValueType(const ValueType &vt) : sign(vt.sign), type(vt.type), pointer(vt.pointer), constness(vt.constness), typeScope(vt.typeScope), originalTypeName(vt.originalTypeName) {}
ValueType(enum Sign s, enum Type t, unsigned int p) : sign(s), type(t), pointer(p), constness(0U), typeScope(nullptr) {}
ValueType(enum Sign s, enum Type t, unsigned int p, unsigned int c) : sign(s), type(t), pointer(p), constness(c), typeScope(nullptr) {}
ValueType(enum Sign s, enum Type t, unsigned int p, unsigned int c, const std::string &otn) : sign(s), type(t), pointer(p), constness(c), typeScope(nullptr), originalTypeName(otn) {}
ValueType() : sign(UNKNOWN_SIGN), type(UNKNOWN_TYPE), pointer(0U), constness(0U), typeScope(nullptr), container(nullptr) {}
ValueType(const ValueType &vt) : sign(vt.sign), type(vt.type), pointer(vt.pointer), constness(vt.constness), typeScope(vt.typeScope), container(vt.container), originalTypeName(vt.originalTypeName) {}
ValueType(enum Sign s, enum Type t, unsigned int p) : sign(s), type(t), pointer(p), constness(0U), typeScope(nullptr), container(nullptr) {}
ValueType(enum Sign s, enum Type t, unsigned int p, unsigned int c) : sign(s), type(t), pointer(p), constness(c), typeScope(nullptr), container(nullptr) {}
ValueType(enum Sign s, enum Type t, unsigned int p, unsigned int c, const std::string &otn) : sign(s), type(t), pointer(p), constness(c), typeScope(nullptr), container(nullptr), originalTypeName(otn) {}
static ValueType parseDecl(const Token *type, const Settings *settings);