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 2012-11-27 18:36:07 -08:00
parent f6b4b3dae2
commit 67a81b6a4b
10 changed files with 63 additions and 71 deletions

View file

@ -35,7 +35,7 @@ public class CPPAliasTemplateInstance extends PlatformObject
private final ICPPAliasTemplate aliasTemplate;
private IType aliasedType;
public CPPAliasTemplateInstance(char[] name, IType aliasedType, ICPPAliasTemplate aliasTemplate) {
public CPPAliasTemplateInstance(char[] name, ICPPAliasTemplate aliasTemplate, IType aliasedType) {
this.name = name;
this.aliasTemplate = aliasTemplate;
this.aliasedType = aliasedType;
@ -122,7 +122,7 @@ public class CPPAliasTemplateInstance extends PlatformObject
char[] name = buffer.getCharArray();
IType unmarshalledAliasedTypeInstance = buffer.unmarshalType();
ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding();
return new CPPAliasTemplateInstance(name, unmarshalledAliasedTypeInstance, unmarshalledAlias);
return new CPPAliasTemplateInstance(name, unmarshalledAlias, unmarshalledAliasedTypeInstance);
}
@Override

View file

@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation 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
* Copyright (c) 2004, 2010 IBM Corporation 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:
* Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
@ -28,7 +28,8 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType
private IType fType;
public CPPTypedefSpecialization(IBinding specialized, ICPPClassType owner, ICPPTemplateParameterMap tpmap, IType type) {
public CPPTypedefSpecialization(IBinding specialized, ICPPClassType owner,
ICPPTemplateParameterMap tpmap, IType type) {
super(specialized, owner, tpmap);
fType= type;
}
@ -38,23 +39,17 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements IType
return fType;
}
/* (non-Javadoc)
* @see java.lang.Object#clone()
*/
@Override
public Object clone() {
IType t = null;
try {
t = (IType) super.clone();
} catch (CloneNotSupportedException e) {
// not going to happen
// Not going to happen.
}
return t;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
@Override
public boolean isSameType(IType o) {
if (o == this)

View file

@ -33,6 +33,7 @@ public class CPPUnknownMemberClass extends CPPUnknownMember implements ICPPUnkno
public static CPPUnknownMemberClass createUnnamedInstance() {
return new CPPUnknownMemberClass(null, CharArrayUtils.EMPTY);
}
public CPPUnknownMemberClass(IType owner, char[] name) {
super(owner, name);
}

View file

@ -241,7 +241,7 @@ public class CPPSemantics {
private static final char[] CALL_FUNCTION = "call-function".toCharArray(); //$NON-NLS-1$
private static final ICPPEvaluation[] NO_INITCLAUSE_EVALUATION = {};
// Set to true for debugging.
public static boolean traceBindingResolution = false;
public static int traceIndent= 0;
@ -308,7 +308,7 @@ public class CPPSemantics {
final IASTName lookupName = data.getLookupName();
if (lookupName == null)
return binding;
IASTNode lookupPoint = data.getLookupPoint();
if (binding == null && data.checkClassContainingFriend()) {
@ -904,7 +904,7 @@ public class CPPSemantics {
IASTName lookupName= data.getLookupName();
if (lookupName == null)
return;
nextScope= getLookupScope(lookupName);
if (nextScope instanceof ICPPTemplateScope) {
@ -1087,7 +1087,7 @@ public class CPPSemantics {
IBinding[] typedefs = ld2.getFoundBindings();
if (typedefs.length < 1 || !(typedefs[0] instanceof ITypedef))
return false;
IType t= SemanticUtil.getNestedType((ITypedef) typedefs[0], TDEF);
if (t instanceof ICPPUnknownBinding || t instanceof ISemanticProblem ||
!(t instanceof ICPPClassType)) {
@ -1224,7 +1224,7 @@ public class CPPSemantics {
}
}
}
}
}
return expandUsingDeclarationsAndRemoveObjects(bindings, data);
}
@ -1489,7 +1489,7 @@ public class CPPSemantics {
} else {
populateCache(scope, item);
}
if (nodes != null && ++idx < nodes.length) {
item = nodes[idx];
} else {
@ -1531,7 +1531,7 @@ public class CPPSemantics {
idx = nodeIdxStack[nodeStackPos--];
if (++idx >= nodes.length)
continue;
item = nodes[idx];
}
break;
@ -1764,16 +1764,16 @@ public class CPPSemantics {
// Bug 238180
if (candidate instanceof ICPPClassTemplatePartialSpecialization)
return null;
// Specialization is selected during instantiation
if (candidate instanceof ICPPTemplateInstance)
candidate= ((ICPPTemplateInstance) candidate).getSpecializedBinding();
if (!(candidate instanceof ICPPFunctionTemplate))
return candidate;
}
}
LookupData data = createLookupData(name);
data.foundItems = bindings;
try {
@ -1781,7 +1781,7 @@ public class CPPSemantics {
} catch (DOMException e) {
return e.getProblem();
}
//
//
// IBinding[] result = null;
// for (Object binding : bindings) {
// if (binding instanceof IASTName) {
@ -1796,13 +1796,13 @@ public class CPPSemantics {
public static boolean declaredBefore(Object obj, IASTNode node, boolean indexBased) {
if (node == null)
return true;
final int pointOfRef= ((ASTNode) node).getOffset();
ASTNode nd = null;
if (obj instanceof ICPPSpecialization) {
obj = ((ICPPSpecialization) obj).getSpecializedBinding();
}
int pointOfDecl= -1;
if (obj instanceof ICPPInternalBinding) {
ICPPInternalBinding cpp = (ICPPInternalBinding) obj;
@ -1838,7 +1838,7 @@ public class CPPSemantics {
pointOfDecl= ((ICPPUsingDirective) obj).getPointOfDeclaration();
}
}
if (pointOfDecl < 0 && nd != null) {
ASTNodeProperty prop = nd.getPropertyInParent();
if (prop == IASTDeclarator.DECLARATOR_NAME || nd instanceof IASTDeclarator) {
@ -1903,13 +1903,13 @@ public class CPPSemantics {
final IASTName lookupName = data.getLookupName();
IASTNode lookupPoint = data.getLookupPoint();
final boolean indexBased= data.getIndex() != null;
final boolean checkWholeClass= lookupName == null || LookupData.checkWholeClassScope(lookupName);
final boolean checkWholeClass= lookupName == null || LookupData.checkWholeClassScope(lookupName);
@SuppressWarnings("unchecked")
ObjectSet<ICPPFunction> fns= ObjectSet.EMPTY_SET;
IBinding type = null;
IBinding obj = null;
IBinding temp = null;
final CPPASTTranslationUnit tu = data.getTranslationUnit();
Object[] items = (Object[]) data.foundItems;
for (int i = 0; i < items.length && items[i] != null; i++) {
@ -2059,7 +2059,7 @@ public class CPPSemantics {
if (type != null && overrulesByRelevance(data, type, fnArray)) {
return type;
}
if (obj != null) {
int cmp= compareByRelevance(data, obj, fnArray);
if (cmp == 0) {
@ -2072,7 +2072,7 @@ public class CPPSemantics {
}
return resolveFunction(data, fnArray, true);
}
if (obj != null) {
return obj;
}
@ -2342,9 +2342,9 @@ public class CPPSemantics {
if (fns == null || fns.length == 0 || fns[0] == null)
return null;
fns= ArrayUtil.trim(fns);
sortAstBeforeIndex(fns);
if (data.forUsingDeclaration)
return new CPPUsingDeclaration(lookupName, fns);
@ -2355,7 +2355,7 @@ public class CPPSemantics {
if (data.forDeclaration() != null) {
return resolveFunctionDeclaration(data, fns);
}
// No arguments to resolve function
final IASTNode lookupPoint = data.getLookupPoint();
if (!data.hasFunctionArguments()) {
@ -2365,9 +2365,9 @@ public class CPPSemantics {
// Reduce our set of candidate functions to only those who have the right number of parameters
final IType[] argTypes = data.getFunctionArgumentTypes();
ICPPFunction[] tmp= selectByArgumentCount(data, fns);
tmp= CPPTemplates.instantiateForFunctionCall(tmp, data.fTemplateArguments,
tmp= CPPTemplates.instantiateForFunctionCall(tmp, data.fTemplateArguments,
Arrays.asList(argTypes),
Arrays.asList(data.getFunctionArgumentValueCategories()),
Arrays.asList(data.getFunctionArgumentValueCategories()),
data.argsContainImpliedObject, lookupPoint);
if (tmp.length == 0 || tmp[0] == null) {
return new ProblemBinding(lookupName, lookupPoint, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, fns);
@ -2522,7 +2522,7 @@ public class CPPSemantics {
}
}
if (result instanceof ICPPFunctionTemplate)
if (result instanceof ICPPFunctionTemplate)
return CPPTemplates.instantiateForAddressOfFunction((ICPPFunctionTemplate) result, null, args, point);
return result;
@ -2677,7 +2677,7 @@ public class CPPSemantics {
IType t= getNestedType(implicitParameterType, TDEF|REF|CVTYPE);
if (SemanticUtil.calculateInheritanceDepth(s, t, data.getLookupPoint()) >= 0)
return null;
return CONTAINS_DEPENDENT_TYPES;
}
}
@ -2714,7 +2714,7 @@ public class CPPSemantics {
} else {
if (CPPTemplates.isDependentType(paramType))
return CONTAINS_DEPENDENT_TYPES;
Context ctx= Context.ORDINARY;
if (j == 0 && sourceLen == 1 && fn instanceof ICPPConstructor) {
if (paramType instanceof ICPPReferenceType) {
@ -2805,7 +2805,7 @@ public class CPPSemantics {
prop= node.getPropertyInParent();
parent= node.getParent();
}
IType targetType= null;
if (prop == IASTDeclarator.INITIALIZER) {
// Target is an object or reference being initialized
@ -2989,7 +2989,7 @@ public class CPPSemantics {
ICPPEvaluation arg1, ICPPEvaluation arg2) {
if (op == null || arg1 == null || arg2 == null)
return null;
IType op1type = getNestedType(arg1.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE);
if (!isUserDefined(op1type) && !isUserDefined(
getNestedType(arg2.getTypeOrFunctionSet(point), TDEF | REF | CVTYPE)))
@ -3001,7 +3001,7 @@ public class CPPSemantics {
} else {
lookupNonMember= LookupMode.LIMITED_GLOBALS;
}
return findOverloadedOperator(point, new ICPPEvaluation[] {arg1, arg2},
return findOverloadedOperator(point, new ICPPEvaluation[] {arg1, arg2},
op1type, op, lookupNonMember);
}
@ -3041,7 +3041,7 @@ public class CPPSemantics {
if (type == null)
return null;
ICPPEvaluation[] args = {new EvalFixed(type, LVALUE, Value.UNKNOWN),
ICPPEvaluation[] args = {new EvalFixed(type, LVALUE, Value.UNKNOWN),
((ICPPASTExpression) expr.getOperand()).getEvaluation()};
return findOverloadedOperator(expr, args, type, op, LookupMode.GLOBALS_IF_NO_MEMBERS);
}
@ -3102,7 +3102,7 @@ public class CPPSemantics {
return null;
if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownType || type instanceof ISemanticProblem)
return null;
final ICPPClassType classType = (ICPPClassType) type;
if (initializer instanceof IASTEqualsInitializer) {
// Copy initialization
@ -3204,7 +3204,7 @@ public class CPPSemantics {
return idExpression;
}
/**
* For simplicity returns an operator of form RT (T, T) rather than RT (boolean, T, T)
@ -3231,11 +3231,11 @@ public class CPPSemantics {
static enum LookupMode {NO_GLOBALS, GLOBALS_IF_NO_MEMBERS, LIMITED_GLOBALS, ALL_GLOBALS}
static ICPPFunction findOverloadedOperator(IASTNode point, ICPPEvaluation[] args, IType methodLookupType,
static ICPPFunction findOverloadedOperator(IASTNode point, ICPPEvaluation[] args, IType methodLookupType,
OverloadableOperator operator, LookupMode mode) {
while (point instanceof IASTName)
while (point instanceof IASTName)
point= point.getParent();
ICPPClassType callToObjectOfClassType= null;
IType type2= null;
if (args.length >= 2) {
@ -3252,7 +3252,7 @@ public class CPPSemantics {
methodData = new LookupData(operator.toCharArray(), null, point);
methodData.setFunctionArguments(true, args);
methodData.qualified = true; // (13.3.1.2.3)
try {
IScope scope = classType.getCompositeScope();
if (scope == null)
@ -3407,7 +3407,7 @@ public class CPPSemantics {
} else if (methodData != null) {
binding = resolveAmbiguities(methodData);
}
if (binding instanceof ICPPFunction)
return (ICPPFunction) binding;
} catch (DOMException e) {

View file

@ -659,7 +659,7 @@ public class CPPTemplates {
IBinding owner = template.getOwner();
ICPPClassSpecialization within = getSpecializationContext(owner);
IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id);
return new CPPAliasTemplateInstance(id.toCharArray(), instantiatedType, aliasTemplate);
return new CPPAliasTemplateInstance(id.toCharArray(), aliasTemplate, instantiatedType);
}
// Class template.
@ -830,7 +830,7 @@ public class CPPTemplates {
} else if (decl instanceof ICPPAliasTemplate) {
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), type, aliasTemplate);
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), aliasTemplate, type);
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) {
// TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter.
spec = decl;

View file

@ -16,7 +16,6 @@ import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
import org.eclipse.cdt.core.dom.ast.IASTBinaryTypeIdExpression.Operator;
import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
@ -73,7 +72,7 @@ public class EvalBinaryTypeId extends CPPEvaluation {
case __is_base_of:
return CPPBasicType.BOOLEAN;
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
@Override

View file

@ -174,7 +174,7 @@ public class EvalConditional extends CPPEvaluation {
} else if (void2 && void3) {
fType= uqt2;
} else {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
}
return;
}
@ -204,10 +204,10 @@ public class EvalConditional extends CPPEvaluation {
if (cost2.converts() || cost3.converts()) {
if (cost2.converts()) {
if (cost3.converts() || cost2.isAmbiguousUDC()) {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
}
} else if (cost3.isAmbiguousUDC()) {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
}
return;
}
@ -222,7 +222,7 @@ public class EvalConditional extends CPPEvaluation {
fType= t3;
fValueCategory= vcat3;
} else {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
}
return;
}
@ -233,7 +233,7 @@ public class EvalConditional extends CPPEvaluation {
if (fOverload != null) {
fType= ExpressionTypes.typeFromFunctionCall(fOverload);
} else {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
}
return;
}
@ -248,7 +248,7 @@ public class EvalConditional extends CPPEvaluation {
if (fType == null) {
fType= Conversions.compositePointerType(t2, t3);
if (fType == null) {
fType= new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
fType= ProblemType.UNKNOWN_FOR_EXPRESSION;
}
}
}

View file

@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
@ -123,7 +122,7 @@ public class EvalFunctionCall extends CPPEvaluation {
final ICPPEvaluation arg0 = fArguments[0];
IType t= SemanticUtil.getNestedType(arg0.getTypeOrFunctionSet(point), TDEF|REF|CVTYPE);
if (t instanceof ICPPClassType) {
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
if (t instanceof IPointerType) {
@ -136,7 +135,7 @@ public class EvalFunctionCall extends CPPEvaluation {
}
return t;
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
@Override
@ -151,7 +150,6 @@ public class EvalFunctionCall extends CPPEvaluation {
if (overload != null)
return valueCategoryFromFunctionCall(overload);
IType t= fArguments[0].getTypeOrFunctionSet(point);
if (t instanceof IPointerType) {
t= SemanticUtil.getNestedType(((IPointerType) t).getType(), TDEF | REF | CVTYPE);

View file

@ -32,7 +32,6 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
@ -196,7 +195,7 @@ public class EvalMemberAccess extends CPPEvaluation {
if (CPPTemplates.isDependentType(type))
return returnUnnamed ? CPPUnknownMemberClass.createUnnamedInstance() : null;
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
@Override

View file

@ -108,7 +108,7 @@ public class EvalUnary extends CPPEvaluation {
if (fType != null)
return fType instanceof TypeOfDependentExpression;
switch(fOperator) {
switch (fOperator) {
case op_alignOf:
case op_not:
case op_sizeof:
@ -217,7 +217,7 @@ public class EvalUnary extends CPPEvaluation {
if (type instanceof ISemanticProblem) {
return type;
}
return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
return ProblemType.UNKNOWN_FOR_EXPRESSION;
case op_noexcept:
case op_not:
return CPPBasicType.BOOLEAN;