Esempio n. 1
0
QString CPlusPlus::toString(const LookupItem &it, const QString &id)
{
    QString result = QString::fromLatin1("%1:").arg(id);
    if (it.declaration())
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.declaration(), QLatin1String("Decl")))));
    if (it.type().isValid())
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.type()))));
    if (it.scope())
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.scope(), QLatin1String("Scope")))));
    if (it.binding())
        result.append(QString::fromLatin1("\n%1").arg(indent(toString(it.binding(), QLatin1String("Binding")))));
    return result;
}
Esempio n. 2
0
bool TypeResolver::findTypedef(const QList<LookupItem> &namedTypeItems, FullySpecifiedType *type,
                               Scope **scope, QSet<Symbol *> &visited)
{
    foreach (const LookupItem &it, namedTypeItems) {
        Symbol *declaration = it.declaration();
        if (!declaration)
            continue;
        if (Template *specialization = declaration->asTemplate())
            declaration = specialization->declaration();
        if (!declaration || (!declaration->isTypedef() && !declaration->type().isDecltype()))
            continue;
        if (visited.contains(declaration))
            break;
        visited.insert(declaration);

        // continue working with the typedefed type and scope
        if (type->type()->isPointerType()) {
            *type = FullySpecifiedType(
                        _factory.control()->pointerType(declaration->type()));
        } else if (type->type()->isReferenceType()) {
            *type = FullySpecifiedType(
                        _factory.control()->referenceType(
                            declaration->type(),
                            declaration->type()->asReferenceType()->isRvalueReference()));
        } else if (declaration->type().isDecltype()) {
            Declaration *decl = declaration->asDeclaration();
            const QList<LookupItem> resolved =
                    resolveDeclInitializer(_factory, decl, QSet<const Declaration* >() << decl);
            if (!resolved.isEmpty()) {
                LookupItem item = resolved.first();
                *type = item.type();
                *scope = item.scope();
                _binding = item.binding();
                return true;
            }
        } else {
            *type = it.type();
        }

        *scope = it.scope();
        _binding = it.binding();
        return true;
    }