1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2015-06-11 19:45:26 -07:00
parent 6356a26f0b
commit 411506db88
5 changed files with 130 additions and 123 deletions

View file

@ -9541,7 +9541,7 @@ public class AST2CPPTests extends AST2TestBase {
assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType())); assertEquals("A", ASTTypeUtil.getType(expr.getExpressionType()));
} }
// void f() { // void test() {
// int i; // int i;
// int f1(); // int f1();
// int&& f2(); // int&& f2();
@ -9552,17 +9552,16 @@ public class AST2CPPTests extends AST2TestBase {
// int l = g(f2()); // calls g(const int&&) // int l = g(f2()); // calls g(const int&&)
// } // }
public void testRankingOfReferenceBindings() throws Exception { public void testRankingOfReferenceBindings() throws Exception {
String code= getAboveComment(); BindingAssertionHelper bh= getAssertionHelper();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true); IFunction g1= bh.assertNonProblemOnFirstIdentifier("g(const int&)");
IFunction g1= bh.assertNonProblem("g(const int&)", 1); IFunction g2= bh.assertNonProblemOnFirstIdentifier("g(const int&&)");
IFunction g2= bh.assertNonProblem("g(const int&&)", 1);
IFunction ref; IFunction ref;
ref= bh.assertNonProblem("g(i);", 1); ref= bh.assertNonProblemOnFirstIdentifier("g(i);");
assertSame(g1, ref); assertSame(g1, ref);
ref= bh.assertNonProblem("g(f1());", 1); ref= bh.assertNonProblemOnFirstIdentifier("g(f1());");
assertSame(g2, ref); assertSame(g2, ref);
ref= bh.assertNonProblem("g(f2());", 1); ref= bh.assertNonProblemOnFirstIdentifier("g(f2());");
assertSame(g2, ref); assertSame(g2, ref);
} }

View file

