summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus/ResolveExpression.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2015-04-24 09:55:20 +0300
committerOrgad Shaneh <orgads@gmail.com>2015-05-15 14:21:45 +0000
commit9b30795c02ac659606304f1a101279cd66af5c07 (patch)
tree67a9d988af34cb2f3701302d89a330a07350e12c /src/libs/cplusplus/ResolveExpression.cpp
parentee37f60bffb14fc20abe63b812dc3b8f20974fe1 (diff)
downloadqt-creator-9b30795c02ac659606304f1a101279cd66af5c07.tar.gz
C++: Fix lookup for instantiation by class object
Task-number: QTCREATORBUG-14352 Change-Id: I2ce4bc1d0dba2414afe050e80607b581686081a9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/libs/cplusplus/ResolveExpression.cpp')
-rw-r--r--src/libs/cplusplus/ResolveExpression.cpp96
1 files changed, 29 insertions, 67 deletions
diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp
index 5b5190aba0..c32dacbb1c 100644
--- a/src/libs/cplusplus/ResolveExpression.cpp
+++ b/src/libs/cplusplus/ResolveExpression.cpp
@@ -915,61 +915,47 @@ LookupScope *ResolveExpression::baseExpression(const QList<LookupItem> &baseResu
if (accessOp == T_ARROW) {
if (PointerType *ptrTy = ty->asPointerType()) {
FullySpecifiedType type = ptrTy->elementType();
- if (LookupScope *binding
- = findClassForTemplateParameterInExpressionScope(r.binding(),
- type)) {
- return binding;
- }
if (LookupScope *binding = findClass(type, scope))
return binding;
- } else {
- LookupScope *binding
- = findClassForTemplateParameterInExpressionScope(r.binding(),
- ty);
+ } else if (LookupScope *binding = findClass(ty, scope, r.binding())) {
+ // lookup for overloads of operator->
- if (! binding)
- binding = findClass(ty, scope, r.binding());
-
- if (binding){
- // lookup for overloads of operator->
+ const OperatorNameId *arrowOp
+ = control()->operatorNameId(OperatorNameId::ArrowOp);
+ foreach (const LookupItem &r, binding->find(arrowOp)) {
+ Symbol *overload = r.declaration();
+ if (! overload)
+ continue;
+ Scope *functionScope = overload->enclosingScope();
- const OperatorNameId *arrowOp
- = control()->operatorNameId(OperatorNameId::ArrowOp);
- foreach (const LookupItem &r, binding->find(arrowOp)) {
- Symbol *overload = r.declaration();
- if (! overload)
- continue;
- Scope *functionScope = overload->enclosingScope();
+ if (Function *funTy = overload->type()->asFunctionType()) {
+ FullySpecifiedType retTy = funTy->returnType().simplified();
- if (Function *funTy = overload->type()->asFunctionType()) {
- FullySpecifiedType retTy = funTy->returnType().simplified();
+ typeResolver.resolve(&retTy, &functionScope, r.binding());
- typeResolver.resolve(&retTy, &functionScope, r.binding());
+ if (! retTy->isPointerType() && ! retTy->isNamedType())
+ continue;
- if (! retTy->isPointerType() && ! retTy->isNamedType())
- continue;
+ if (PointerType *ptrTy = retTy->asPointerType())
+ retTy = ptrTy->elementType();
- if (PointerType *ptrTy = retTy->asPointerType())
- retTy = ptrTy->elementType();
+ if (LookupScope *retBinding = findClass(retTy, functionScope))
+ return retBinding;
- if (LookupScope *retBinding = findClass(retTy, functionScope))
+ if (scope != functionScope) {
+ if (LookupScope *retBinding = findClass(retTy, scope))
return retBinding;
+ }
- if (scope != functionScope) {
- if (LookupScope *retBinding = findClass(retTy, scope))
- return retBinding;
- }
-
- if (LookupScope *origin = binding->instantiationOrigin()) {
- foreach (Symbol *originSymbol, origin->symbols()) {
- Scope *originScope = originSymbol->asScope();
- if (originScope && originScope != scope
- && originScope != functionScope) {
- if (LookupScope *retBinding
- = findClass(retTy, originScope))
- return retBinding;
- }
+ if (LookupScope *origin = binding->instantiationOrigin()) {
+ foreach (Symbol *originSymbol, origin->symbols()) {
+ Scope *originScope = originSymbol->asScope();
+ if (originScope && originScope != scope
+ && originScope != functionScope) {
+ if (LookupScope *retBinding
+ = findClass(retTy, originScope))
+ return retBinding;
}
}
}
@@ -983,12 +969,6 @@ LookupScope *ResolveExpression::baseExpression(const QList<LookupItem> &baseResu
ty = ptrTy->elementType();
}
- if (LookupScope *binding
- = findClassForTemplateParameterInExpressionScope(r.binding(),
- ty)) {
- return binding;
- }
-
LookupScope *enclosingBinding = 0;
if (LookupScope *binding = r.binding()) {
if (binding->instantiationOrigin())
@@ -1003,24 +983,6 @@ LookupScope *ResolveExpression::baseExpression(const QList<LookupItem> &baseResu
return 0;
}
-LookupScope *ResolveExpression::findClassForTemplateParameterInExpressionScope(
- LookupScope *resultBinding,
- const FullySpecifiedType &ty) const
-{
- if (resultBinding) {
- if (LookupScope *origin = resultBinding->instantiationOrigin()) {
- foreach (Symbol *originSymbol, origin->symbols()) {
- if (Scope *originScope = originSymbol->asScope()) {
- if (LookupScope *retBinding = findClass(ty, originScope))
- return retBinding;
- }
- }
- }
- }
-
- return 0;
-}
-
bool ResolveExpression::visit(PostIncrDecrAST *ast)
{
const QList<LookupItem> baseResults = resolve(ast->base_expression, _scope);