Commit 1c3c5094 authored by Erik Verbruggen's avatar Erik Verbruggen

C++: fixed highlighting of expressions inside a sizeof() operator.

Task-number: QTCREATORBUG-5129

Change-Id: Ibe0a6a7925a4f0e5b52207079f28a3fa4bb95745
Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent f3155987
......@@ -106,15 +106,15 @@ protected:
}
}
virtual bool visit(IdExpressionAST *ast)
bool checkLocalUse(NameAST *nameAst, unsigned firstToken)
{
if (SimpleNameAST *simpleName = ast->name->asSimpleName()) {
if (SimpleNameAST *simpleName = nameAst->asSimpleName()) {
const Identifier *id = identifier(simpleName->identifier_token);
for (int i = _scopeStack.size() - 1; i != -1; --i) {
if (Symbol *member = _scopeStack.at(i)->find(id)) {
if (member->isTypedef())
if (member->isTypedef() || !member->isDeclaration())
continue;
else if (!member->isGenerated() && (member->sourceLocation() < ast->firstToken() || member->enclosingScope()->isFunction())) {
else if (!member->isGenerated() && (member->sourceLocation() < firstToken || member->enclosingScope()->isFunction())) {
unsigned line, column;
getTokenStartPosition(simpleName->identifier_token, &line, &column);
localUses[member].append(SemanticInfo::Use(line, column, id->size(), SemanticInfo::LocalUse));
......@@ -127,6 +127,26 @@ protected:
return true;
}
virtual bool visit(IdExpressionAST *ast)
{
return checkLocalUse(ast->name, ast->firstToken());
}
virtual bool visit(SizeofExpressionAST *ast)
{
if (ast->expression && ast->expression->asTypeId()) {
TypeIdAST *typeId = ast->expression->asTypeId();
if (!typeId->declarator && typeId->type_specifier_list && !typeId->type_specifier_list->next) {
if (NamedTypeSpecifierAST *namedTypeSpec = typeId->type_specifier_list->value->asNamedTypeSpecifier()) {
if (checkLocalUse(namedTypeSpec->name, namedTypeSpec->firstToken()))
return false;
}
}
}
return true;
}
virtual bool visit(QtMemberDeclarationAST *ast)
{
if (tokenKind(ast->q_token) == T_Q_D)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment