C++: fix replacing dot(.) with arrow(->)

Fix replacing operator dot(.) with operator arrow(->)
for typedef pointer.

Task-number: QTCREATORBUG-8488
Change-Id: Ic4462bc437a4aa37adfed4fa50b32d9bc20fe194
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Przemyslaw Gorszkowski
2013-01-30 12:27:28 +01:00
parent e9f219c335
commit 21500d54b7
3 changed files with 74 additions and 3 deletions

View File

@@ -978,10 +978,23 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
}
} else if (accessOp == T_DOT) {
if (replacedDotOperator) {
if (PointerType *ptrTy = ty->asPointerType()) {
// replace . with ->
*replacedDotOperator = originalType->isPointerType() || ty->isPointerType();
// replace . with ->
if (PointerType *ptrTy = originalType->asPointerType()) {
// case when original type is a pointer and
// typedef is for type
// e.g.:
// typedef S SType;
// SType *p;
ty = ptrTy->elementType();
}
else if (PointerType *ptrTy = ty->asPointerType()) {
// case when original type is a type and
// typedef is for pointer of type
// e.g.:
// typedef S* SPTR;
// SPTR p;
ty = ptrTy->elementType();
*replacedDotOperator = true;
}
}