1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-09-20 17:36:01 -07:00
parent 4f80345f71
commit 83124590a9
12 changed files with 76 additions and 70 deletions

View file

@ -1596,6 +1596,22 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertEquals("ns", ref.getOwner().getName()); assertEquals("ns", ref.getOwner().getName());
} }
// class A {};
// void f(A a) {}
// struct B {};
// void g(B b) {}
// struct A;
// class B;
//
// void test(A a, B b) {
// f(a);
// g(b);
// }
public void testStructClassMismatch_358282() throws Exception {
getBindingFromASTName("f(a)", 1, ICPPFunction.class);
getBindingFromASTName("g(b)", 1, ICPPFunction.class);
}
/* CPP assertion helpers */ /* CPP assertion helpers */
/* ##################################################################### */ /* ##################################################################### */

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IField;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPClassType extends ICompositeType, ICPPBinding { public interface ICPPClassType extends ICompositeType, ICPPBinding {
public static final ICPPClassType[] EMPTY_CLASS_ARRAY = new ICPPClassType[0]; public static final ICPPClassType[] EMPTY_CLASS_ARRAY = {};
public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class; public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class;
/** /**

View file

@ -208,8 +208,9 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
*/ */
public int getKey() { public int getKey() {
return (definition != null) ? ((IASTCompositeTypeSpecifier) definition.getParent()).getKey() return definition != null ?
: ((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind(); ((IASTCompositeTypeSpecifier) definition.getParent()).getKey() :
((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind();
} }
/* /*

View file

@ -222,7 +222,6 @@ public class CPPClassSpecialization extends CPPSpecialization
return scope.getNestedClasses(); return scope.getNestedClasses();
} }
public IField[] getFields() { public IField[] getFields() {
return ClassTypeHelper.getFields(this); return ClassTypeHelper.getFields(this);
} }
@ -239,7 +238,6 @@ public class CPPClassSpecialization extends CPPSpecialization
return ClassTypeHelper.getAllDeclaredMethods(this); return ClassTypeHelper.getAllDeclaredMethods(this);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
*/ */
@ -247,7 +245,7 @@ public class CPPClassSpecialization extends CPPSpecialization
if (getDefinition() != null) if (getDefinition() != null)
return getCompositeTypeSpecifier().getKey(); return getCompositeTypeSpecifier().getKey();
return (getSpecializedBinding()).getKey(); return getSpecializedBinding().getKey();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -316,7 +314,6 @@ public class CPPClassSpecialization extends CPPSpecialization
return false; return false;
} }
public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) { public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) {
// exclude class template specialization or class instance // exclude class template specialization or class instance
if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition || if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition ||

View file

@ -280,7 +280,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
} }
public IASTNode getPhysicalNode() { public IASTNode getPhysicalNode() {
return (definition != null) ? (IASTNode) definition : declarations[0]; return definition != null ? (IASTNode) definition : declarations[0];
} }
public int getKey() { public int getKey() {
@ -306,7 +306,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
return; return;
} }
//keep the lowest offset declaration in [0] // Keep the lowest offset declaration in [0]
if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode) declarations[0]).getOffset()) { if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name); declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name);
} else { } else {

View file

@ -30,12 +30,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
* Represents a instantiation that cannot be performed because of dependent arguments or an unknown template. * Represents a instantiation that cannot be performed because of dependent arguments or an unknown template.
*/ */
public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance { public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
private final ICPPTemplateArgument[] fArguments; private final ICPPTemplateArgument[] fArguments;
private final ICPPClassTemplate fClassTemplate; private final ICPPClassTemplate fClassTemplate;
private final ICPPScope fLookupScope; private final ICPPScope fLookupScope;
public CPPDeferredClassInstance(ICPPClassTemplate template, ICPPTemplateArgument[] arguments, ICPPScope lookupScope) throws DOMException { public CPPDeferredClassInstance(ICPPClassTemplate template, ICPPTemplateArgument[] arguments,
ICPPScope lookupScope) throws DOMException {
// With template template parameters the owner must not be calculated, it'd lead to an infinite loop. // With template template parameters the owner must not be calculated, it'd lead to an infinite loop.
// Rather than that we override getOwner(). // Rather than that we override getOwner().
super(null, template.getNameCharArray()); super(null, template.getNameCharArray());
@ -48,7 +48,6 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
this(template, arguments, null); this(template, arguments, null);
} }
@Override @Override
public IBinding getOwner() { public IBinding getOwner() {
return fClassTemplate.getOwner(); return fClassTemplate.getOwner();

View file

@ -49,7 +49,9 @@ class CompositeCStructure extends CompositeCBinding implements ICompositeType, I
} }
@Override @Override
public Object clone() {fail(); return null;} public Object clone() {
fail(); return null;
}
public boolean isAnonymous() { public boolean isAnonymous() {
return ((ICompositeType) rbinding).isAnonymous(); return ((ICompositeType) rbinding).isAnonymous();

View file

@ -63,8 +63,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
private volatile ICPPClassScope fScope; private volatile ICPPClassScope fScope;
private ObjectMap specializationMap= null; // Obtained from the synchronized PDOM cache private ObjectMap specializationMap= null; // Obtained from the synchronized PDOM cache
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized) public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType,
throws CoreException { PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) classType, specialized); super(linkage, parent, (ICPPSpecialization) classType, specialized);
} }
@ -177,8 +177,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
if (base != null) { if (base != null) {
if (predecessor != null) { if (predecessor != null) {
predecessor.setNextBase(base.getNextBase()); predecessor.setNextBase(base.getNextBase());
} } else {
else {
setFirstBase(base.getNextBase()); setFirstBase(base.getNextBase());
} }
base.delete(); base.delete();
@ -294,7 +293,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
} }
public int getKey() { public int getKey() {
return (getSpecializedBinding()).getKey(); return getSpecializedBinding().getKey();
} }
public boolean isSameType(IType type) { public boolean isSameType(IType type) {

View file

@ -45,19 +45,13 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
*
*/ */
class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDOMMemberOwner { class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDOMMemberOwner {
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0; private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4; private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
private static final int FIRSTFRIEND = PDOMCPPBinding.RECORD_SIZE + 8; private static final int FIRSTFRIEND = PDOMCPPBinding.RECORD_SIZE + 8;
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 12; // byte private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 12; // byte
private static final int ANONYMOUS= PDOMCPPBinding.RECORD_SIZE + 13; // byte private static final int ANONYMOUS= PDOMCPPBinding.RECORD_SIZE + 13; // byte
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 14; protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 14;
@ -163,8 +157,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
if (base != null) { if (base != null) {
if (predecessor != null) { if (predecessor != null) {
predecessor.setNextBase(base.getNextBase()); predecessor.setNextBase(base.getNextBase());
} } else {
else {
setFirstBase(base.getNextBase()); setFirstBase(base.getNextBase());
} }
base.delete(); base.delete();
@ -202,8 +195,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
if (friend != null) { if (friend != null) {
if (predecessor != null) { if (predecessor != null) {
predecessor.setNextFriend(friend.getNextFriend()); predecessor.setNextFriend(friend.getNextFriend());
} } else {
else {
setFirstFriend(friend.getNextFriend()); setFirstFriend(friend.getNextFriend());
} }
friend.delete(); friend.delete();