Commit 1c2d6111 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] hide internal variables used for labels with parameters

This fixes a bug that the variables used to implement labels with
parameters in CSA leak into the user-accessible scope.

Example:

macro Foo() labels Bar(Smi) {
  Bar0 = 5;
}

Bug: v8:7793
Change-Id: I33bf5a207c7e9e7337fa79fc7591c05901b2fa5b
Reviewed-on: https://chromium-review.googlesource.com/1246183Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56257}
parent 0ba3de60
......@@ -638,7 +638,8 @@ void DeclarationVisitor::DeclareSignature(const Signature& signature) {
}
std::string var_name = label.name + std::to_string(i++);
new_label->AddVariable(DeclareVariable(var_name, var_type, false));
new_label->AddVariable(
declarations()->CreateVariable(var_name, var_type, false));
}
}
}
......
......@@ -304,6 +304,15 @@ RuntimeFunction* Declarations::DeclareRuntimeFunction(
return result;
}
Variable* Declarations::CreateVariable(const std::string& var, const Type* type,
bool is_const) {
std::string name(var + "_" +
std::to_string(GetNextUniqueDeclarationNumber()));
std::replace(name.begin(), name.end(), '.', '_');
return RegisterDeclarable(
std::unique_ptr<Variable>(new Variable(var, name, type, is_const)));
}
Variable* Declarations::DeclareVariable(const std::string& var,
const Type* type, bool is_const) {
std::string name(var + "_" +
......
......@@ -91,6 +91,8 @@ class Declarations {
RuntimeFunction* DeclareRuntimeFunction(const std::string& name,
const Signature& signature);
Variable* CreateVariable(const std::string& var, const Type* type,
bool is_const);
Variable* DeclareVariable(const std::string& var, const Type* type,
bool is_const);
......
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