SymbolDatabase: Type lookup for clang type strings

This commit is contained in:
Daniel Marjamäki 2020-01-11 21:24:15 +01:00
parent cde757bcd3
commit 668212ac2f
2 changed files with 21 additions and 1 deletions

View File

@ -392,7 +392,7 @@ void clangimport::AstNode::setValueType(Token *tok)
ValueType valueType = ValueType::parseDecl(decl.front(), mData->mSettings);
if (valueType.type != ValueType::Type::UNKNOWN_TYPE)
tok->setValueType(new ValueType(valueType.sign, valueType.type, valueType.pointer, valueType.constness));
tok->setValueType(new ValueType(valueType));
}
Scope *clangimport::AstNode::createScope(TokenList *tokenList, Scope::ScopeType scopeType, AstNodePtr astNode)

View File

@ -5530,6 +5530,26 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V
parsedecl(type->type()->typeStart, valuetype, defaultSignedness, settings);
else if (type->str() == "const")
valuetype->constness |= (1 << (valuetype->pointer - pointer0));
else if (settings->clang && type->str().find("::") != std::string::npos && type->str().size() > 2) {
TokenList typeTokens(settings);
std::string::size_type pos1 = 0;
do {
std::string::size_type pos2 = type->str().find("::", pos1);
if (pos2 == std::string::npos) {
typeTokens.addtoken(type->str().substr(pos1), 0, 0, false);
break;
}
typeTokens.addtoken(type->str().substr(pos1, pos2 - pos1), 0, 0, false);
typeTokens.addtoken("::", 0, 0, false);
pos1 = pos2 + 2;
}
while (pos1 < type->str().size());
const Library::Container *container = settings->library.detectContainer(typeTokens.front());
if (container) {
valuetype->type = ValueType::Type::CONTAINER;
valuetype->container = container;
}
}
else if (const Library::Container *container = settings->library.detectContainer(type)) {
valuetype->type = ValueType::Type::CONTAINER;
valuetype->container = container;