Commit 8b8e9960 authored by Nico Hartmann's avatar Nico Hartmann Committed by V8 LUCI CQ

[torque] Fix positions for type alias and structs

Bug: v8:12261
Change-Id: I4872ba82676bf64fa51d5a599323382c65cc465a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3386594
Auto-Submit: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78606}
parent 7d4e3d35
......@@ -11,6 +11,7 @@
#include "src/base/macros.h"
#include "src/torque/declarations.h"
#include "src/torque/global-context.h"
#include "src/torque/kythe-data.h"
#include "src/torque/types.h"
#include "src/torque/utils.h"
......@@ -35,10 +36,22 @@ class PredeclarationVisitor {
for (Declaration* child : decl->declarations) Predeclare(child);
}
static void Predeclare(TypeDeclaration* decl) {
Declarations::PredeclareTypeAlias(decl->name, decl, false);
TypeAlias* alias =
Declarations::PredeclareTypeAlias(decl->name, decl, false);
alias->SetPosition(decl->pos);
alias->SetIdentifierPosition(decl->name->pos);
if (GlobalContext::collect_kythe_data()) {
KytheData::AddTypeDefinition(alias);
}
}
static void Predeclare(StructDeclaration* decl) {
Declarations::PredeclareTypeAlias(decl->name, decl, false);
TypeAlias* alias =
Declarations::PredeclareTypeAlias(decl->name, decl, false);
alias->SetPosition(decl->pos);
alias->SetIdentifierPosition(decl->name->pos);
if (GlobalContext::collect_kythe_data()) {
KytheData::AddTypeDefinition(alias);
}
}
static void Predeclare(GenericTypeDeclaration* generic_decl) {
Declarations::DeclareGenericType(generic_decl->declaration->name->value,
......
......@@ -168,9 +168,9 @@ TypeAlias* Declarations::DeclareType(const Identifier* name, const Type* type) {
new TypeAlias(type, true, name->pos)));
}
const TypeAlias* Declarations::PredeclareTypeAlias(const Identifier* name,
TypeDeclaration* type,
bool redeclaration) {
TypeAlias* Declarations::PredeclareTypeAlias(const Identifier* name,
TypeDeclaration* type,
bool redeclaration) {
CheckAlreadyDeclared<TypeAlias>(name->value, "type");
std::unique_ptr<TypeAlias> alias_ptr(
new TypeAlias(type, redeclaration, name->pos));
......
......@@ -93,9 +93,9 @@ class Declarations {
static Namespace* DeclareNamespace(const std::string& name);
static TypeAlias* DeclareType(const Identifier* name, const Type* type);
static const TypeAlias* PredeclareTypeAlias(const Identifier* name,
TypeDeclaration* type,
bool redeclaration);
static TypeAlias* PredeclareTypeAlias(const Identifier* name,
TypeDeclaration* type,
bool redeclaration);
static TorqueMacro* CreateTorqueMacro(std::string external_name,
std::string readable_name,
bool exported_to_csa,
......
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