Commit 1d682e6c authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[torque] Add parameter check for function pointer calls.

This CL stops torque from crashing when a function pointer call site
uses wrong parameters.

R=tebbi@chromium.org

Change-Id: If097d0882ca5370e525097c68014f7ec051b3fe8
Reviewed-on: https://chromium-review.googlesource.com/1068181Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Simon Zünd <szuend@google.com>
Cr-Commit-Position: refs/heads/master@{#53308}
parent 344463d6
...@@ -1288,6 +1288,24 @@ VisitResult ImplementationVisitor::GeneratePointerCall( ...@@ -1288,6 +1288,24 @@ VisitResult ImplementationVisitor::GeneratePointerCall(
const FunctionPointerType* type = const FunctionPointerType* type =
FunctionPointerType::cast(callee_result.type()); FunctionPointerType::cast(callee_result.type());
if (type->parameter_types().size() != parameter_types.size()) {
std::stringstream stream;
stream << "parameter count mismatch calling function pointer with Type: "
<< type << " - expected "
<< std::to_string(type->parameter_types().size()) << ", found "
<< std::to_string(parameter_types.size());
ReportError(stream.str());
}
ParameterTypes types{type->parameter_types(), false};
if (!GetTypeOracle().IsCompatibleSignature(types, parameter_types)) {
std::stringstream stream;
stream << "parameters do not match function pointer signature. Expected: ("
<< type->parameter_types() << ") but got: (" << parameter_types
<< ")";
ReportError(stream.str());
}
std::vector<std::string> variables; std::vector<std::string> variables;
for (size_t current = 0; current < arguments.parameters.size(); ++current) { for (size_t current = 0; current < arguments.parameters.size(); ++current) {
const Type* to_type = type->parameter_types()[current]; const Type* to_type = type->parameter_types()[current];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment