forked from qt-creator/qt-creator
Added support for override/final and enum classes
Change-Id: I6dfe9dd606781046ff5a1ed61315741d2f332cb8 Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
This commit is contained in:
committed by
Christian Kamm
parent
656ecfbf59
commit
95c5ab2746
@@ -506,6 +506,14 @@ bool CheckSymbols::visit(SimpleDeclarationAST *ast)
|
||||
decl->enclosingScope()),
|
||||
nameAST, funTy->argumentCount())) {
|
||||
declrIdNameAST = nameAST;
|
||||
|
||||
// Add a diagnostic message if non-virtual function has override/final marker
|
||||
if ((_usages.back().kind != SemanticInfo::VirtualMethodUse)) {
|
||||
if (funTy->isOverride())
|
||||
warning(declrIdNameAST, "Only virtual methods can be marked `override'");
|
||||
else if (funTy->isFinal())
|
||||
warning(declrIdNameAST, "Only virtual methods can be marked `final'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -952,6 +960,37 @@ bool CheckSymbols::visit(LabeledStatementAST *ast)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Highlights "override" and "final" pseudokeywords like true keywords
|
||||
*/
|
||||
bool CheckSymbols::visit(SimpleSpecifierAST *ast)
|
||||
{
|
||||
if (ast->specifier_token)
|
||||
{
|
||||
const Token &tk = tokenAt(ast->specifier_token);
|
||||
if (tk.is(T_IDENTIFIER))
|
||||
{
|
||||
const Identifier &id = *(tk.identifier);
|
||||
if (id.equalTo(_doc->control()->cpp11Override())
|
||||
|| id.equalTo(_doc->control()->cpp11Final()))
|
||||
{
|
||||
addUse(ast->specifier_token, SemanticInfo::PseudoKeywordUse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CheckSymbols::visit(ClassSpecifierAST *ast)
|
||||
{
|
||||
if (ast->final_token)
|
||||
addUse(ast->final_token, SemanticInfo::PseudoKeywordUse);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckSymbols::visit(FunctionDefinitionAST *ast)
|
||||
{
|
||||
AST *thisFunction = _astStack.takeLast();
|
||||
|
Reference in New Issue
Block a user