/** Returns the implied object type, or <code>null</code>. */ public IType getImpliedObjectType() { if (astName == null) return null; IASTName name = astName; IASTNode nameParent = name.getParent(); while (nameParent instanceof IASTName) { name = (IASTName) nameParent; nameParent = name.getParent(); } final ASTNodeProperty prop = name.getPropertyInParent(); if (prop == CPPSemantics.STRING_LOOKUP_PROPERTY) { return null; } if (prop == IASTFieldReference.FIELD_NAME) { ICPPASTFieldReference fieldRef = (ICPPASTFieldReference) nameParent; return fieldRef.getFieldOwnerType(); } if (prop == IASTIdExpression.ID_NAME) { IScope scope = CPPVisitor.getContainingScope(name); if (scope instanceof ICPPClassScope) { return ((ICPPClassScope) scope).getClassType(); } return CPPVisitor.getImpliedObjectType(scope); } return null; }
private IType computeType(IASTNode point) { if (isTypeDependent()) return new TypeOfDependentExpression(this); ICPPFunction overload = getOverload(point); if (overload != null) return ExpressionTypes.typeFromFunctionCall(overload); switch (fOperator) { case op_sizeof: case op_sizeofParameterPack: return CPPVisitor.get_SIZE_T(point); case op_typeid: return CPPVisitor.get_type_info(point); case op_throw: return CPPSemantics.VOID_TYPE; case op_amper: if (fAddressOfQualifiedNameBinding instanceof ICPPMember) { ICPPMember member = (ICPPMember) fAddressOfQualifiedNameBinding; if (!member.isStatic()) { try { return new CPPPointerToMemberType( member.getType(), member.getClassOwner(), false, false, false); } catch (DOMException e) { return e.getProblem(); } } } return new CPPPointerType(fArgument.getTypeOrFunctionSet(point)); case op_star: IType type = fArgument.getTypeOrFunctionSet(point); type = prvalueTypeWithResolvedTypedefs(type); if (type instanceof IPointerType) { return glvalueType(((IPointerType) type).getType()); } if (type instanceof ISemanticProblem) { return type; } return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION); case op_noexcept: case op_not: return CPPBasicType.BOOLEAN; case op_postFixDecr: case op_postFixIncr: return prvalueType(fArgument.getTypeOrFunctionSet(point)); case op_minus: case op_plus: case op_tilde: final IType t1 = prvalueType(fArgument.getTypeOrFunctionSet(point)); final IType t2 = SemanticUtil.getNestedType(t1, TDEF); final IType t3 = CPPArithmeticConversion.promoteCppType(t2); return (t3 == null || t3 == t2) ? t1 : t3; } return fArgument.getTypeOrFunctionSet(point); }
@Override protected int rwInDeclarator(IASTDeclarator parent, int indirection) { IType type = CPPVisitor.createType(parent); if (type instanceof ICPPUnknownType || type instanceof ICPPClassType && !TypeTraits.hasTrivialDefaultConstructor((ICPPClassType) type, parent)) { return WRITE; } return super.rwInDeclarator(parent, indirection); }
private static IBinding[] getContext(IASTName name) { IBinding[] accessibilityContext = IBinding.EMPTY_BINDING_ARRAY; for (IBinding binding = CPPVisitor.findEnclosingFunctionOrClass(name); binding != null; binding = binding.getOwner()) { if (binding instanceof ICPPMethod || // Definition of an undeclared method. binding instanceof IProblemBinding && ((IProblemBinding) binding).getID() == IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND) { continue; } if (binding instanceof ICPPFunction || binding instanceof ICPPClassType) { accessibilityContext = ArrayUtil.append(accessibilityContext, binding); } } return ArrayUtil.trim(accessibilityContext); }
public boolean checkClassContainingFriend() { if (astName == null || astName instanceof ICPPASTQualifiedName) return false; IASTNode p = astName.getParent(); ASTNodeProperty prop = null; while (p != null) { prop = p.getPropertyInParent(); if (prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT || prop == IASTDeclarator.DECLARATOR_NAME) return false; if (p instanceof IASTDeclarator && !(((IASTDeclarator) p).getName() instanceof ICPPASTQualifiedName)) return false; if (p instanceof IASTDeclaration) { if (prop == IASTCompositeTypeSpecifier.MEMBER_DECLARATION) { return CPPVisitor.isFriendDeclaration(p); } else { return false; } } p = p.getParent(); } return false; }