From f8db0ae7ce4146ea85b6511a46eca01d9af4b9cc Mon Sep 17 00:00:00 2001 From: Erik Verbruggen <erik.verbruggen@nokia.com> Date: Wed, 19 Jan 2011 14:14:19 +0100 Subject: [PATCH] Prevent preleminary flushes to prevent order mess-ups. The semantic highlighter relies on the highlight ranges to be subsequent and non-overlapping. A method body in a class nested in a method can result in flushes before the semantic info for the enclosing method is calculated, resulting in overlapping ranges. Task-number: QTCREATORBUG-3364 Reviewed-by: Roberto Raggi --- src/plugins/cppeditor/cppchecksymbols.cpp | 11 ++++++++--- src/plugins/cppeditor/cppchecksymbols.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/cppeditor/cppchecksymbols.cpp b/src/plugins/cppeditor/cppchecksymbols.cpp index 63b02305c2e..0e60ec0e327 100644 --- a/src/plugins/cppeditor/cppchecksymbols.cpp +++ b/src/plugins/cppeditor/cppchecksymbols.cpp @@ -343,9 +343,12 @@ bool CheckSymbols::warning(AST *ast, const QString &text) return false; } -FunctionDefinitionAST *CheckSymbols::enclosingFunctionDefinition() const +FunctionDefinitionAST *CheckSymbols::enclosingFunctionDefinition(bool skipTopOfStack) const { - for (int index = _astStack.size() - 1; index != -1; --index) { + int index = _astStack.size() - 1; + if (skipTopOfStack && !_astStack.isEmpty()) + --index; + for (; index != -1; --index) { AST *ast = _astStack.at(index); if (FunctionDefinitionAST *funDef = ast->asFunctionDefinition()) @@ -791,7 +794,9 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast) addUse(u); } - flush(); + if (!enclosingFunctionDefinition(true)) + flush(); + return false; } diff --git a/src/plugins/cppeditor/cppchecksymbols.h b/src/plugins/cppeditor/cppchecksymbols.h index 9adedd65565..d4dda4fe97a 100644 --- a/src/plugins/cppeditor/cppchecksymbols.h +++ b/src/plugins/cppeditor/cppchecksymbols.h @@ -124,7 +124,7 @@ protected: bool isTemplateClass(Symbol *s) const; Scope *enclosingScope() const; - FunctionDefinitionAST *enclosingFunctionDefinition() const; + FunctionDefinitionAST *enclosingFunctionDefinition(bool skipTopOfStack = false) const; TemplateDeclarationAST *enclosingTemplateDeclaration() const; virtual bool preVisit(AST *); -- GitLab