| 8741 | } |
| 8742 | |
| 8743 | ValueType::MatchResult ValueType::matchParameter(const ValueType *call, const ValueType *func) |
| 8744 | { |
| 8745 | if (!call || !func) |
| 8746 | return ValueType::MatchResult::UNKNOWN; |
| 8747 | if (call->pointer != func->pointer) { |
| 8748 | if (call->pointer > 1 && func->pointer == 1 && func->type == ValueType::Type::VOID) |
| 8749 | return ValueType::MatchResult::FALLBACK1; |
| 8750 | if (call->pointer == 1 && func->pointer == 0 && func->isIntegral() && func->sign != ValueType::Sign::SIGNED) |
| 8751 | return ValueType::MatchResult::FALLBACK1; |
| 8752 | if (call->pointer == 1 && call->type == ValueType::Type::CHAR && func->pointer == 0 && func->container && func->container->stdStringLike) |
| 8753 | return ValueType::MatchResult::FALLBACK2; |
| 8754 | return ValueType::MatchResult::NOMATCH; // TODO |
| 8755 | } |
| 8756 | if (call->pointer > 0) { |
| 8757 | const unsigned int mask = (1U << call->pointer) - 1; |
| 8758 | if (((call->constness | func->constness) & mask) != (func->constness & mask)) |
| 8759 | return ValueType::MatchResult::NOMATCH; |
| 8760 | if ((call->volatileness | func->volatileness) != func->volatileness) |
| 8761 | return ValueType::MatchResult::NOMATCH; |
| 8762 | if (call->constness == 0 && func->constness != 0 && func->reference != Reference::None) |
| 8763 | return ValueType::MatchResult::NOMATCH; |
| 8764 | if (call->volatileness == 0 && func->volatileness != 0 && func->reference != Reference::None) |
| 8765 | return ValueType::MatchResult::NOMATCH; |
| 8766 | } |
| 8767 | if (call->type != func->type || (call->isEnum() && !func->isEnum())) { |
| 8768 | if (call->type == ValueType::Type::VOID || func->type == ValueType::Type::VOID) |
| 8769 | return ValueType::MatchResult::FALLBACK1; |
| 8770 | if (call->pointer > 0) |
| 8771 | return func->type == ValueType::UNKNOWN_TYPE ? ValueType::MatchResult::UNKNOWN : ValueType::MatchResult::NOMATCH; |
| 8772 | if (call->isIntegral() && func->isIntegral()) |
| 8773 | return call->type < func->type ? |
| 8774 | ValueType::MatchResult::FALLBACK1 : |
| 8775 | ValueType::MatchResult::FALLBACK2; |
| 8776 | if (call->isFloat() && func->isFloat()) |
| 8777 | return ValueType::MatchResult::FALLBACK1; |
| 8778 | if (call->isIntegral() && func->isFloat()) |
| 8779 | return ValueType::MatchResult::FALLBACK2; |
| 8780 | if (call->isFloat() && func->isIntegral()) |
| 8781 | return ValueType::MatchResult::FALLBACK2; |
| 8782 | return ValueType::MatchResult::UNKNOWN; // TODO |
| 8783 | } |
| 8784 | |
| 8785 | if (call->typeScope != nullptr || func->typeScope != nullptr) { |
| 8786 | if (call->typeScope != func->typeScope && |
| 8787 | !(call->typeScope && func->typeScope && call->typeScope->definedType && call->typeScope->definedType->isDerivedFrom(func->typeScope->className))) |
| 8788 | return ValueType::MatchResult::NOMATCH; |
| 8789 | } |
| 8790 | |
| 8791 | if (call->container != nullptr || func->container != nullptr) { |
| 8792 | if (call->container != func->container) |
| 8793 | return ValueType::MatchResult::NOMATCH; |
| 8794 | } |
| 8795 | |
| 8796 | if (func->typeScope != nullptr && func->container != nullptr) { |
| 8797 | if (func->type < ValueType::Type::VOID || func->type == ValueType::Type::UNKNOWN_INT) |
| 8798 | return ValueType::MatchResult::UNKNOWN; |
| 8799 | } |
| 8800 |
nothing calls this directly
no test coverage detected