diff options
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r-- | src/libs/cplusplus/ResolveExpression.cpp | 32 | ||||
-rw-r--r-- | src/libs/cplusplus/ResolveExpression.h | 20 |
2 files changed, 44 insertions, 8 deletions
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index ed0253b6a7..a9b86e978e 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -49,6 +49,8 @@ using namespace CPlusPlus; namespace { +const bool debug = ! qgetenv("CPLUSPLUS_DEBUG").isEmpty(); + template <typename _Tp> static QList<_Tp> removeDuplicates(const QList<_Tp> &results) { @@ -563,6 +565,36 @@ bool ResolveExpression::visit(MemberAccessAST *ast) return false; } +ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &baseResults, + int accessOp, + bool *replacedDotOperator) const +{ + foreach (const LookupItem &r, baseResults) { + FullySpecifiedType ty = r.type().simplified(); + + if (accessOp == T_DOT) { + if (PointerType *ptrTy = ty->asPointerType()) { + ty = ptrTy->elementType(); + + if (replacedDotOperator) + *replacedDotOperator = true; + } + } + + if (Class *klass = ty->asClassType()) { + if (ClassOrNamespace *binding = _context.classOrNamespace(klass)) + return binding; + + } else if (NamedType *namedTy = ty->asNamedType()) { + if (ClassOrNamespace *binding = _context.classOrNamespace(namedTy->name(), r.scope())) + return binding; + } + } + + return 0; +} + + QList<LookupItem> ResolveExpression::resolveBaseExpression(const QList<LookupItem> &baseResults, int accessOp, bool *replacedDotOperator) const diff --git a/src/libs/cplusplus/ResolveExpression.h b/src/libs/cplusplus/ResolveExpression.h index 95538ceba6..52bbd6eb99 100644 --- a/src/libs/cplusplus/ResolveExpression.h +++ b/src/libs/cplusplus/ResolveExpression.h @@ -47,14 +47,18 @@ public: QList<LookupItem> operator()(ExpressionAST *ast, Scope *scope); QList<LookupItem> resolve(ExpressionAST *ast, Scope *scope); - QList<LookupItem> resolveMemberExpression(const QList<LookupItem> &baseResults, - unsigned accessOp, - const Name *memberName, - bool *replacedDotOperator = 0) const; - - QList<LookupItem> resolveBaseExpression(const QList<LookupItem> &baseResults, - int accessOp, - bool *replacedDotOperator = 0) const; + ClassOrNamespace *baseExpression(const QList<LookupItem> &baseResults, + int accessOp, + bool *replacedDotOperator = 0) const; + + Q_DECL_DEPRECATED QList<LookupItem> resolveMemberExpression(const QList<LookupItem> &baseResults, + unsigned accessOp, + const Name *memberName, + bool *replacedDotOperator = 0) const; + + Q_DECL_DEPRECATED QList<LookupItem> resolveBaseExpression(const QList<LookupItem> &baseResults, + int accessOp, + bool *replacedDotOperator = 0) const; protected: QList<LookupItem> resolve(ExpressionAST *ast); |