/// Return all typedefs with given name from given scope up to function scope.
 static QList<LookupItem> typedefsFromScopeUpToFunctionScope(const Name *name, Scope *scope)
 {
     QList<LookupItem> results;
     if (!scope)
         return results;
     Scope *enclosingBlockScope = 0;
     for (Block *block = scope->asBlock(); block;
          block = enclosingBlockScope ? enclosingBlockScope->asBlock() : 0) {
         const unsigned memberCount = block->memberCount();
         for (unsigned i = 0; i < memberCount; ++i) {
             Symbol *symbol = block->memberAt(i);
             if (Declaration *declaration = symbol->asDeclaration()) {
                 if (isTypedefWithName(declaration, name)) {
                     LookupItem item;
                     item.setDeclaration(declaration);
                     item.setScope(block);
                     item.setType(declaration->type());
                     results.append(item);
                 }
             }
         }
         enclosingBlockScope = block->enclosingScope();
     }
     return results;
 }
Exemple #2
0
Block *Symbol::enclosingBlock() const
{
    for (Scope *s = _enclosingScope; s; s = s->enclosingScope()) {
        if (Block *block = s->asBlock())
            return block;
    }
    return 0;
}