mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 16:55:38 +02:00
Reworked pointer-to-member types, bug 264479.
This commit is contained in:
parent
fb9e22e7e4
commit
93867fa16e
26 changed files with 466 additions and 326 deletions
|
@ -6759,4 +6759,61 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
|
|
||||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// class X {
|
||||||
|
// public:
|
||||||
|
// int f;
|
||||||
|
// void m(int) {};
|
||||||
|
// void cm(int) const {};
|
||||||
|
// static int sf;
|
||||||
|
// static void sm(int) {};
|
||||||
|
// };
|
||||||
|
// int X::sf;
|
||||||
|
//
|
||||||
|
// void mpr(int X::* p){}
|
||||||
|
// void mpr(void (X::* q)(int)){}
|
||||||
|
// void mprc(void (X::* q)(int) const){}
|
||||||
|
// void mprcp(void (X::** q)(int) const){}
|
||||||
|
// void pr(int * p){}
|
||||||
|
// void pr(void (*q)(int)){}
|
||||||
|
//
|
||||||
|
// void testxxx() {
|
||||||
|
// void (X::* ptr)(int) const= &X::cm;
|
||||||
|
// mpr(&X::f);
|
||||||
|
// mpr(&X::m);
|
||||||
|
// mprc(&X::cm);
|
||||||
|
// mprcp(&ptr);
|
||||||
|
// pr(&X::sf);
|
||||||
|
// pr(&(X::sf));
|
||||||
|
// pr(&X::sm);
|
||||||
|
// pr(&(X::sm));
|
||||||
|
//
|
||||||
|
// // invalid constructs:
|
||||||
|
// mpr(&(X::f)); // cannot use parenthesis
|
||||||
|
// mpr(&(X::m)); // cannot use parenthesis
|
||||||
|
// mpr(&X::sf); // sf is static
|
||||||
|
// mpr(&X::sm); // sm is static
|
||||||
|
// mpr(&X::cm); // cm is const
|
||||||
|
// mprc(&X::m); // m is not const
|
||||||
|
// }
|
||||||
|
public void testMemberPtrs_264479() throws Exception {
|
||||||
|
final String code = getAboveComment();
|
||||||
|
BindingAssertionHelper ba= new BindingAssertionHelper(code, true);
|
||||||
|
ba.assertNonProblem("mpr(&X::f)", 3);
|
||||||
|
ba.assertNonProblem("mpr(&X::m)", 3);
|
||||||
|
ba.assertNonProblem("mprc(&X::cm)", 4);
|
||||||
|
ba.assertNonProblem("mprcp(&ptr)", 5);
|
||||||
|
ba.assertNonProblem("pr(&X::sf)", 2);
|
||||||
|
ba.assertNonProblem("pr(&(X::sf))", 2);
|
||||||
|
ba.assertNonProblem("pr(&X::sm)", 2);
|
||||||
|
ba.assertNonProblem("pr(&(X::sm))", 2);
|
||||||
|
|
||||||
|
ba.assertProblem("mpr(&(X::f))", 3);
|
||||||
|
ba.assertProblem("mpr(&(X::m))", 3);
|
||||||
|
ba.assertProblem("mpr(&X::sf)", 3);
|
||||||
|
ba.assertProblem("mpr(&X::sm)", 3);
|
||||||
|
ba.assertProblem("mpr(&X::cm)", 3);
|
||||||
|
ba.assertProblem("mprc(&X::m)", 4);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2009 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.index.IndexFilter;
|
import org.eclipse.cdt.core.index.IndexFilter;
|
||||||
|
@ -94,7 +95,7 @@ public class PDOMCBugsTest extends BaseTestCase {
|
||||||
IFunctionType ft= (IFunctionType) type;
|
IFunctionType ft= (IFunctionType) type;
|
||||||
assertEquals("int (int)", ASTTypeUtil.getType(ft));
|
assertEquals("int (int)", ASTTypeUtil.getType(ft));
|
||||||
} else {
|
} else {
|
||||||
assertTrue("expected ITypedef, got "+type, type == null || type instanceof ITypedef);
|
assertTrue("expected ITypedef, got "+type, type == null || type instanceof ITypedef || type instanceof IPointerType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
|
import org.eclipse.cdt.core.dom.ast.c.ICArrayType;
|
||||||
|
@ -20,7 +22,9 @@ import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
|
@ -89,7 +93,7 @@ public class ASTTypeUtil {
|
||||||
if (parameters.length == 0) {
|
if (parameters.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
} else if (parameters.length == 1) {
|
} else if (parameters.length == 1) {
|
||||||
IType ultimateType = SemanticUtil.getUltimateTypeViaTypedefs(parameters[0].getType());
|
IType ultimateType = SemanticUtil.getNestedType(parameters[0].getType(), TDEF);
|
||||||
|
|
||||||
if (ultimateType instanceof IBasicType) {
|
if (ultimateType instanceof IBasicType) {
|
||||||
if (((IBasicType) ultimateType).getType() == IBasicType.t_void) {
|
if (((IBasicType) ultimateType).getType() == IBasicType.t_void) {
|
||||||
|
@ -387,9 +391,17 @@ public class ASTTypeUtil {
|
||||||
if (temp != null && !temp.equals(EMPTY_STRING)) {
|
if (temp != null && !temp.equals(EMPTY_STRING)) {
|
||||||
result.append(temp); needSpace = false;
|
result.append(temp); needSpace = false;
|
||||||
}
|
}
|
||||||
|
if (type instanceof ICPPFunctionType) {
|
||||||
|
ICPPFunctionType ft= (ICPPFunctionType) type;
|
||||||
|
needSpace= appendCVQ(result, needSpace, ft.isConst(), ft.isVolatile());
|
||||||
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
}
|
}
|
||||||
} else if (type instanceof IPointerType) {
|
} else if (type instanceof IPointerType) {
|
||||||
|
if (type instanceof ICPPPointerToMemberType) {
|
||||||
|
result.append(getTypeString(((ICPPPointerToMemberType) type).getMemberOfClass(), normalize));
|
||||||
|
result.append(Keywords.cpCOLONCOLON);
|
||||||
|
}
|
||||||
result.append(Keywords.cpSTAR); needSpace = true;
|
result.append(Keywords.cpSTAR); needSpace = true;
|
||||||
|
|
||||||
if (type instanceof IGPPPointerType) {
|
if (type instanceof IGPPPointerType) {
|
||||||
|
@ -408,18 +420,8 @@ public class ASTTypeUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((IPointerType) type).isConst()) {
|
IPointerType pt= (IPointerType) type;
|
||||||
if (needSpace) {
|
needSpace= appendCVQ(result, needSpace, pt.isConst(), pt.isVolatile());
|
||||||
result.append(SPACE); needSpace = false;
|
|
||||||
}
|
|
||||||
result.append(Keywords.CONST); needSpace = true;
|
|
||||||
}
|
|
||||||
if (((IPointerType) type).isVolatile()) {
|
|
||||||
if (needSpace) {
|
|
||||||
result.append(SPACE); needSpace = false;
|
|
||||||
}
|
|
||||||
result.append(Keywords.VOLATILE); needSpace = true;
|
|
||||||
}
|
|
||||||
} else if (type instanceof IQualifierType) {
|
} else if (type instanceof IQualifierType) {
|
||||||
if (type instanceof ICQualifierType) {
|
if (type instanceof ICQualifierType) {
|
||||||
if (((ICQualifierType) type).isRestrict()) {
|
if (((ICQualifierType) type).isRestrict()) {
|
||||||
|
@ -431,18 +433,8 @@ public class ASTTypeUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((IQualifierType) type).isConst()) {
|
IQualifierType qt= (IQualifierType) type;
|
||||||
if (needSpace) {
|
needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile());
|
||||||
result.append(SPACE); needSpace = false;
|
|
||||||
}
|
|
||||||
result.append(Keywords.CONST); needSpace = true;
|
|
||||||
}
|
|
||||||
if (((IQualifierType) type).isVolatile()) {
|
|
||||||
if (needSpace) {
|
|
||||||
result.append(SPACE); needSpace = false;
|
|
||||||
}
|
|
||||||
result.append(Keywords.VOLATILE); needSpace = true;
|
|
||||||
}
|
|
||||||
} else if (type instanceof ITypedef) {
|
} else if (type instanceof ITypedef) {
|
||||||
result.append(((ITypedef) type).getNameCharArray());
|
result.append(((ITypedef) type).getNameCharArray());
|
||||||
}
|
}
|
||||||
|
@ -450,6 +442,23 @@ public class ASTTypeUtil {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean appendCVQ(StringBuilder target, boolean needSpace, final boolean isConst,
|
||||||
|
final boolean isVolatile) {
|
||||||
|
if (isConst) {
|
||||||
|
if (needSpace) {
|
||||||
|
target.append(SPACE); needSpace = false;
|
||||||
|
}
|
||||||
|
target.append(Keywords.CONST); needSpace = true;
|
||||||
|
}
|
||||||
|
if (isVolatile) {
|
||||||
|
if (needSpace) {
|
||||||
|
target.append(SPACE); needSpace = false;
|
||||||
|
}
|
||||||
|
target.append(Keywords.VOLATILE); needSpace = true;
|
||||||
|
}
|
||||||
|
return needSpace;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the normalized string representation of the type.
|
* Returns the normalized string representation of the type.
|
||||||
* @see #getType(IType, boolean)
|
* @see #getType(IType, boolean)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Niefer (IBM) - Initial API and implementation
|
* Andrew Niefer (IBM) - Initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -23,7 +24,10 @@ public interface ICPPFunctionType extends IFunctionType {
|
||||||
/**
|
/**
|
||||||
* Returns type of implicit <code>this</code>. parameter, or null, if the function
|
* Returns type of implicit <code>this</code>. parameter, or null, if the function
|
||||||
* is not a class method or a static method.
|
* is not a class method or a static method.
|
||||||
|
* @deprecated function types don't relate to this pointers at all.
|
||||||
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public IPointerType getThisType();
|
public IPointerType getThisType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,10 +7,12 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a member of a class. Adds in the visibility attribute.
|
* Represents a member of a class. Adds in the visibility attribute.
|
||||||
|
@ -20,16 +22,30 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
*/
|
*/
|
||||||
public interface ICPPMember extends ICPPBinding {
|
public interface ICPPMember extends ICPPBinding {
|
||||||
|
|
||||||
|
public static final int v_private = ICPPASTVisibilityLabel.v_private;
|
||||||
|
public static final int v_protected = ICPPASTVisibilityLabel.v_protected;
|
||||||
|
public static final int v_public = ICPPASTVisibilityLabel.v_public;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The visibility.
|
* Returns the accessibility of the member.
|
||||||
*/
|
*/
|
||||||
public int getVisibility() throws DOMException;
|
public int getVisibility() throws DOMException;
|
||||||
|
|
||||||
public static final int v_private = ICPPASTVisibilityLabel.v_private;
|
|
||||||
|
|
||||||
public static final int v_protected = ICPPASTVisibilityLabel.v_protected;
|
|
||||||
|
|
||||||
public static final int v_public = ICPPASTVisibilityLabel.v_public;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as {@link #getOwner()}.
|
||||||
|
*/
|
||||||
public ICPPClassType getClassOwner() throws DOMException;
|
public ICPPClassType getClassOwner() throws DOMException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this is a static member or not.
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public boolean isStatic() throws DOMException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of the member (function type or type of field)
|
||||||
|
* @since 5.1
|
||||||
|
*/
|
||||||
|
public IType getType() throws DOMException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,37 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVQ;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.REF;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
@ -33,7 +41,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Unary expression in c++
|
||||||
*/
|
*/
|
||||||
public class CPPASTUnaryExpression extends ASTNode implements
|
public class CPPASTUnaryExpression extends ASTNode implements
|
||||||
ICPPASTUnaryExpression, IASTAmbiguityParent {
|
ICPPASTUnaryExpression, IASTAmbiguityParent {
|
||||||
|
@ -118,15 +126,14 @@ public class CPPASTUnaryExpression extends ASTNode implements
|
||||||
return CPPVisitor.get_type_info(this);
|
return CPPVisitor.get_type_info(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
IType type= getOperand().getExpressionType();
|
final IASTExpression operand = getOperand();
|
||||||
type = SemanticUtil.getUltimateTypeViaTypedefs(type);
|
|
||||||
|
|
||||||
if (op == IASTUnaryExpression.op_star) {
|
if (op == IASTUnaryExpression.op_star) {
|
||||||
|
IType type= operand.getExpressionType();
|
||||||
|
type = SemanticUtil.getNestedType(type, TDEF | REF | CVQ);
|
||||||
|
if (type instanceof IProblemBinding) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
type = SemanticUtil.getUltimateTypeUptoPointers(type);
|
|
||||||
if (type instanceof IProblemBinding) {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
if (type instanceof ICPPClassType) {
|
if (type instanceof ICPPClassType) {
|
||||||
ICPPFunction operator= CPPSemantics.findOperator(this, (ICPPClassType) type);
|
ICPPFunction operator= CPPSemantics.findOperator(this, (ICPPClassType) type);
|
||||||
if (operator != null) {
|
if (operator != null) {
|
||||||
|
@ -137,37 +144,47 @@ public class CPPASTUnaryExpression extends ASTNode implements
|
||||||
} else if (type instanceof ICPPUnknownType) {
|
} else if (type instanceof ICPPUnknownType) {
|
||||||
return CPPUnknownClass.createUnnamedInstance();
|
return CPPUnknownClass.createUnnamedInstance();
|
||||||
}
|
}
|
||||||
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE,
|
|
||||||
this.getRawSignature().toCharArray());
|
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
} else if (op == IASTUnaryExpression.op_amper) {
|
return new ProblemBinding(this, IProblemBinding.SEMANTIC_INVALID_TYPE, this.getRawSignature().toCharArray());
|
||||||
if (type instanceof ICPPReferenceType) {
|
}
|
||||||
try {
|
if (op == IASTUnaryExpression.op_amper) {
|
||||||
type = ((ICPPReferenceType) type).getType();
|
IASTNode child= operand;
|
||||||
} catch (DOMException e) {
|
boolean inParenthesis= false;
|
||||||
}
|
while (child instanceof IASTUnaryExpression && ((IASTUnaryExpression) child).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
|
||||||
|
child= ((IASTUnaryExpression) child).getOperand();
|
||||||
|
inParenthesis= true;
|
||||||
}
|
}
|
||||||
if (type instanceof ICPPFunctionType) {
|
if (child instanceof IASTIdExpression) {
|
||||||
ICPPFunctionType functionType = (ICPPFunctionType) type;
|
IASTName name= ((IASTIdExpression) child).getName();
|
||||||
IPointerType thisType = functionType.getThisType();
|
IBinding b= name.resolveBinding();
|
||||||
if (thisType != null) {
|
if (b instanceof ICPPMember) {
|
||||||
IType nestedType;
|
ICPPMember member= (ICPPMember) b;
|
||||||
try {
|
try {
|
||||||
nestedType = thisType.getType();
|
if (name instanceof ICPPASTQualifiedName) {
|
||||||
while (nestedType instanceof ITypeContainer) {
|
if (!member.isStatic()) {
|
||||||
nestedType = ((ITypeContainer) nestedType).getType();
|
if (!inParenthesis) {
|
||||||
|
return new CPPPointerToMemberType(member.getType(), member.getClassOwner(), false, false);
|
||||||
|
} else if (member instanceof IFunction) {
|
||||||
|
return new ProblemBinding(operand, IProblemBinding.SEMANTIC_INVALID_TYPE, operand.getRawSignature().toCharArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
return new CPPPointerToMemberType(type, nestedType, thisType.isConst(), thisType
|
|
||||||
.isVolatile());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IType type= operand.getExpressionType();
|
||||||
|
type = SemanticUtil.getNestedType(type, TDEF | REF);
|
||||||
return new CPPPointerType(type);
|
return new CPPPointerType(type);
|
||||||
} else if (type instanceof CPPBasicType) {
|
}
|
||||||
|
|
||||||
|
IType type= operand.getExpressionType();
|
||||||
|
type = SemanticUtil.getNestedType(type, TDEF | REF);
|
||||||
|
if (type instanceof CPPBasicType) {
|
||||||
((CPPBasicType) type).setFromExpression(this);
|
((CPPBasicType) type).setFromExpression(this);
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
|
|
|
@ -33,7 +33,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -126,8 +125,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
if (!ia.hasUserDeclaredCopyAssignmentOperator()) {
|
if (!ia.hasUserDeclaredCopyAssignmentOperator()) {
|
||||||
//copy assignment operator: A& operator = (const A &)
|
//copy assignment operator: A& operator = (const A &)
|
||||||
IType refType = new CPPReferenceType(clsType);
|
IType refType = new CPPReferenceType(clsType);
|
||||||
IPointerType thisType= new CPPPointerType(clsType);
|
ICPPFunctionType ft= CPPVisitor.createImplicitFunctionType(refType, ps, false, false);
|
||||||
ICPPFunctionType ft= CPPVisitor.createImplicitFunctionType(refType, ps, thisType);
|
|
||||||
ICPPMethod m = new CPPImplicitMethod(this, OverloadableOperator.ASSIGN.toCharArray(), ft, ps);
|
ICPPMethod m = new CPPImplicitMethod(this, OverloadableOperator.ASSIGN.toCharArray(), ft, ps);
|
||||||
implicits[i++] = m;
|
implicits[i++] = m;
|
||||||
addBinding(m);
|
addBinding(m);
|
||||||
|
@ -136,8 +134,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
||||||
if (!ia.hasUserDeclaredDestructor()) {
|
if (!ia.hasUserDeclaredDestructor()) {
|
||||||
//destructor: ~A()
|
//destructor: ~A()
|
||||||
// a destructor can be called for const and volatile objects
|
// a destructor can be called for const and volatile objects
|
||||||
IPointerType thisType= new CPPPointerType(new CPPQualifierType(clsType, true, true));
|
ICPPFunctionType ft= CPPVisitor.createImplicitFunctionType(new CPPBasicType(IBasicType.t_unspecified, 0), voidPs, true, true);
|
||||||
ICPPFunctionType ft= CPPVisitor.createImplicitFunctionType(new CPPBasicType(IBasicType.t_unspecified, 0), voidPs, thisType);
|
|
||||||
char[] dtorName = CharArrayUtils.concat("~".toCharArray(), className); //$NON-NLS-1$
|
char[] dtorName = CharArrayUtils.concat("~".toCharArray(), className); //$NON-NLS-1$
|
||||||
ICPPMethod m = new CPPImplicitMethod(this, dtorName, ft, voidPs);
|
ICPPMethod m = new CPPImplicitMethod(this, dtorName, ft, voidPs);
|
||||||
implicits[i++] = m;
|
implicits[i++] = m;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -26,7 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
public class CPPFunctionType implements ICPPFunctionType {
|
public class CPPFunctionType implements ICPPFunctionType {
|
||||||
private IType[] parameters;
|
private IType[] parameters;
|
||||||
private IType returnType;
|
private IType returnType;
|
||||||
private IPointerType thisType;
|
private boolean isConst;
|
||||||
|
private boolean isVolatile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param returnType
|
* @param returnType
|
||||||
|
@ -37,10 +38,11 @@ public class CPPFunctionType implements ICPPFunctionType {
|
||||||
this.parameters = types;
|
this.parameters = types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPFunctionType(IType returnType, IType[] types, IPointerType thisType) {
|
public CPPFunctionType(IType returnType, IType[] types, boolean isConst, boolean isVolatile) {
|
||||||
this.returnType = returnType;
|
this.returnType = returnType;
|
||||||
this.parameters = types;
|
this.parameters = types;
|
||||||
this.thisType = thisType;
|
this.isConst = isConst;
|
||||||
|
this.isVolatile= isVolatile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSameType(IType o) {
|
public boolean isSameType(IType o) {
|
||||||
|
@ -66,11 +68,11 @@ public class CPPFunctionType implements ICPPFunctionType {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (parameters.length == 1 && fps.length == 0) {
|
if (parameters.length == 1 && fps.length == 0) {
|
||||||
IType p0= SemanticUtil.getUltimateTypeViaTypedefs(parameters[0]);
|
IType p0= SemanticUtil.getNestedType(parameters[0], SemanticUtil.TDEF);
|
||||||
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
||||||
return false;
|
return false;
|
||||||
} else if (fps.length == 1 && parameters.length == 0) {
|
} else if (fps.length == 1 && parameters.length == 0) {
|
||||||
IType p0= SemanticUtil.getUltimateTypeViaTypedefs(fps[0]);
|
IType p0= SemanticUtil.getNestedType(fps[0], SemanticUtil.TDEF);
|
||||||
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
||||||
return false;
|
return false;
|
||||||
} else if (parameters.length != fps.length) {
|
} else if (parameters.length != fps.length) {
|
||||||
|
@ -119,19 +121,17 @@ public class CPPFunctionType implements ICPPFunctionType {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
@Deprecated
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ICPPFunctionType#getThisType()
|
|
||||||
*/
|
|
||||||
public IPointerType getThisType() {
|
public IPointerType getThisType() {
|
||||||
return thisType;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isConst() {
|
public final boolean isConst() {
|
||||||
return thisType != null && thisType.isConst();
|
return isConst;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isVolatile() {
|
public final boolean isVolatile() {
|
||||||
return thisType != null && thisType.isVolatile();
|
return isVolatile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -30,7 +30,7 @@ public class CPPImplicitConstructor extends CPPImplicitMethod implements ICPPCon
|
||||||
|
|
||||||
private static ICPPFunctionType createFunctionType(ICPPClassScope scope, IParameter[] params) {
|
private static ICPPFunctionType createFunctionType(ICPPClassScope scope, IParameter[] params) {
|
||||||
IType returnType= new CPPBasicType(IBasicType.t_unspecified, 0);
|
IType returnType= new CPPBasicType(IBasicType.t_unspecified, 0);
|
||||||
return CPPVisitor.createImplicitFunctionType(returnType, params, null);
|
return CPPVisitor.createImplicitFunctionType(returnType, params, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExplicit() {
|
public boolean isExplicit() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -19,9 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models pointer to members.
|
* Models pointer to members.
|
||||||
|
@ -48,16 +46,16 @@ public class CPPPointerToMemberType extends CPPPointerType implements ICPPPointe
|
||||||
public boolean isSameType(IType o) {
|
public boolean isSameType(IType o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (o instanceof ITypedef || o instanceof IIndexType)
|
if (o instanceof ITypedef)
|
||||||
return o.isSameType(this);
|
return o.isSameType(this);
|
||||||
|
|
||||||
|
if (!(o instanceof ICPPPointerToMemberType))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!super.isSameType(o))
|
if (!super.isSameType(o))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(o instanceof CPPPointerToMemberType))
|
ICPPPointerToMemberType pt = (ICPPPointerToMemberType) o;
|
||||||
return false;
|
|
||||||
|
|
||||||
CPPPointerToMemberType pt = (CPPPointerToMemberType) o;
|
|
||||||
IType cls = pt.getMemberOfClass();
|
IType cls = pt.getMemberOfClass();
|
||||||
if (cls != null)
|
if (cls != null)
|
||||||
return cls.isSameType(getMemberOfClass());
|
return cls.isSameType(getMemberOfClass());
|
||||||
|
@ -88,14 +86,4 @@ public class CPPPointerToMemberType extends CPPPointerType implements ICPPPointe
|
||||||
}
|
}
|
||||||
return classType;
|
return classType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isConst() {
|
|
||||||
return super.isConst() || (getType() instanceof ICPPFunctionType && ((ICPPFunctionType) getType()).isConst());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVolatile() {
|
|
||||||
return super.isVolatile() || (getType() instanceof ICPPFunctionType && ((ICPPFunctionType) getType()).isVolatile());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,27 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* Andrew Niefer (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Dec 10, 2004
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
import org.eclipse.cdt.core.dom.ast.IASTPointer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* Pointers in c++
|
||||||
*/
|
*/
|
||||||
public class CPPPointerType implements IPointerType, ITypeContainer {
|
public class CPPPointerType implements IPointerType, ITypeContainer {
|
||||||
protected IType type = null;
|
protected IType type = null;
|
||||||
|
@ -59,18 +57,25 @@ public class CPPPointerType implements IPointerType, ITypeContainer {
|
||||||
public boolean isSameType(IType o) {
|
public boolean isSameType(IType o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (o instanceof ITypedef || o instanceof IIndexType)
|
if (o instanceof ITypedef)
|
||||||
return o.isSameType(this);
|
return o.isSameType(this);
|
||||||
|
|
||||||
if (!(o instanceof CPPPointerType))
|
if (!(o instanceof IPointerType))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (this instanceof ICPPPointerToMemberType != o instanceof ICPPPointerToMemberType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CPPPointerType pt = (CPPPointerType) o;
|
IPointerType pt = (IPointerType) o;
|
||||||
if (isConst == pt.isConst && isVolatile == pt.isVolatile)
|
if (isConst == pt.isConst() && isVolatile == pt.isVolatile()) {
|
||||||
return type.isSameType(pt.getType());
|
try {
|
||||||
|
return type.isSameType(pt.getType());
|
||||||
|
} catch (DOMException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
|
||||||
|
|
||||||
|
@ -442,8 +444,13 @@ public class CPPSemantics {
|
||||||
if (parent instanceof ICPPASTFunctionDeclarator) {
|
if (parent instanceof ICPPASTFunctionDeclarator) {
|
||||||
data.functionParameters = ((ICPPASTFunctionDeclarator)parent).getParameters();
|
data.functionParameters = ((ICPPASTFunctionDeclarator)parent).getParameters();
|
||||||
} else if (parent instanceof IASTIdExpression) {
|
} else if (parent instanceof IASTIdExpression) {
|
||||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
IASTNode grand= parent.getParent();
|
||||||
if (prop == IASTFunctionCallExpression.FUNCTION_NAME) {
|
while (grand instanceof IASTUnaryExpression
|
||||||
|
&& ((IASTUnaryExpression) grand).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
|
||||||
|
parent= grand;
|
||||||
|
grand = grand.getParent();
|
||||||
|
}
|
||||||
|
if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
|
||||||
parent = parent.getParent();
|
parent = parent.getParent();
|
||||||
IASTExpression exp = ((IASTFunctionCallExpression)parent).getParameterExpression();
|
IASTExpression exp = ((IASTFunctionCallExpression)parent).getParameterExpression();
|
||||||
if (exp instanceof IASTExpressionList)
|
if (exp instanceof IASTExpressionList)
|
||||||
|
@ -453,14 +460,22 @@ public class CPPSemantics {
|
||||||
else
|
else
|
||||||
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
}
|
}
|
||||||
} else if (parent instanceof ICPPASTFieldReference && parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
|
} else if (parent instanceof ICPPASTFieldReference) {
|
||||||
IASTExpression exp = ((IASTFunctionCallExpression)parent.getParent()).getParameterExpression();
|
IASTNode grand= parent.getParent();
|
||||||
if (exp instanceof IASTExpressionList)
|
while (grand instanceof IASTUnaryExpression
|
||||||
data.functionParameters = ((IASTExpressionList) exp).getExpressions();
|
&& ((IASTUnaryExpression) grand).getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
|
||||||
else if (exp != null)
|
parent= grand;
|
||||||
data.functionParameters = new IASTExpression[] { exp };
|
grand = grand.getParent();
|
||||||
else
|
}
|
||||||
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
|
||||||
|
IASTExpression exp = ((IASTFunctionCallExpression)parent.getParent()).getParameterExpression();
|
||||||
|
if (exp instanceof IASTExpressionList)
|
||||||
|
data.functionParameters = ((IASTExpressionList) exp).getExpressions();
|
||||||
|
else if (exp != null)
|
||||||
|
data.functionParameters = new IASTExpression[] { exp };
|
||||||
|
else
|
||||||
|
data.functionParameters = IASTExpression.EMPTY_EXPRESSION_ARRAY;
|
||||||
|
}
|
||||||
} else if (parent instanceof ICPPASTNamedTypeSpecifier && parent.getParent() instanceof IASTTypeId) {
|
} else if (parent instanceof ICPPASTNamedTypeSpecifier && parent.getParent() instanceof IASTTypeId) {
|
||||||
IASTTypeId typeId = (IASTTypeId) parent.getParent();
|
IASTTypeId typeId = (IASTTypeId) parent.getParent();
|
||||||
if (typeId.getParent() instanceof ICPPASTNewExpression) {
|
if (typeId.getParent() instanceof ICPPASTNewExpression) {
|
||||||
|
@ -1833,7 +1848,7 @@ public class CPPSemantics {
|
||||||
// check for parameter of type void
|
// check for parameter of type void
|
||||||
IType[] argTypes= getSourceParameterTypes(funcArgs);
|
IType[] argTypes= getSourceParameterTypes(funcArgs);
|
||||||
if (argTypes.length == 1) {
|
if (argTypes.length == 1) {
|
||||||
IType t= SemanticUtil.getUltimateTypeViaTypedefs(argTypes[0]);
|
IType t= getNestedType(argTypes[0], TDEF);
|
||||||
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void) {
|
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void) {
|
||||||
numArgs= 0;
|
numArgs= 0;
|
||||||
}
|
}
|
||||||
|
@ -1862,7 +1877,7 @@ public class CPPSemantics {
|
||||||
int numPars = params.length;
|
int numPars = params.length;
|
||||||
if (numArgs < 2 && numPars == 1) {
|
if (numArgs < 2 && numPars == 1) {
|
||||||
// check for void
|
// check for void
|
||||||
IType t = SemanticUtil.getUltimateTypeViaTypedefs(params[0].getType());
|
IType t = getNestedType(params[0].getType(), TDEF);
|
||||||
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void)
|
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void)
|
||||||
numPars= 0;
|
numPars= 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -754,17 +754,18 @@ public class CPPTemplates {
|
||||||
if (tpMap == null)
|
if (tpMap == null)
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
if (type instanceof IFunctionType) {
|
if (type instanceof ICPPFunctionType) {
|
||||||
|
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||||
IType ret = null;
|
IType ret = null;
|
||||||
IType[] params = null;
|
IType[] params = null;
|
||||||
final IType r = ((IFunctionType) type).getReturnType();
|
final IType r = ft.getReturnType();
|
||||||
ret = instantiateType(r, tpMap, within);
|
ret = instantiateType(r, tpMap, within);
|
||||||
IType[] ps = ((IFunctionType) type).getParameterTypes();
|
IType[] ps = ft.getParameterTypes();
|
||||||
params = instantiateTypes(ps, tpMap, within);
|
params = instantiateTypes(ps, tpMap, within);
|
||||||
if (ret == r && params == ps) {
|
if (ret == r && params == ps) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
return new CPPFunctionType(ret, params, ((ICPPFunctionType) type).getThisType());
|
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type instanceof ICPPTemplateParameter) {
|
if (type instanceof ICPPTemplateParameter) {
|
||||||
|
@ -1800,7 +1801,7 @@ public class CPPTemplates {
|
||||||
@Override
|
@Override
|
||||||
public ICPPFunctionType getType() {
|
public ICPPFunctionType getType() {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = CPPVisitor.createImplicitFunctionType(new CPPBasicType(IBasicType.t_void, 0), functionParameters, null);
|
type = CPPVisitor.createImplicitFunctionType(new CPPBasicType(IBasicType.t_void, 0), functionParameters, false, false);
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,6 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
@ -118,7 +117,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
|
@ -1493,7 +1491,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
* Generate a function type for an implicit function.
|
* Generate a function type for an implicit function.
|
||||||
* NOTE: This does not correctly handle parameters with typedef types.
|
* NOTE: This does not correctly handle parameters with typedef types.
|
||||||
*/
|
*/
|
||||||
public static ICPPFunctionType createImplicitFunctionType(IType returnType, IParameter[] parameters, IPointerType thisType) {
|
public static ICPPFunctionType createImplicitFunctionType(IType returnType, IParameter[] parameters, boolean isConst, boolean isVolatile) {
|
||||||
IType[] pTypes = new IType[parameters.length];
|
IType[] pTypes = new IType[parameters.length];
|
||||||
IType pt = null;
|
IType pt = null;
|
||||||
|
|
||||||
|
@ -1518,7 +1516,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
pTypes[i] = pt;
|
pTypes[i] = pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CPPFunctionType(returnType, pTypes, thisType);
|
return new CPPFunctionType(returnType, pTypes, isConst, isVolatile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IType createType(IType returnType, ICPPASTFunctionDeclarator fnDtor) {
|
private static IType createType(IType returnType, ICPPASTFunctionDeclarator fnDtor) {
|
||||||
|
@ -1547,30 +1545,11 @@ public class CPPVisitor extends ASTQueries {
|
||||||
returnType = getPointerTypes(returnType, fnDtor);
|
returnType = getPointerTypes(returnType, fnDtor);
|
||||||
}
|
}
|
||||||
|
|
||||||
IScope scope = fnDtor.getFunctionScope();
|
// a destructor can be called for const and volatile objects
|
||||||
IType thisType= getThisType(scope);
|
final char[] lookupKey = name.getLookupKey();
|
||||||
IASTDeclarator nested = fnDtor.getNestedDeclarator();
|
final boolean isDestructor= lookupKey.length > 0 && lookupKey[0]=='~';
|
||||||
if (thisType == null && nested != null) {
|
IType type = new CPPFunctionType(returnType, pTypes, isDestructor || fnDtor.isConst(), isDestructor || fnDtor.isVolatile());
|
||||||
IType pts= getPointerTypes(new CPPBasicType(-1,-1), nested);
|
final IASTDeclarator nested = fnDtor.getNestedDeclarator();
|
||||||
if (pts instanceof ICPPPointerToMemberType) {
|
|
||||||
thisType= new CPPPointerType(((ICPPPointerToMemberType)pts).getMemberOfClass());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (thisType instanceof IPointerType) {
|
|
||||||
try {
|
|
||||||
IType classType = ((IPointerType) thisType).getType();
|
|
||||||
// a destructor can be called for const and volatile objects
|
|
||||||
final char[] lookupKey = name.getLookupKey();
|
|
||||||
final boolean isDestructor= lookupKey.length > 0 && lookupKey[0]=='~';
|
|
||||||
final boolean isConst = isDestructor || fnDtor.isConst();
|
|
||||||
final boolean isVolatile = isDestructor || fnDtor.isVolatile();
|
|
||||||
thisType = new CPPPointerType(classType, isConst, isVolatile);
|
|
||||||
} catch (DOMException e) {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
thisType = null;
|
|
||||||
}
|
|
||||||
IType type = new CPPFunctionType(returnType, pTypes, (IPointerType) thisType);
|
|
||||||
if (nested != null) {
|
if (nested != null) {
|
||||||
return createType(type, nested);
|
return createType(type, nested);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,18 +64,18 @@ public class Conversions {
|
||||||
public static Cost checkImplicitConversionSequence(IASTExpression sourceExp, IType source,
|
public static Cost checkImplicitConversionSequence(IASTExpression sourceExp, IType source,
|
||||||
IType target, boolean allowUDC, boolean isImpliedObject) throws DOMException {
|
IType target, boolean allowUDC, boolean isImpliedObject) throws DOMException {
|
||||||
allowUDC &= !isImpliedObject;
|
allowUDC &= !isImpliedObject;
|
||||||
target= getNestedType(target, TYPEDEFS);
|
target= getNestedType(target, TDEF);
|
||||||
source= getNestedType(source, TYPEDEFS);
|
source= getNestedType(source, TDEF);
|
||||||
|
|
||||||
if (target instanceof ICPPReferenceType) {
|
if (target instanceof ICPPReferenceType) {
|
||||||
// [8.5.3-5] initialization of a reference
|
// [8.5.3-5] initialization of a reference
|
||||||
IType cv1T1= getNestedType(target, TYPEDEFS | REFERENCES);
|
IType cv1T1= getNestedType(target, TDEF | REF);
|
||||||
|
|
||||||
boolean lvalue= sourceExp == null || !CPPVisitor.isRValue(sourceExp);
|
boolean lvalue= sourceExp == null || !CPPVisitor.isRValue(sourceExp);
|
||||||
if (source instanceof ICPPReferenceType)
|
if (source instanceof ICPPReferenceType)
|
||||||
source= getNestedType(source, TYPEDEFS | REFERENCES);
|
source= getNestedType(source, TDEF | REF);
|
||||||
|
|
||||||
IType T2= getNestedType(source, TYPEDEFS | REFERENCES | QUALIFIERS | PTR_QUALIFIERS);
|
IType T2= getNestedType(source, TDEF | REF | CVQ | PTR_CVQ);
|
||||||
|
|
||||||
// [8.5.3-5] Is an lvalue (but is not a bit-field), and "cv1 T1" is reference-compatible with "cv2 T2,"
|
// [8.5.3-5] Is an lvalue (but is not a bit-field), and "cv1 T1" is reference-compatible with "cv2 T2,"
|
||||||
if (lvalue) {
|
if (lvalue) {
|
||||||
|
@ -131,7 +131,7 @@ public class Conversions {
|
||||||
if (conv!= null && !ambiguousConversionOperator) {
|
if (conv!= null && !ambiguousConversionOperator) {
|
||||||
IType newSource= conv.getType().getReturnType();
|
IType newSource= conv.getType().getReturnType();
|
||||||
if (newSource instanceof ICPPReferenceType) { // require an lvalue
|
if (newSource instanceof ICPPReferenceType) { // require an lvalue
|
||||||
IType cvT2= getNestedType(newSource, TYPEDEFS | REFERENCES);
|
IType cvT2= getNestedType(newSource, TDEF | REF);
|
||||||
Cost cost= isReferenceCompatible(cv1T1, cvT2);
|
Cost cost= isReferenceCompatible(cv1T1, cvT2);
|
||||||
if (cost != null) {
|
if (cost != null) {
|
||||||
if (isImpliedObject) {
|
if (isImpliedObject) {
|
||||||
|
@ -161,7 +161,7 @@ public class Conversions {
|
||||||
|
|
||||||
// If T1 is reference-related to T2, cv1 must be the same cv-qualification as,
|
// If T1 is reference-related to T2, cv1 must be the same cv-qualification as,
|
||||||
// or greater cv-qualification than, cv2; otherwise, the program is ill-formed.
|
// or greater cv-qualification than, cv2; otherwise, the program is ill-formed.
|
||||||
IType T1= getNestedType(cv1T1, TYPEDEFS | REFERENCES | QUALIFIERS | PTR_QUALIFIERS);
|
IType T1= getNestedType(cv1T1, TDEF | REF | CVQ | PTR_CVQ);
|
||||||
boolean illformed= isReferenceRelated(T1, T2) >= 0 && compareQualifications(cv1T1, source) < 0;
|
boolean illformed= isReferenceRelated(T1, T2) >= 0 && compareQualifications(cv1T1, source) < 0;
|
||||||
|
|
||||||
// We must do a non-reference initialization
|
// We must do a non-reference initialization
|
||||||
|
@ -248,19 +248,19 @@ public class Conversions {
|
||||||
* @return inheritance distance, or -1, if <code>cv1t1</code> is not reference-related to <code>cv2t2</code>
|
* @return inheritance distance, or -1, if <code>cv1t1</code> is not reference-related to <code>cv2t2</code>
|
||||||
*/
|
*/
|
||||||
private static final int isReferenceRelated(IType cv1Target, IType cv2Source) throws DOMException {
|
private static final int isReferenceRelated(IType cv1Target, IType cv2Source) throws DOMException {
|
||||||
IType t= SemanticUtil.getNestedType(cv1Target, TYPEDEFS | REFERENCES);
|
IType t= SemanticUtil.getNestedType(cv1Target, TDEF | REF);
|
||||||
IType s= SemanticUtil.getNestedType(cv2Source, TYPEDEFS | REFERENCES);
|
IType s= SemanticUtil.getNestedType(cv2Source, TDEF | REF);
|
||||||
|
|
||||||
// The way cv-qualification is currently modeled means
|
// The way cv-qualification is currently modeled means
|
||||||
// we must cope with IPointerType objects separately.
|
// we must cope with IPointerType objects separately.
|
||||||
if (t instanceof IPointerType && s instanceof IPointerType) {
|
if (t instanceof IPointerType && s instanceof IPointerType) {
|
||||||
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TYPEDEFS | REFERENCES);
|
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF);
|
||||||
s= SemanticUtil.getNestedType(((IPointerType) s).getType(), TYPEDEFS | REFERENCES);
|
s= SemanticUtil.getNestedType(((IPointerType) s).getType(), TDEF | REF);
|
||||||
} else {
|
} else {
|
||||||
if (t instanceof IQualifierType)
|
if (t instanceof IQualifierType)
|
||||||
t= SemanticUtil.getNestedType(((IQualifierType) t).getType(), TYPEDEFS | REFERENCES);
|
t= SemanticUtil.getNestedType(((IQualifierType) t).getType(), TDEF | REF);
|
||||||
if (s instanceof IQualifierType)
|
if (s instanceof IQualifierType)
|
||||||
s= SemanticUtil.getNestedType(((IQualifierType) s).getType(), TYPEDEFS | REFERENCES);
|
s= SemanticUtil.getNestedType(((IQualifierType) s).getType(), TDEF | REF);
|
||||||
|
|
||||||
if (t instanceof ICPPClassType && s instanceof ICPPClassType) {
|
if (t instanceof ICPPClassType && s instanceof ICPPClassType) {
|
||||||
return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, s, t);
|
return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, s, t);
|
||||||
|
@ -441,7 +441,7 @@ public class Conversions {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbase= getNestedType(tbase, TYPEDEFS);
|
tbase= getNestedType(tbase, TDEF);
|
||||||
if (tbase instanceof ICPPClassType) {
|
if (tbase instanceof ICPPClassType) {
|
||||||
int n= calculateInheritanceDepth(maxdepth - 1, tbase, ancestorToFind);
|
int n= calculateInheritanceDepth(maxdepth - 1, tbase, ancestorToFind);
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
|
@ -464,17 +464,17 @@ public class Conversions {
|
||||||
private static final boolean lvalue_to_rvalue(final Cost cost) throws DOMException {
|
private static final boolean lvalue_to_rvalue(final Cost cost) throws DOMException {
|
||||||
// target should not be a reference here.
|
// target should not be a reference here.
|
||||||
boolean isConverted= false;
|
boolean isConverted= false;
|
||||||
IType target = getNestedType(cost.target, REFERENCES | TYPEDEFS);
|
IType target = getNestedType(cost.target, REF | TDEF);
|
||||||
IType source= getNestedType(cost.source, TYPEDEFS);
|
IType source= getNestedType(cost.source, TDEF);
|
||||||
|
|
||||||
|
|
||||||
// 4.1 lvalue to rvalue
|
// 4.1 lvalue to rvalue
|
||||||
IType srcRValue= getNestedType(source, REFERENCES | TYPEDEFS);
|
IType srcRValue= getNestedType(source, REF | TDEF);
|
||||||
if (source instanceof ICPPReferenceType) {
|
if (source instanceof ICPPReferenceType) {
|
||||||
// 4.1 lvalue of non-function and non-array
|
// 4.1 lvalue of non-function and non-array
|
||||||
if (!(srcRValue instanceof IFunctionType) && !(srcRValue instanceof IArrayType)) {
|
if (!(srcRValue instanceof IFunctionType) && !(srcRValue instanceof IArrayType)) {
|
||||||
// 4.1 if T is a non-class type, the type of the rvalue is the cv-unqualified version of T
|
// 4.1 if T is a non-class type, the type of the rvalue is the cv-unqualified version of T
|
||||||
IType unqualifiedSrcRValue= getNestedType(srcRValue, QUALIFIERS | PTR_QUALIFIERS | TYPEDEFS | REFERENCES);
|
IType unqualifiedSrcRValue= getNestedType(srcRValue, CVQ | PTR_CVQ | TDEF | REF);
|
||||||
if (unqualifiedSrcRValue instanceof ICPPClassType) {
|
if (unqualifiedSrcRValue instanceof ICPPClassType) {
|
||||||
if (isCompleteType(unqualifiedSrcRValue)) {
|
if (isCompleteType(unqualifiedSrcRValue)) {
|
||||||
source= srcRValue;
|
source= srcRValue;
|
||||||
|
@ -496,7 +496,7 @@ public class Conversions {
|
||||||
final IArrayType arrayType= (IArrayType) srcRValue;
|
final IArrayType arrayType= (IArrayType) srcRValue;
|
||||||
|
|
||||||
if (target instanceof IPointerType) {
|
if (target instanceof IPointerType) {
|
||||||
final IType targetPtrTgt= getNestedType(((IPointerType) target).getType(), TYPEDEFS);
|
final IType targetPtrTgt= getNestedType(((IPointerType) target).getType(), TDEF);
|
||||||
|
|
||||||
// 4.2-2 a string literal can be converted to pointer to char
|
// 4.2-2 a string literal can be converted to pointer to char
|
||||||
if (!(targetPtrTgt instanceof IQualifierType) || !((IQualifierType) targetPtrTgt).isConst()) {
|
if (!(targetPtrTgt instanceof IQualifierType) || !((IQualifierType) targetPtrTgt).isConst()) {
|
||||||
|
@ -519,7 +519,7 @@ public class Conversions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isConverted && (target instanceof IPointerType || target instanceof IBasicType)) {
|
if (!isConverted && (target instanceof IPointerType || target instanceof IBasicType)) {
|
||||||
source = new CPPPointerType(getNestedType(arrayType.getType(), TYPEDEFS));
|
source = new CPPPointerType(getNestedType(arrayType.getType(), TDEF));
|
||||||
cost.rank= Cost.LVALUE_OR_QUALIFICATION_RANK;
|
cost.rank= Cost.LVALUE_OR_QUALIFICATION_RANK;
|
||||||
isConverted= true;
|
isConverted= true;
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ public class Conversions {
|
||||||
|
|
||||||
// 4.3 function to pointer conversion
|
// 4.3 function to pointer conversion
|
||||||
if (!isConverted && target instanceof IPointerType) {
|
if (!isConverted && target instanceof IPointerType) {
|
||||||
final IType targetPtrTgt= getNestedType(((IPointerType) target).getType(), TYPEDEFS);
|
final IType targetPtrTgt= getNestedType(((IPointerType) target).getType(), TDEF);
|
||||||
if (targetPtrTgt instanceof IFunctionType && srcRValue instanceof IFunctionType) {
|
if (targetPtrTgt instanceof IFunctionType && srcRValue instanceof IFunctionType) {
|
||||||
source = new CPPPointerType(source);
|
source = new CPPPointerType(source);
|
||||||
cost.rank= Cost.LVALUE_OR_QUALIFICATION_RANK;
|
cost.rank= Cost.LVALUE_OR_QUALIFICATION_RANK;
|
||||||
|
@ -537,9 +537,9 @@ public class Conversions {
|
||||||
|
|
||||||
// this should actually be done in 'checkImplicitConversionSequence', see 13.3.3.1-6 and 8.5.14
|
// this should actually be done in 'checkImplicitConversionSequence', see 13.3.3.1-6 and 8.5.14
|
||||||
// 8.5.14 cv-qualifiers can be ignored for non-class types
|
// 8.5.14 cv-qualifiers can be ignored for non-class types
|
||||||
IType unqualifiedTarget= getNestedType(target, QUALIFIERS | PTR_QUALIFIERS | TYPEDEFS | REFERENCES);
|
IType unqualifiedTarget= getNestedType(target, CVQ | PTR_CVQ | TDEF | REF);
|
||||||
if (!(unqualifiedTarget instanceof ICPPClassType)) {
|
if (!(unqualifiedTarget instanceof ICPPClassType)) {
|
||||||
IType unqualifiedSource= getNestedType(source, QUALIFIERS | PTR_QUALIFIERS | TYPEDEFS | REFERENCES);
|
IType unqualifiedSource= getNestedType(source, CVQ | PTR_CVQ | TDEF | REF);
|
||||||
if (!(unqualifiedSource instanceof ICPPClassType)) {
|
if (!(unqualifiedSource instanceof ICPPClassType)) {
|
||||||
source= unqualifiedSource;
|
source= unqualifiedSource;
|
||||||
target= unqualifiedTarget;
|
target= unqualifiedTarget;
|
||||||
|
@ -569,8 +569,8 @@ public class Conversions {
|
||||||
boolean constInEveryCV2k = true;
|
boolean constInEveryCV2k = true;
|
||||||
boolean firstPointer= true;
|
boolean firstPointer= true;
|
||||||
while (true) {
|
while (true) {
|
||||||
s= getNestedType(s, TYPEDEFS | REFERENCES);
|
s= getNestedType(s, TDEF | REF);
|
||||||
t= getNestedType(t, TYPEDEFS | REFERENCES);
|
t= getNestedType(t, TDEF | REF);
|
||||||
if (s instanceof IPointerType && t instanceof IPointerType) {
|
if (s instanceof IPointerType && t instanceof IPointerType) {
|
||||||
final int cmp= compareQualifications(t, s); // is t more qualified than s?
|
final int cmp= compareQualifications(t, s); // is t more qualified than s?
|
||||||
if (cmp < 0 || (cmp > 0 && !constInEveryCV2k)) {
|
if (cmp < 0 || (cmp > 0 && !constInEveryCV2k)) {
|
||||||
|
@ -610,8 +610,8 @@ public class Conversions {
|
||||||
} else if (cmp != 0) {
|
} else if (cmp != 0) {
|
||||||
cost.qualification= Cost.CONVERSION_RANK;
|
cost.qualification= Cost.CONVERSION_RANK;
|
||||||
}
|
}
|
||||||
s= getNestedType(s, QUALIFIERS | TYPEDEFS | REFERENCES);
|
s= getNestedType(s, CVQ | TDEF | REF);
|
||||||
t= getNestedType(t, QUALIFIERS | TYPEDEFS | REFERENCES);
|
t= getNestedType(t, CVQ | TDEF | REF);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s != null && t != null && s.isSameType(t);
|
return s != null && t != null && s.isSameType(t);
|
||||||
|
@ -730,7 +730,7 @@ public class Conversions {
|
||||||
IPointerType srcPtr= (IPointerType) s;
|
IPointerType srcPtr= (IPointerType) s;
|
||||||
// 4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
|
// 4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
|
||||||
// converted to an rvalue of type "pointer to cv void"
|
// converted to an rvalue of type "pointer to cv void"
|
||||||
IType tgtPtrTgt= getNestedType(tgtPtr.getType(), TYPEDEFS | QUALIFIERS | REFERENCES);
|
IType tgtPtrTgt= getNestedType(tgtPtr.getType(), TDEF | CVQ | REF);
|
||||||
if (tgtPtrTgt instanceof IBasicType && ((IBasicType) tgtPtrTgt).getType() == IBasicType.t_void) {
|
if (tgtPtrTgt instanceof IBasicType && ((IBasicType) tgtPtrTgt).getType() == IBasicType.t_void) {
|
||||||
cost.rank = Cost.CONVERSION_RANK;
|
cost.rank = Cost.CONVERSION_RANK;
|
||||||
cost.conversion = 1;
|
cost.conversion = 1;
|
||||||
|
@ -745,7 +745,7 @@ public class Conversions {
|
||||||
if (!tIsPtrToMember && !sIsPtrToMember) {
|
if (!tIsPtrToMember && !sIsPtrToMember) {
|
||||||
// 4.10-3 An rvalue of type "pointer to cv D", where D is a class type can be converted
|
// 4.10-3 An rvalue of type "pointer to cv D", where D is a class type can be converted
|
||||||
// to an rvalue of type "pointer to cv B", where B is a base class of D.
|
// to an rvalue of type "pointer to cv B", where B is a base class of D.
|
||||||
IType srcPtrTgt= getNestedType(srcPtr.getType(), TYPEDEFS | QUALIFIERS | REFERENCES);
|
IType srcPtrTgt= getNestedType(srcPtr.getType(), TDEF | CVQ | REF);
|
||||||
if (tgtPtrTgt instanceof ICPPClassType && srcPtrTgt instanceof ICPPClassType) {
|
if (tgtPtrTgt instanceof ICPPClassType && srcPtrTgt instanceof ICPPClassType) {
|
||||||
int depth= calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, srcPtrTgt, tgtPtrTgt);
|
int depth= calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, srcPtrTgt, tgtPtrTgt);
|
||||||
if (depth == -1) {
|
if (depth == -1) {
|
||||||
|
|
|
@ -51,10 +51,13 @@ public class SemanticUtil {
|
||||||
// Cache of overloadable operator names for fast lookup. Used by isConversionOperator.
|
// Cache of overloadable operator names for fast lookup. Used by isConversionOperator.
|
||||||
private static final CharArraySet cas= new CharArraySet(OverloadableOperator.values().length);
|
private static final CharArraySet cas= new CharArraySet(OverloadableOperator.values().length);
|
||||||
|
|
||||||
static final int TYPEDEFS = 0x1;
|
public static final int TDEF = 0x01;
|
||||||
static final int REFERENCES = 0x2;
|
public static final int REF = 0x02;
|
||||||
static final int QUALIFIERS = 0x4;
|
public static final int CVQ = 0x04;
|
||||||
static final int PTR_QUALIFIERS= 0x8;
|
public static final int PTR_CVQ= 0x08;
|
||||||
|
public static final int PTR= 0x10;
|
||||||
|
public static final int MPTR= 0x20;
|
||||||
|
public static final int ARRAY= 0x40;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final int OPERATOR_SPC= OPERATOR_CHARS.length + 1;
|
final int OPERATOR_SPC= OPERATOR_CHARS.length + 1;
|
||||||
|
@ -163,106 +166,69 @@ public class SemanticUtil {
|
||||||
* @return the deepest type in a type container sequence
|
* @return the deepest type in a type container sequence
|
||||||
*/
|
*/
|
||||||
public static IType getUltimateType(IType type, boolean stopAtPointerToMember) {
|
public static IType getUltimateType(IType type, boolean stopAtPointerToMember) {
|
||||||
try {
|
if (stopAtPointerToMember)
|
||||||
while (true) {
|
return getNestedType(type, TDEF | CVQ | PTR | ARRAY | REF);
|
||||||
if (type instanceof ITypedef) {
|
return getNestedType(type, TDEF | CVQ | PTR | ARRAY | MPTR | REF);
|
||||||
IType tt= ((ITypedef) type).getType();
|
|
||||||
if (tt == null)
|
|
||||||
return type;
|
|
||||||
type= tt;
|
|
||||||
} else if (type instanceof IQualifierType) {
|
|
||||||
type= ((IQualifierType) type).getType();
|
|
||||||
} else if (stopAtPointerToMember && type instanceof ICPPPointerToMemberType) {
|
|
||||||
return type;
|
|
||||||
} else if (type instanceof IPointerType) {
|
|
||||||
type= ((IPointerType) type).getType();
|
|
||||||
} else if (type instanceof IArrayType) {
|
|
||||||
type= ((IArrayType) type).getType();
|
|
||||||
} else if (type instanceof ICPPReferenceType) {
|
|
||||||
type= ((ICPPReferenceType) type).getType();
|
|
||||||
} else {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
|
||||||
return e.getProblem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Descends into type containers, stopping at pointer or
|
* Descends into type containers, stopping at array, pointer or
|
||||||
* pointer-to-member types.
|
* pointer-to-member types.
|
||||||
* @param type
|
* @param type
|
||||||
* @return the ultimate type contained inside the specified type
|
* @return the ultimate type contained inside the specified type
|
||||||
*/
|
*/
|
||||||
public static IType getUltimateTypeUptoPointers(IType type) {
|
public static IType getUltimateTypeUptoPointers(IType type) {
|
||||||
try {
|
return getNestedType(type, TDEF | REF | CVQ);
|
||||||
while (true) {
|
|
||||||
if (type instanceof ITypedef) {
|
|
||||||
IType tt= ((ITypedef) type).getType();
|
|
||||||
if (tt == null)
|
|
||||||
return type;
|
|
||||||
type= tt;
|
|
||||||
} else if (type instanceof IQualifierType) {
|
|
||||||
type = ((IQualifierType) type).getType();
|
|
||||||
} else if (type instanceof ICPPReferenceType) {
|
|
||||||
type = ((ICPPReferenceType) type).getType();
|
|
||||||
} else {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
|
||||||
return e.getProblem();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Descends into a typedef sequence.
|
|
||||||
*/
|
|
||||||
public static IType getUltimateTypeViaTypedefs(IType type) {
|
|
||||||
return getNestedType(type, TYPEDEFS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Descends into typedefs, references, etc. as specified by options.
|
* Descends into typedefs, references, etc. as specified by options.
|
||||||
*/
|
*/
|
||||||
public static IType getNestedType(IType type, int options) {
|
public static IType getNestedType(IType type, int options) {
|
||||||
boolean typedefs= (options & TYPEDEFS) != 0;
|
boolean tdef= (options & TDEF) != 0;
|
||||||
boolean refs= (options & REFERENCES) != 0;
|
boolean ptrcvq= (options & PTR_CVQ) != 0;
|
||||||
boolean qualifiers= (options & QUALIFIERS) != 0;
|
boolean ptr= (options & PTR) != 0;
|
||||||
boolean ptrQualifiers= (options & PTR_QUALIFIERS) != 0;
|
boolean mptr= (options & MPTR) != 0;
|
||||||
|
assert !(ptrcvq && (ptr || mptr));
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
IType t= null;
|
IType t= null;
|
||||||
if (typedefs && type instanceof ITypedef) {
|
if (type instanceof IPointerType) {
|
||||||
|
final boolean isMbrPtr = type instanceof ICPPPointerToMemberType;
|
||||||
|
if ((ptr && !isMbrPtr) || (mptr && isMbrPtr)) {
|
||||||
|
t= ((IPointerType) type).getType();
|
||||||
|
} else if (ptrcvq) {
|
||||||
|
if (type instanceof CPPPointerType) {
|
||||||
|
return ((CPPPointerType) type).stripQualifiers();
|
||||||
|
}
|
||||||
|
IPointerType p= (IPointerType) type;
|
||||||
|
if (p.isConst() || p.isVolatile()) {
|
||||||
|
if (p instanceof ICPPPointerToMemberType) {
|
||||||
|
final IType memberOfClass = ((ICPPPointerToMemberType) p).getMemberOfClass();
|
||||||
|
if (memberOfClass instanceof ICPPClassType)
|
||||||
|
return new CPPPointerToMemberType(p.getType(), memberOfClass, false, false);
|
||||||
|
} else {
|
||||||
|
return new CPPPointerType(p.getType(), false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (tdef && type instanceof ITypedef) {
|
||||||
t= ((ITypedef) type).getType();
|
t= ((ITypedef) type).getType();
|
||||||
} else if (refs && type instanceof ICPPReferenceType) {
|
|
||||||
t= ((ICPPReferenceType) type).getType();
|
|
||||||
} else if (type instanceof IQualifierType) {
|
} else if (type instanceof IQualifierType) {
|
||||||
final IQualifierType qt = (IQualifierType) type;
|
final IQualifierType qt = (IQualifierType) type;
|
||||||
if (qualifiers) {
|
if (((options & CVQ) != 0)) {
|
||||||
t= qt.getType();
|
t= qt.getType();
|
||||||
} else if (typedefs) {
|
} else if (tdef) {
|
||||||
IType temp= qt.getType();
|
IType temp= qt.getType();
|
||||||
if (temp instanceof ITypedef) {
|
if (temp instanceof ITypedef) {
|
||||||
temp= getNestedType(temp, TYPEDEFS);
|
temp= getNestedType(temp, TDEF);
|
||||||
return addQualifiers(temp, qt.isConst(), qt.isVolatile());
|
return addQualifiers(temp, qt.isConst(), qt.isVolatile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ptrQualifiers && type instanceof IPointerType) {
|
} else if ((options & ARRAY) != 0 && type instanceof IArrayType) {
|
||||||
if (type instanceof CPPPointerType) {
|
t= ((IArrayType) type).getType();
|
||||||
return ((CPPPointerType) type).stripQualifiers();
|
} else if ((options & REF) != 0 && type instanceof ICPPReferenceType) {
|
||||||
}
|
t= ((ICPPReferenceType) type).getType();
|
||||||
IPointerType ptr= (IPointerType) type;
|
|
||||||
if (ptr.isConst() || ptr.isVolatile()) {
|
|
||||||
if (ptr instanceof ICPPPointerToMemberType) {
|
|
||||||
final IType memberOfClass = ((ICPPPointerToMemberType) ptr).getMemberOfClass();
|
|
||||||
if (memberOfClass instanceof ICPPClassType)
|
|
||||||
return new CPPPointerToMemberType(ptr.getType(), memberOfClass, false, false);
|
|
||||||
} else {
|
|
||||||
return new CPPPointerType(ptr.getType(), false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (t == null)
|
if (t == null)
|
||||||
return type;
|
return type;
|
||||||
|
@ -279,17 +245,18 @@ public class SemanticUtil {
|
||||||
*/
|
*/
|
||||||
static IType getSimplifiedType(IType type) {
|
static IType getSimplifiedType(IType type) {
|
||||||
try {
|
try {
|
||||||
if (type instanceof IFunctionType) {
|
if (type instanceof ICPPFunctionType) {
|
||||||
|
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||||
IType ret = null;
|
IType ret = null;
|
||||||
IType[] params = null;
|
IType[] params = null;
|
||||||
final IType r = ((IFunctionType) type).getReturnType();
|
final IType r = ft.getReturnType();
|
||||||
ret = getSimplifiedType(r);
|
ret = getSimplifiedType(r);
|
||||||
IType[] ps = ((IFunctionType) type).getParameterTypes();
|
IType[] ps = ft.getParameterTypes();
|
||||||
params = getSimplifiedTypes(ps);
|
params = getSimplifiedTypes(ps);
|
||||||
if (ret == r && params == ps) {
|
if (ret == r && params == ps) {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
return new CPPFunctionType(ret, params, ((ICPPFunctionType) type).getThisType());
|
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type instanceof ITypedef) {
|
if (type instanceof ITypedef) {
|
||||||
|
@ -386,7 +353,7 @@ public class SemanticUtil {
|
||||||
*/
|
*/
|
||||||
public static IType adjustParameterType(final IType pt, boolean forFunctionType) {
|
public static IType adjustParameterType(final IType pt, boolean forFunctionType) {
|
||||||
// bug 239975
|
// bug 239975
|
||||||
IType t= SemanticUtil.getUltimateTypeViaTypedefs(pt);
|
IType t= SemanticUtil.getNestedType(pt, TDEF);
|
||||||
try {
|
try {
|
||||||
if (t instanceof IArrayType) {
|
if (t instanceof IArrayType) {
|
||||||
IArrayType at = (IArrayType) t;
|
IArrayType at = (IArrayType) t;
|
||||||
|
@ -402,7 +369,7 @@ public class SemanticUtil {
|
||||||
//8.3.5-3
|
//8.3.5-3
|
||||||
//Any cv-qualifier modifying a parameter type is deleted.
|
//Any cv-qualifier modifying a parameter type is deleted.
|
||||||
if (forFunctionType && (t instanceof IQualifierType || t instanceof IPointerType)) {
|
if (forFunctionType && (t instanceof IQualifierType || t instanceof IPointerType)) {
|
||||||
return SemanticUtil.getNestedType(t, TYPEDEFS | QUALIFIERS | PTR_QUALIFIERS);
|
return SemanticUtil.getNestedType(t, TDEF | CVQ | PTR_CVQ);
|
||||||
}
|
}
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
|
|
||||||
|
public class CPPPointerToMemberTypeClone extends PointerTypeClone implements ICPPPointerToMemberType {
|
||||||
|
public CPPPointerToMemberTypeClone(ICPPPointerToMemberType pointer) {
|
||||||
|
super(pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType getMemberOfClass() {
|
||||||
|
return ((ICPPPointerToMemberType) delegate).getMemberOfClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
return new CPPPointerToMemberTypeClone((ICPPPointerToMemberType) delegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSameType(IType o) {
|
||||||
|
if (o instanceof ITypedef)
|
||||||
|
return o.isSameType(this);
|
||||||
|
|
||||||
|
if (!(o instanceof ICPPPointerToMemberType))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!super.isSameType(o))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ICPPPointerToMemberType pt = (ICPPPointerToMemberType) o;
|
||||||
|
IType cls = pt.getMemberOfClass();
|
||||||
|
if (cls != null)
|
||||||
|
return cls.isSameType(getMemberOfClass());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 QNX Software Systems and others.
|
* Copyright (c) 2007, 2009 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,6 +51,9 @@ public class PointerTypeClone implements IPointerType, ITypeContainer, IIndexTyp
|
||||||
if (!(type instanceof IPointerType))
|
if (!(type instanceof IPointerType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (this instanceof ICPPPointerToMemberType != type instanceof ICPPPointerToMemberType)
|
||||||
|
return false;
|
||||||
|
|
||||||
IPointerType rhs = (IPointerType) type;
|
IPointerType rhs = (IPointerType) type;
|
||||||
try {
|
try {
|
||||||
if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
|
if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2009 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -22,8 +22,9 @@ public class CompositeCPPFunctionType extends CompositeFunctionType implements I
|
||||||
super(rtype, cf);
|
super(rtype, cf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public IPointerType getThisType() {
|
public IPointerType getThisType() {
|
||||||
return ((ICPPFunctionType) type).getThisType();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConst() {
|
public boolean isConst() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2009 Symbian Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.CPPPointerToMemberTypeClone;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
|
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
|
@ -28,4 +29,9 @@ class CompositeCPPPointerToMemberType extends CompositePointerType implements IC
|
||||||
IIndexFragmentBinding rbinding = (IIndexFragmentBinding) ((ICPPPointerToMemberType) type).getMemberOfClass();
|
IIndexFragmentBinding rbinding = (IIndexFragmentBinding) ((ICPPPointerToMemberType) type).getMemberOfClass();
|
||||||
return (IType) cf.getCompositeBinding(rbinding);
|
return (IType) cf.getCompositeBinding(rbinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object clone() {
|
||||||
|
return new CPPPointerToMemberTypeClone(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
|
||||||
|
@ -28,7 +29,7 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* Pointer types for c and c++.
|
||||||
*/
|
*/
|
||||||
public class PDOMPointerType extends PDOMNode implements IPointerType,
|
public class PDOMPointerType extends PDOMNode implements IPointerType,
|
||||||
ITypeContainer, IIndexType {
|
ITypeContainer, IIndexType {
|
||||||
|
@ -118,9 +119,12 @@ public class PDOMPointerType extends PDOMNode implements IPointerType,
|
||||||
if( type instanceof ITypedef )
|
if( type instanceof ITypedef )
|
||||||
return ((ITypedef)type).isSameType( this );
|
return ((ITypedef)type).isSameType( this );
|
||||||
|
|
||||||
if( !( type instanceof IPointerType ))
|
if (!(type instanceof IPointerType))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (this instanceof ICPPPointerToMemberType != type instanceof ICPPPointerToMemberType)
|
||||||
|
return false;
|
||||||
|
|
||||||
IPointerType rhs = (IPointerType) type;
|
IPointerType rhs = (IPointerType) type;
|
||||||
try {
|
try {
|
||||||
if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
|
if (isConst() == rhs.isConst() && isVolatile() == rhs.isVolatile()) {
|
||||||
|
|
|
@ -123,11 +123,11 @@ public class PDOMCFunctionType extends PDOMNode implements IIndexType, IFunction
|
||||||
IType[] params1= getParameterTypes();
|
IType[] params1= getParameterTypes();
|
||||||
IType[] params2= ft.getParameterTypes();
|
IType[] params2= ft.getParameterTypes();
|
||||||
if (params1.length == 1 && params2.length == 0) {
|
if (params1.length == 1 && params2.length == 0) {
|
||||||
IType p0= SemanticUtil.getUltimateTypeViaTypedefs(params1[0]);
|
IType p0= SemanticUtil.getNestedType(params1[0], SemanticUtil.TDEF);
|
||||||
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
||||||
return false;
|
return false;
|
||||||
} else if (params2.length == 1 && params1.length == 0) {
|
} else if (params2.length == 1 && params1.length == 0) {
|
||||||
IType p0= SemanticUtil.getUltimateTypeViaTypedefs(params2[0]);
|
IType p0= SemanticUtil.getNestedType(params2[0], SemanticUtil.TDEF);
|
||||||
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
if (!(p0 instanceof IBasicType) || ((IBasicType) p0).getType() != IBasicType.t_void)
|
||||||
return false;
|
return false;
|
||||||
} else if (params1.length != params2.length) {
|
} else if (params1.length != params2.length) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* Typedefs for c
|
||||||
*/
|
*/
|
||||||
class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IIndexType {
|
class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IIndexType {
|
||||||
|
|
||||||
|
@ -145,6 +145,11 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String toStringBase() {
|
||||||
|
return getName() + ": " + super.toStringBase(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(IType type) {fail();}
|
public void setType(IType type) {fail();}
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {fail(); return null;}
|
public Object clone() {fail(); return null;}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
|
@ -28,6 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
public class PDOMCPPFunctionType extends PDOMCFunctionType implements ICPPFunctionType {
|
public class PDOMCPPFunctionType extends PDOMCFunctionType implements ICPPFunctionType {
|
||||||
private static IType FALLBACK_RETURN_TYPE= new CPPBasicType(IBasicType.t_void, 0);
|
private static IType FALLBACK_RETURN_TYPE= new CPPBasicType(IBasicType.t_void, 0);
|
||||||
static ICPPFunctionType FALLBACK= new ICPPFunctionType() {
|
static ICPPFunctionType FALLBACK= new ICPPFunctionType() {
|
||||||
|
@Deprecated
|
||||||
public IPointerType getThisType() {
|
public IPointerType getThisType() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -56,15 +56,16 @@ public class PDOMCPPFunctionType extends PDOMCFunctionType implements ICPPFuncti
|
||||||
* Offset for <code>this</code> type of this function (relative to
|
* Offset for <code>this</code> type of this function (relative to
|
||||||
* the beginning of the record).
|
* the beginning of the record).
|
||||||
*/
|
*/
|
||||||
private static final int THIS_TYPE= PDOMCFunctionType.RECORD_SIZE;
|
private static final int CV= PDOMCFunctionType.RECORD_SIZE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size in bytes of a PDOMCFunctionType record in the database.
|
* The size in bytes of a PDOMCFunctionType record in the database.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
private static final int RECORD_SIZE= PDOMCFunctionType.RECORD_SIZE + 4;
|
private static final int RECORD_SIZE= PDOMCFunctionType.RECORD_SIZE + 1;
|
||||||
|
|
||||||
IPointerType thisType; // Cached value
|
IPointerType thisType; // Cached value
|
||||||
|
int cvq= -1; // Cached value
|
||||||
|
|
||||||
protected PDOMCPPFunctionType(PDOMLinkage linkage, int offset) {
|
protected PDOMCPPFunctionType(PDOMLinkage linkage, int offset) {
|
||||||
super(linkage, offset);
|
super(linkage, offset);
|
||||||
|
@ -73,36 +74,37 @@ public class PDOMCPPFunctionType extends PDOMCFunctionType implements ICPPFuncti
|
||||||
protected PDOMCPPFunctionType(PDOMLinkage linkage, PDOMNode parent, ICPPFunctionType type)
|
protected PDOMCPPFunctionType(PDOMLinkage linkage, PDOMNode parent, ICPPFunctionType type)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
super(linkage, parent, type);
|
super(linkage, parent, type);
|
||||||
setThisType(type.getThisType());
|
setcvq(type.isConst(), type.isVolatile());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setThisType(IPointerType type) throws CoreException {
|
private void setcvq(boolean isConst, boolean isVolatile) throws CoreException {
|
||||||
PDOMNode typeNode = getLinkage().addType(this, type);
|
int v= (isConst ? 1 : 0) + (isVolatile ? 2 : 0);
|
||||||
if (typeNode != null) {
|
getDB().putByte(record + CV, (byte) v);
|
||||||
getDB().putInt(record + THIS_TYPE, typeNode.getRecord());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public IPointerType getThisType() {
|
public IPointerType getThisType() {
|
||||||
if (thisType == null) {
|
return null;
|
||||||
try {
|
|
||||||
PDOMNode node = getLinkage().getNode(getDB().getInt(record + THIS_TYPE));
|
|
||||||
if (node instanceof IPointerType) {
|
|
||||||
thisType = (IPointerType) node;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return thisType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isConst() {
|
public final boolean isConst() {
|
||||||
return getThisType() != null && getThisType().isConst();
|
readcvq();
|
||||||
|
return (cvq & 1) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readcvq() {
|
||||||
|
if (cvq == -1) {
|
||||||
|
try {
|
||||||
|
cvq= getDB().getByte(record + CV);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
cvq= 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isVolatile() {
|
public final boolean isVolatile() {
|
||||||
return getThisType() != null && getThisType().isVolatile();
|
readcvq();
|
||||||
|
return (cvq & 2) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,20 +10,23 @@
|
||||||
* Bryan Wilkinson (QNX)
|
* Bryan Wilkinson (QNX)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPPointerToMemberType;
|
||||||
|
import org.eclipse.cdt.internal.core.index.CPPPointerToMemberTypeClone;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.PointerTypeClone;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMPointerType;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMPointerType;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to member type
|
||||||
|
*/
|
||||||
class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerToMemberType {
|
class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerToMemberType {
|
||||||
private static final int TYPE = PDOMPointerType.RECORD_SIZE;
|
private static final int TYPE = PDOMPointerType.RECORD_SIZE;
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
|
@ -69,23 +72,27 @@ class PDOMCPPPointerToMemberType extends PDOMPointerType implements ICPPPointerT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public boolean isSameType(IType o) {
|
||||||
return new PDOMCPPPointerToMemberTypeClone(this);
|
if (o instanceof ITypedef)
|
||||||
|
return o.isSameType(this);
|
||||||
|
|
||||||
|
if (!(o instanceof ICPPPointerToMemberType))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!super.isSameType(o))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ICPPPointerToMemberType pt = (ICPPPointerToMemberType) o;
|
||||||
|
IType cls = pt.getMemberOfClass();
|
||||||
|
if (cls != null)
|
||||||
|
return cls.isSameType(getMemberOfClass());
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PDOMCPPPointerToMemberTypeClone extends PointerTypeClone implements ICPPPointerToMemberType {
|
@Override
|
||||||
public PDOMCPPPointerToMemberTypeClone(ICPPPointerToMemberType pointer) {
|
public Object clone() {
|
||||||
super(pointer);
|
return new CPPPointerToMemberTypeClone(this);
|
||||||
}
|
|
||||||
|
|
||||||
public IType getMemberOfClass() {
|
|
||||||
return ((ICPPPointerToMemberType) delegate).getMemberOfClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object clone() {
|
|
||||||
return new PDOMCPPPointerToMemberTypeClone((ICPPPointerToMemberType) delegate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* Typedefs for c++
|
||||||
*/
|
*/
|
||||||
class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer, IIndexType {
|
class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer, IIndexType {
|
||||||
|
|
||||||
|
@ -152,6 +152,11 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String toStringBase() {
|
||||||
|
return getName() + ": " + super.toStringBase(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
public void setType(IType type) { fail(); }
|
public void setType(IType type) { fail(); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue