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

Whitespace.

This commit is contained in:
Sergey Prigogin 2012-10-23 12:28:01 +02:00
parent 90a6c37f6b
commit d514c8e8d4

View file

@ -78,14 +78,14 @@ public class SemanticUtil {
// Resolve typedefs. // Resolve typedefs.
public static final int TDEF = 0x01; public static final int TDEF = 0x01;
// Resolve typedefs, but only if necessary for a nested type transformation. // Resolve typedefs, but only if necessary for a nested type transformation.
public static final int COND_TDEF = 0x02; public static final int COND_TDEF = 0x02;
public static final int REF = 0x04; public static final int REF = 0x04;
public static final int CVTYPE = 0x08; public static final int CVTYPE = 0x08;
public static final int ALLCVQ = 0x10; public static final int ALLCVQ = 0x10;
public static final int PTR = 0x20; public static final int PTR = 0x20;
public static final int MPTR = 0x40; public static final int MPTR = 0x40;
public static final int ARRAY = 0x80; public static final int ARRAY = 0x80;
static { static {
final int OPERATOR_SPC= OPERATOR_CHARS.length + 1; final int OPERATOR_SPC= OPERATOR_CHARS.length + 1;
for (OverloadableOperator op : OverloadableOperator.values()) { for (OverloadableOperator op : OverloadableOperator.values()) {
@ -93,7 +93,7 @@ public class SemanticUtil {
cas.put(CharArrayUtils.subarray(name, OPERATOR_SPC, name.length)); cas.put(CharArrayUtils.subarray(name, OPERATOR_SPC, name.length));
} }
} }
/** /**
* Returns an array of ICPPMethod objects representing all conversion operators * Returns an array of ICPPMethod objects representing all conversion operators
* declared by the specified class. This does not include inherited methods. Conversion * declared by the specified class. This does not include inherited methods. Conversion
@ -116,7 +116,7 @@ public class SemanticUtil {
} }
return methods; return methods;
} }
/** /**
* Returns an array of ICPPMethod objects representing all conversion operators * Returns an array of ICPPMethod objects representing all conversion operators
* declared by the specified class and its ancestors. This includes inherited * declared by the specified class and its ancestors. This includes inherited
@ -132,7 +132,7 @@ public class SemanticUtil {
} }
return methods; return methods;
} }
/** /**
* @param root the class to start at * @param root the class to start at
* @return the root and all its ancestor classes * @return the root and all its ancestor classes
@ -147,7 +147,7 @@ public class SemanticUtil {
ObjectSet<ICPPClassType> next= new ObjectSet<ICPPClassType>(2); ObjectSet<ICPPClassType> next= new ObjectSet<ICPPClassType>(2);
for (int i = 0; i < current.size(); i++) { for (int i = 0; i < current.size(); i++) {
ICPPClassType clazz= current.keyAt(i); ICPPClassType clazz= current.keyAt(i);
done.put(clazz); done.put(clazz);
for (ICPPBase base : ClassTypeHelper.getBases(clazz, point)) { for (ICPPBase base : ClassTypeHelper.getBases(clazz, point)) {
@ -181,21 +181,21 @@ public class SemanticUtil {
} }
return false; return false;
} }
public static CVQualifier getCVQualifier(IType t) { public static CVQualifier getCVQualifier(IType t) {
if (t instanceof IQualifierType) { if (t instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) t; IQualifierType qt= (IQualifierType) t;
return qt.isConst() return qt.isConst()
? qt.isVolatile() ? CONST_VOLATILE : CONST ? qt.isVolatile() ? CONST_VOLATILE : CONST
: qt.isVolatile() ? VOLATILE : NONE; : qt.isVolatile() ? VOLATILE : NONE;
} }
if (t instanceof IPointerType) { if (t instanceof IPointerType) {
IPointerType pt= (IPointerType) t; IPointerType pt= (IPointerType) t;
return pt.isConst() return pt.isConst()
? pt.isVolatile() ? pt.isVolatile()
? pt.isRestrict() ? CONST_VOLATILE_RESTRICT : CONST_VOLATILE ? pt.isRestrict() ? CONST_VOLATILE_RESTRICT : CONST_VOLATILE
: pt.isRestrict() ? CONST_RESTRICT : CONST : pt.isRestrict() ? CONST_RESTRICT : CONST
: pt.isVolatile() : pt.isVolatile()
? pt.isRestrict() ? VOLATILE_RESTRICT : VOLATILE ? pt.isRestrict() ? VOLATILE_RESTRICT : VOLATILE
: pt.isRestrict() ? RESTRICT : NONE; : pt.isRestrict() ? RESTRICT : NONE;
} }
@ -204,7 +204,7 @@ public class SemanticUtil {
} }
return NONE; return NONE;
} }
/** /**
* Descends into type containers, stopping at pointer-to-member types if * Descends into type containers, stopping at pointer-to-member types if
* specified. * specified.
@ -216,7 +216,7 @@ public class SemanticUtil {
final int options = TDEF | ALLCVQ | PTR | ARRAY | REF; final int options = TDEF | ALLCVQ | PTR | ARRAY | REF;
return getNestedType(type, stopAtPointerToMember ? options : (options | MPTR)); return getNestedType(type, stopAtPointerToMember ? options : (options | MPTR));
} }
/** /**
* Descends into type containers, stopping at array, pointer or * Descends into type containers, stopping at array, pointer or
* pointer-to-member types. * pointer-to-member types.
@ -273,10 +273,10 @@ public class SemanticUtil {
beforeTypedefs = null; beforeTypedefs = null;
} else if (tdef || cond_tdef) { } else if (tdef || cond_tdef) {
t= getNestedType(qttgt, options); t= getNestedType(qttgt, options);
if (t == qttgt) if (t == qttgt)
return qt; return qt;
return addQualifiers(t, qt.isConst(), qt.isVolatile(), false); return addQualifiers(t, qt.isConst(), qt.isVolatile(), false);
} }
} else if (type instanceof IArrayType) { } else if (type instanceof IArrayType) {
final IArrayType atype= (IArrayType) type; final IArrayType atype= (IArrayType) type;
if ((options & ARRAY) != 0) { if ((options & ARRAY) != 0) {
@ -298,7 +298,7 @@ public class SemanticUtil {
// A typedef within the reference type can influence whether the reference is lvalue or rvalue // A typedef within the reference type can influence whether the reference is lvalue or rvalue
IType nested= rt.getType(); IType nested= rt.getType();
IType newNested = getNestedType(nested, TDEF); IType newNested = getNestedType(nested, TDEF);
if (nested == newNested) if (nested == newNested)
return type; return type;
return replaceNestedType((ITypeContainer) rt, newNested); return replaceNestedType((ITypeContainer) rt, newNested);
} }
@ -310,7 +310,7 @@ public class SemanticUtil {
} }
return type; return type;
} }
type= t; type= t;
} }
} }
@ -331,7 +331,7 @@ public class SemanticUtil {
return type; return type;
} }
return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs()); return new CPPFunctionType(ret, params, ft.isConst(), ft.isVolatile(), ft.takesVarArgs());
} }
if (type instanceof ITypedef) { if (type instanceof ITypedef) {
IType t= ((ITypedef) type).getType(); IType t= ((ITypedef) type).getType();
@ -342,31 +342,31 @@ public class SemanticUtil {
if (type instanceof ITypeContainer) { if (type instanceof ITypeContainer) {
final ITypeContainer tc = (ITypeContainer) type; final ITypeContainer tc = (ITypeContainer) type;
final IType nestedType= tc.getType(); final IType nestedType= tc.getType();
if (nestedType == null) if (nestedType == null)
return type; return type;
IType newType= getSimplifiedType(nestedType); IType newType= getSimplifiedType(nestedType);
if (newType != nestedType) { if (newType != nestedType) {
return replaceNestedType(tc, newType); return replaceNestedType(tc, newType);
} }
return type; return type;
} }
return type; return type;
} }
static boolean isSimplified(IType type) { static boolean isSimplified(IType type) {
if (type instanceof ICPPFunctionType) { if (type instanceof ICPPFunctionType) {
final ICPPFunctionType ft = (ICPPFunctionType) type; final ICPPFunctionType ft = (ICPPFunctionType) type;
if (!isSimplified(ft.getReturnType())) if (!isSimplified(ft.getReturnType()))
return false; return false;
IType[] ps = ft.getParameterTypes(); IType[] ps = ft.getParameterTypes();
for (IType p : ps) { for (IType p : ps) {
if (!isSimplified(p)) if (!isSimplified(p))
return false; return false;
} }
return true; return true;
} }
if (type instanceof ITypedef) { if (type instanceof ITypedef) {
return false; return false;
} }
@ -379,7 +379,7 @@ public class SemanticUtil {
public static IType replaceNestedType(ITypeContainer type, IType newNestedType) { public static IType replaceNestedType(ITypeContainer type, IType newNestedType) {
if (newNestedType == null) if (newNestedType == null)
return type; return type;
// Bug 249085 make sure not to add unnecessary qualifications // Bug 249085 make sure not to add unnecessary qualifications
if (type instanceof IQualifierType) { if (type instanceof IQualifierType) {
IQualifierType qt= (IQualifierType) type; IQualifierType qt= (IQualifierType) type;
@ -393,9 +393,9 @@ public class SemanticUtil {
/** /**
* Replaces the given type or its nested type with a typedef if that type is the same as * Replaces the given type or its nested type with a typedef if that type is the same as
* the type the typedef resolves to. * the type the typedef resolves to.
* *
* @param type the type subject to substitution * @param type the type subject to substitution
* @param typedefType the type possibly containing the typedef as its nested type. * @param typedefType the type possibly containing the typedef as its nested type.
* @return the given type with the nested type replaced by the typedef, or {@code null} if * @return the given type with the nested type replaced by the typedef, or {@code null} if
* the typedefType doesn't contain a typedef or the nested type doesn't match the typedef. * the typedefType doesn't contain a typedef or the nested type doesn't match the typedef.
@ -439,7 +439,7 @@ public class SemanticUtil {
public static IType mapToAST(IType type, IASTNode node) { public static IType mapToAST(IType type, IASTNode node) {
if (node == null) if (node == null)
return type; return type;
if (type instanceof IFunctionType) { if (type instanceof IFunctionType) {
final ICPPFunctionType ft = (ICPPFunctionType) type; final ICPPFunctionType ft = (ICPPFunctionType) type;
final IType r = ft.getReturnType(); final IType r = ft.getReturnType();
@ -452,13 +452,13 @@ public class SemanticUtil {
if (type instanceof ITypeContainer) { if (type instanceof ITypeContainer) {
final ITypeContainer tc = (ITypeContainer) type; final ITypeContainer tc = (ITypeContainer) type;
final IType nestedType= tc.getType(); final IType nestedType= tc.getType();
if (nestedType == null) if (nestedType == null)
return type; return type;
IType newType= mapToAST(nestedType, node); IType newType= mapToAST(nestedType, node);
if (newType != nestedType) { if (newType != nestedType) {
return replaceNestedType(tc, newType); return replaceNestedType(tc, newType);
} }
return type; return type;
} else if (type instanceof ICPPClassType && type instanceof IIndexBinding) { } else if (type instanceof ICPPClassType && type instanceof IIndexBinding) {
IASTTranslationUnit tu = node.getTranslationUnit(); IASTTranslationUnit tu = node.getTranslationUnit();
@ -535,17 +535,17 @@ public class SemanticUtil {
return baseType; return baseType;
} else if (baseType instanceof ICPPPointerToMemberType) { } else if (baseType instanceof ICPPPointerToMemberType) {
ICPPPointerToMemberType pt= (ICPPPointerToMemberType) baseType; ICPPPointerToMemberType pt= (ICPPPointerToMemberType) baseType;
if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile()) if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())
|| (restrict && !pt.isRestrict())) { || (restrict && !pt.isRestrict())) {
return new CPPPointerToMemberType(pt.getType(), pt.getMemberOfClass(), return new CPPPointerToMemberType(pt.getType(), pt.getMemberOfClass(),
cnst || pt.isConst(), vol || pt.isVolatile(), restrict || pt.isRestrict()); cnst || pt.isConst(), vol || pt.isVolatile(), restrict || pt.isRestrict());
} }
return baseType; return baseType;
} else if (baseType instanceof IPointerType) { } else if (baseType instanceof IPointerType) {
IPointerType pt= (IPointerType) baseType; IPointerType pt= (IPointerType) baseType;
if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile()) if ((cnst && !pt.isConst()) || (vol && !pt.isVolatile())
|| (restrict && !pt.isRestrict())) { || (restrict && !pt.isRestrict())) {
return new CPPPointerType(pt.getType(), return new CPPPointerType(pt.getType(),
cnst || pt.isConst(), vol || pt.isVolatile(), restrict || pt.isRestrict()); cnst || pt.isConst(), vol || pt.isVolatile(), restrict || pt.isRestrict());
} }
return baseType; return baseType;
@ -562,7 +562,7 @@ public class SemanticUtil {
} else if (baseType == null) { } else if (baseType == null) {
return null; return null;
} }
return new CPPQualifierType(baseType, cnst, vol); return new CPPQualifierType(baseType, cnst, vol);
} }
return baseType; return baseType;
@ -590,7 +590,7 @@ public class SemanticUtil {
} }
} else if (owner1 instanceof ICPPNamespace) { } else if (owner1 instanceof ICPPNamespace) {
if (owner2 instanceof ICPPNamespace) { if (owner2 instanceof ICPPNamespace) {
if (!CharArrayUtils.equals(owner1.getNameCharArray(), owner2.getNameCharArray())) if (!CharArrayUtils.equals(owner1.getNameCharArray(), owner2.getNameCharArray()))
return false; return false;
return isSameOwner(owner1.getOwner(), owner2.getOwner()); return isSameOwner(owner1.getOwner(), owner2.getOwner());
} }
@ -611,7 +611,7 @@ public class SemanticUtil {
public static boolean isEmptyParameterList(IType[] parameters) { public static boolean isEmptyParameterList(IType[] parameters) {
if (parameters.length == 0) { if (parameters.length == 0) {
return true; return true;
} }
if (parameters.length == 1 && isVoidType(parameters[0])) { if (parameters.length == 1 && isVoidType(parameters[0])) {
return true; return true;
} }
@ -629,28 +629,28 @@ public class SemanticUtil {
public static final int calculateInheritanceDepth(IType type, IType baseClass, IASTNode point) { public static final int calculateInheritanceDepth(IType type, IType baseClass, IASTNode point) {
return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>(), type, baseClass, point); return calculateInheritanceDepth(CPPSemantics.MAX_INHERITANCE_DEPTH, new HashSet<Object>(), type, baseClass, point);
} }
private static final int calculateInheritanceDepth(int maxdepth, Set<Object> hashSet, IType type, IType baseClass, IASTNode point) { private static final int calculateInheritanceDepth(int maxdepth, Set<Object> hashSet, IType type, IType baseClass, IASTNode point) {
if (type == baseClass || type.isSameType(baseClass)) { if (type == baseClass || type.isSameType(baseClass)) {
return 0; return 0;
} }
if (maxdepth > 0 && type instanceof ICPPClassType && baseClass instanceof ICPPClassType) { if (maxdepth > 0 && type instanceof ICPPClassType && baseClass instanceof ICPPClassType) {
ICPPClassType clazz = (ICPPClassType) type; ICPPClassType clazz = (ICPPClassType) type;
if (clazz instanceof ICPPDeferredClassInstance) { if (clazz instanceof ICPPDeferredClassInstance) {
clazz= (ICPPClassType) ((ICPPDeferredClassInstance) clazz).getSpecializedBinding(); clazz= (ICPPClassType) ((ICPPDeferredClassInstance) clazz).getSpecializedBinding();
} }
for (ICPPBase cppBase : ClassTypeHelper.getBases(clazz, point)) { for (ICPPBase cppBase : ClassTypeHelper.getBases(clazz, point)) {
IBinding base= cppBase.getBaseClass(); IBinding base= cppBase.getBaseClass();
if (base instanceof IType && hashSet.add(base)) { if (base instanceof IType && hashSet.add(base)) {
IType tbase= (IType) base; IType tbase= (IType) base;
if (tbase.isSameType(baseClass) || if (tbase.isSameType(baseClass) ||
(baseClass instanceof ICPPSpecialization && // allow some flexibility with templates (baseClass instanceof ICPPSpecialization && // allow some flexibility with templates
((IType)((ICPPSpecialization) baseClass).getSpecializedBinding()).isSameType(tbase))) { ((IType)((ICPPSpecialization) baseClass).getSpecializedBinding()).isSameType(tbase))) {
return 1; return 1;
} }
if (tbase instanceof ICPPClassType) { if (tbase instanceof ICPPClassType) {
int n= calculateInheritanceDepth(maxdepth - 1, hashSet, tbase, baseClass, point); int n= calculateInheritanceDepth(maxdepth - 1, hashSet, tbase, baseClass, point);
if (n > 0) if (n > 0)
@ -659,7 +659,7 @@ public class SemanticUtil {
} }
} }
} }
return -1; return -1;
} }
@ -668,14 +668,14 @@ public class SemanticUtil {
final ICPPFunctionType ft = (ICPPFunctionType) type; final ICPPFunctionType ft = (ICPPFunctionType) type;
if (containsUniqueTypeForParameterPack(ft.getReturnType())) if (containsUniqueTypeForParameterPack(ft.getReturnType()))
return true; return true;
for (IType pt : ft.getParameterTypes()) { for (IType pt : ft.getParameterTypes()) {
if (containsUniqueTypeForParameterPack(pt)) if (containsUniqueTypeForParameterPack(pt))
return true; return true;
} }
return false; return false;
} }
if (type instanceof ICPPPointerToMemberType) { if (type instanceof ICPPPointerToMemberType) {
if (containsUniqueTypeForParameterPack(((ICPPPointerToMemberType) type).getMemberOfClass())) if (containsUniqueTypeForParameterPack(((ICPPPointerToMemberType) type).getMemberOfClass()))
return true; return true;
@ -688,7 +688,7 @@ public class SemanticUtil {
return true; return true;
} }
} }
if (type instanceof ICPPTemplateInstance) { if (type instanceof ICPPTemplateInstance) {
ICPPTemplateArgument[] args = ((ICPPTemplateInstance) type).getTemplateArguments(); ICPPTemplateArgument[] args = ((ICPPTemplateInstance) type).getTemplateArguments();
for (ICPPTemplateArgument arg : args) { for (ICPPTemplateArgument arg : args) {
@ -702,7 +702,7 @@ public class SemanticUtil {
final IType nestedType= tc.getType(); final IType nestedType= tc.getType();
return containsUniqueTypeForParameterPack(nestedType); return containsUniqueTypeForParameterPack(nestedType);
} }
if (type instanceof UniqueType) { if (type instanceof UniqueType) {
return ((UniqueType) type).isForParameterPack(); return ((UniqueType) type).isForParameterPack();
} }