diff options
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/cpptools/cppchecksymbols.cpp | 14 | ||||
| -rw-r--r-- | src/plugins/cpptools/cppchecksymbols.h | 2 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp index fbf27666060..6ac5843c11e 100644 --- a/src/plugins/cpptools/cppchecksymbols.cpp +++ b/src/plugins/cpptools/cppchecksymbols.cpp @@ -1240,6 +1240,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST { unsigned startToken = ast->firstToken(); bool isDestructor = false; + bool isConstructor = false; if (DestructorNameAST *dtor = ast->asDestructorName()) { isDestructor = true; if (dtor->unqualified_name) @@ -1264,6 +1265,8 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST if (isDestructor != c->name()->isDestructorNameId()) continue; + isConstructor = isConstructorDeclaration(c); + Function *funTy = c->type()->asFunctionType(); if (! funTy) { //Try to find a template function @@ -1296,7 +1299,9 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST } if (matchType != Match_None) { + // decide how constructor and destructor should be highlighted if (highlightCtorDtorAsType + && (isConstructor || isDestructor) && maybeType(ast->name) && kind == SemanticInfo::FunctionUse) { return false; @@ -1399,3 +1404,12 @@ void CheckSymbols::flush() _usages.clear(); _usages.reserve(cap); } + +bool CheckSymbols::isConstructorDeclaration(Symbol *declaration) +{ + Class *clazz = declaration->enclosingClass(); + if (clazz && clazz->name()) + return declaration->name()->isEqualTo(clazz->name()); + + return false; +} diff --git a/src/plugins/cpptools/cppchecksymbols.h b/src/plugins/cpptools/cppchecksymbols.h index 2b69e000815..51c032bb9c3 100644 --- a/src/plugins/cpptools/cppchecksymbols.h +++ b/src/plugins/cpptools/cppchecksymbols.h @@ -165,6 +165,8 @@ protected: void flush(); private: + bool isConstructorDeclaration(Symbol *declaration); + Document::Ptr _doc; LookupContext _context; TypeOfExpression typeOfExpression; |
