C++: Resolve function-scope typedef inside lambda

Use-case:
struct Foo { int bar; };

void func()
{
    typedef Foo F;
    []() {
        F f;
        f.bar; // bar not highlighted
    };
}

Change-Id: Ifaee2d125931d993acad69f03031a675c6180858
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-06-28 22:28:44 +03:00
committed by Orgad Shaneh
parent 1faf2bd1ef
commit f8544bbc42
2 changed files with 22 additions and 0 deletions

View File

@@ -154,6 +154,13 @@ QList<LookupItem> TypeResolver::typedefsFromScopeUpToFunctionScope(const Name *n
}
}
enclosingBlockScope = block->enclosingScope();
if (enclosingBlockScope) {
// For lambda, step beyond the function to its enclosing block
if (Function *enclosingFunction = enclosingBlockScope->asFunction()) {
if (!enclosingFunction->name())
enclosingBlockScope = enclosingBlockScope->enclosingScope();
}
}
}
return results;
}