@ -233,7 +233,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
/** /**
* Name resolution * Name resolution.
*/ */
public class CPPSemantics { public class CPPSemantics {
/** /**
@ -274,8 +274,9 @@ public class CPPSemantics {
static protected IBinding resolveBinding(IASTName name) { static protected IBinding resolveBinding(IASTName name) {
if (traceBindingResolution) { if (traceBindingResolution) {
for (int i = 0; i < traceIndent; i++) for (int i = 0; i < traceIndent; i++) {
System.out.print(" "); //$NON-NLS-1$ System.out.print(" "); //$NON-NLS-1$
}
System.out.println("Resolving " + name + ':' + ((ASTNode) name).getOffset()); //$NON-NLS-1$ System.out.println("Resolving " + name + ':' + ((ASTNode) name).getOffset()); //$NON-NLS-1$
traceIndent++; traceIndent++;
} }
@ -311,8 +312,9 @@ public class CPPSemantics {
binding = postResolution(binding, data); binding = postResolution(binding, data);
if (traceBindingResolution) { if (traceBindingResolution) {
traceIndent--; traceIndent--;
for (int i = 0; i < traceIndent; i++) for (int i = 0; i < traceIndent; i++) {
System.out.print(" "); //$NON-NLS-1$ System.out.print(" "); //$NON-NLS-1$
}
System.out.println("Resolved " + name + ':' + ((ASTNode) name).getOffset() + //$NON-NLS-1$ System.out.println("Resolved " + name + ':' + ((ASTNode) name).getOffset() + //$NON-NLS-1$
" to " + DebugUtil.toStringWithClass(binding) + ':' + System.identityHashCode(binding)); //$NON-NLS-1$ " to " + DebugUtil.toStringWithClass(binding) + ':' + System.identityHashCode(binding)); //$NON-NLS-1$
} }
@ -347,8 +349,9 @@ public class CPPSemantics {
// 3.4.1-10 If we don't find a name used in a friend declaration in the member // 3.4.1-10 If we don't find a name used in a friend declaration in the member
// declaration's class, we should look in the class granting friendship. // declaration's class, we should look in the class granting friendship.
IASTNode parent = lookupName.getParent(); IASTNode parent = lookupName.getParent();
while (parent != null && !(parent instanceof ICPPASTCompositeTypeSpecifier)) while (parent != null && !(parent instanceof ICPPASTCompositeTypeSpecifier)) {
parent = parent.getParent(); parent = parent.getParent();
}
if (parent instanceof ICPPASTCompositeTypeSpecifier) { if (parent instanceof ICPPASTCompositeTypeSpecifier) {
IScope scope = ((ICPPASTCompositeTypeSpecifier) parent).getScope(); IScope scope = ((ICPPASTCompositeTypeSpecifier) parent).getScope();
try { try {
@ -1528,8 +1531,9 @@ public class CPPSemantics {
continue; continue;
} }
} }
while (item instanceof IASTLabelStatement) while (item instanceof IASTLabelStatement) {
item= ((IASTLabelStatement) item).getNestedStatement(); item= ((IASTLabelStatement) item).getNestedStatement();
}
if (item instanceof IASTDeclarationStatement) if (item instanceof IASTDeclarationStatement)
item = ((IASTDeclarationStatement) item).getDeclaration(); item = ((IASTDeclarationStatement) item).getDeclaration();
if (item instanceof ICPPASTUsingDirective) { if (item instanceof ICPPASTUsingDirective) {
@ -1906,8 +1910,9 @@ public class CPPSemantics {
// Point of declaration for a name is immediately after its complete declarator // Point of declaration for a name is immediately after its complete declarator
// and before its initializer. // and before its initializer.
IASTDeclarator dtor = (IASTDeclarator)((nd instanceof IASTDeclarator) ? nd : nd.getParent()); IASTDeclarator dtor = (IASTDeclarator)((nd instanceof IASTDeclarator) ? nd : nd.getParent());
while (dtor.getParent() instanceof IASTDeclarator) while (dtor.getParent() instanceof IASTDeclarator) {
dtor = (IASTDeclarator) dtor.getParent(); dtor = (IASTDeclarator) dtor.getParent();
}
IASTInitializer init = dtor.getInitializer(); IASTInitializer init = dtor.getInitializer();
// [basic.scope.pdecl]/p9: The point of declaration for a template parameter // [basic.scope.pdecl]/p9: The point of declaration for a template parameter
// is immediately after its complete template-parameter. // is immediately after its complete template-parameter.
@ -2131,7 +2136,7 @@ public class CPPSemantics {
return type; return type;
} }
if (fns.size() > 0) { if (!fns.isEmpty()) {
final ICPPFunction[] fnArray = fns.keyArray(ICPPFunction.class); final ICPPFunction[] fnArray = fns.keyArray(ICPPFunction.class);
if (type != null && overrulesByRelevance(data, type, fnArray)) { if (type != null && overrulesByRelevance(data, type, fnArray)) {
return type; return type;
@ -2878,8 +2883,9 @@ public class CPPSemantics {
static IBinding resolveTargetedFunction(IASTName name, CPPFunctionSet functionSet) { static IBinding resolveTargetedFunction(IASTName name, CPPFunctionSet functionSet) {
boolean addressOf= false; boolean addressOf= false;
IASTNode node= name.getParent(); IASTNode node= name.getParent();
while (node instanceof IASTName) while (node instanceof IASTName) {
node= node.getParent(); node= node.getParent();
}
if (!(node instanceof IASTIdExpression)) if (!(node instanceof IASTIdExpression))
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_OVERLOAD); return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_OVERLOAD);
@ -3362,8 +3368,9 @@ public class CPPSemantics {
static enum LookupMode {NO_GLOBALS, GLOBALS_IF_NO_MEMBERS, LIMITED_GLOBALS, ALL_GLOBALS} static enum LookupMode {NO_GLOBALS, GLOBALS_IF_NO_MEMBERS, LIMITED_GLOBALS, ALL_GLOBALS}
static ICPPFunction findOverloadedOperator(IASTNode pointOfInstantiation, IScope pointOfDefinition, static ICPPFunction findOverloadedOperator(IASTNode pointOfInstantiation, IScope pointOfDefinition,
ICPPEvaluation[] args, IType methodLookupType, OverloadableOperator operator, LookupMode mode) { ICPPEvaluation[] args, IType methodLookupType, OverloadableOperator operator, LookupMode mode) {
while (pointOfInstantiation instanceof IASTName) while (pointOfInstantiation instanceof IASTName) {
pointOfInstantiation= pointOfInstantiation.getParent(); pointOfInstantiation= pointOfInstantiation.getParent();
}
ICPPClassType callToObjectOfClassType= null; ICPPClassType callToObjectOfClassType= null;
IType type2= null; IType type2= null;
@ -3471,10 +3478,11 @@ public class CPPSemantics {
} }
} }
if (j > 0) { if (j > 0) {
while (j < items.length) while (j < items.length) {
items[j++]= null; items[j++]= null;
} }
} }
}
// 13.3.1.2.3 // 13.3.1.2.3
// However, if no operand type has class type, only those non-member functions ... // However, if no operand type has class type, only those non-member functions ...
if (mode == LookupMode.LIMITED_GLOBALS) { if (mode == LookupMode.LIMITED_GLOBALS) {

View file

@ -34,7 +34,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates.TypeS
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.DeferredUDC; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.Cost.DeferredUDC;
/** /**
* Cost for the entire function call * Cost for the entire function call.
*/ */
class FunctionCost { class FunctionCost {
private final ICPPFunction fFunction; private final ICPPFunction fFunction;
@ -96,7 +96,7 @@ class FunctionCost {
for (int i = 0; i < fCosts.length; i++) { for (int i = 0; i < fCosts.length; i++) {
Cost cost = fCosts[i]; Cost cost = fCosts[i];
Cost udcCost= null; Cost udcCost= null;
switch(cost.isDeferredUDC()) { switch (cost.isDeferredUDC()) {
case NONE: case NONE:
continue; continue;
case COPY_INIT_OF_CLASS: case COPY_INIT_OF_CLASS:

View file

@ -141,11 +141,11 @@ public class TemplateArgumentDeduction {
IType arg = fnArgs.get(j); IType arg = fnArgs.get(j);
par= SemanticUtil.getNestedType(par, SemanticUtil.TDEF); // adjustParameterType preserves typedefs par= SemanticUtil.getNestedType(par, SemanticUtil.TDEF); // adjustParameterType preserves typedefs
// C++0x: 14.9.2.1-1 // C++11: 14.9.2.1-1
if (arg instanceof InitializerListType) { if (arg instanceof InitializerListType) {
par= SemanticUtil.getNestedType(par, TDEF | REF | CVTYPE); par= SemanticUtil.getNestedType(par, TDEF | REF | CVTYPE);
// Check if this is a deduced context // Check if this is a deduced context.
IType inner= Conversions.getInitListType(par); IType inner= Conversions.getInitListType(par);
if (inner != null) { if (inner != null) {
final EvalInitList eval = ((InitializerListType) arg).getEvaluation(); final EvalInitList eval = ((InitializerListType) arg).getEvaluation();