Skip to content

Commit f0f7ca7

Browse files
committed
chore: Simplify parsing of nested name specifiers
Signed-off-by: Roberto Raggi <[email protected]>
1 parent 6e31a0e commit f0f7ca7

File tree

13 files changed

+16
-61
lines changed

13 files changed

+16
-61
lines changed

packages/cxx-frontend/src/AST.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11081,22 +11081,12 @@ export class DecltypeNestedNameSpecifierAST extends NestedNameSpecifierAST {
1108111081
return visitor.visitDecltypeNestedNameSpecifier(this, context);
1108211082
}
1108311083

11084-
/**
11085-
* Returns the nestedNameSpecifier of this node
11086-
*/
11087-
getNestedNameSpecifier(): NestedNameSpecifierAST | undefined {
11088-
return AST.from<NestedNameSpecifierAST>(
11089-
cxx.getASTSlot(this.getHandle(), 0),
11090-
this.parser,
11091-
);
11092-
}
11093-
1109411084
/**
1109511085
* Returns the decltypeSpecifier of this node
1109611086
*/
1109711087
getDecltypeSpecifier(): DecltypeSpecifierAST | undefined {
1109811088
return AST.from<DecltypeSpecifierAST>(
11099-
cxx.getASTSlot(this.getHandle(), 1),
11089+
cxx.getASTSlot(this.getHandle(), 0),
1110011090
this.parser,
1110111091
);
1110211092
}
@@ -11105,7 +11095,7 @@ export class DecltypeNestedNameSpecifierAST extends NestedNameSpecifierAST {
1110511095
* Returns the location of the scope token in this node
1110611096
*/
1110711097
getScopeToken(): Token | undefined {
11108-
return Token.from(cxx.getASTSlot(this.getHandle(), 2), this.parser);
11098+
return Token.from(cxx.getASTSlot(this.getHandle(), 1), this.parser);
1110911099
}
1111011100
}
1111111101

packages/cxx-frontend/src/RecursiveASTVisitor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,6 @@ export class RecursiveASTVisitor<Context> extends ASTVisitor<Context, void> {
25272527
node: ast.DecltypeNestedNameSpecifierAST,
25282528
context: Context,
25292529
): void {
2530-
this.accept(node.getNestedNameSpecifier(), context);
25312530
this.accept(node.getDecltypeSpecifier(), context);
25322531
}
25332532

src/frontend/cxx/ast_printer.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,6 @@ void ASTPrinter::visit(SimpleNestedNameSpecifierAST* ast) {
21632163

21642164
void ASTPrinter::visit(DecltypeNestedNameSpecifierAST* ast) {
21652165
out_ << std::format("{}\n", "decltype-nested-name-specifier");
2166-
accept(ast->nestedNameSpecifier, "nested-name-specifier");
21672166
accept(ast->decltypeSpecifier, "decltype-specifier");
21682167
}
21692168

src/mlir/cxx/mlir/codegen.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,6 @@ auto Codegen::NestedNameSpecifierVisitor::operator()(
26322632

26332633
auto Codegen::NestedNameSpecifierVisitor::operator()(
26342634
DecltypeNestedNameSpecifierAST* ast) -> NestedNameSpecifierResult {
2635-
auto nestedNameSpecifierResult = gen(ast->nestedNameSpecifier);
26362635
auto decltypeSpecifierResult = gen(ast->decltypeSpecifier);
26372636

26382637
return {};

src/parser/cxx/ast.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,7 +2931,6 @@ auto SimpleNestedNameSpecifierAST::lastSourceLocation() -> SourceLocation {
29312931
}
29322932

29332933
auto DecltypeNestedNameSpecifierAST::firstSourceLocation() -> SourceLocation {
2934-
if (auto loc = cxx::firstSourceLocation(nestedNameSpecifier)) return loc;
29352934
if (auto loc = cxx::firstSourceLocation(decltypeSpecifier)) return loc;
29362935
if (auto loc = cxx::firstSourceLocation(scopeLoc)) return loc;
29372936
return {};
@@ -2940,7 +2939,6 @@ auto DecltypeNestedNameSpecifierAST::firstSourceLocation() -> SourceLocation {
29402939
auto DecltypeNestedNameSpecifierAST::lastSourceLocation() -> SourceLocation {
29412940
if (auto loc = cxx::lastSourceLocation(scopeLoc)) return loc;
29422941
if (auto loc = cxx::lastSourceLocation(decltypeSpecifier)) return loc;
2943-
if (auto loc = cxx::lastSourceLocation(nestedNameSpecifier)) return loc;
29442942
return {};
29452943
}
29462944

src/parser/cxx/ast.fbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,6 @@ table SimpleNestedNameSpecifier /* NestedNameSpecifierAST */ {
13301330
}
13311331

13321332
table DecltypeNestedNameSpecifier /* NestedNameSpecifierAST */ {
1333-
nested_name_specifier: NestedNameSpecifier;
13341333
decltype_specifier: DecltypeSpecifier;
13351334
scope_loc: uint32;
13361335
}

src/parser/cxx/ast.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3558,7 +3558,6 @@ class DecltypeNestedNameSpecifierAST final : public NestedNameSpecifierAST {
35583558

35593559
DecltypeNestedNameSpecifierAST() : NestedNameSpecifierAST(Kind) {}
35603560

3561-
NestedNameSpecifierAST* nestedNameSpecifier = nullptr;
35623561
DecltypeSpecifierAST* decltypeSpecifier = nullptr;
35633562
SourceLocation scopeLoc;
35643563

src/parser/cxx/ast_interpreter.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,6 @@ auto ASTInterpreter::NestedNameSpecifierVisitor::operator()(
17951795

17961796
auto ASTInterpreter::NestedNameSpecifierVisitor::operator()(
17971797
DecltypeNestedNameSpecifierAST* ast) -> NestedNameSpecifierResult {
1798-
auto nestedNameSpecifierResult = accept(ast->nestedNameSpecifier);
17991798
auto decltypeSpecifierResult = accept(ast->decltypeSpecifier);
18001799

18011800
return {};

src/parser/cxx/ast_rewriter.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3319,7 +3319,6 @@ auto ASTRewriter::NestedNameSpecifierVisitor::operator()(
33193319
auto copy = new (arena()) DecltypeNestedNameSpecifierAST{};
33203320

33213321
copy->symbol = ast->symbol;
3322-
copy->nestedNameSpecifier = rewrite(ast->nestedNameSpecifier);
33233322
copy->decltypeSpecifier =
33243323
ast_cast<DecltypeSpecifierAST>(rewrite(ast->decltypeSpecifier));
33253324
copy->scopeLoc = ast->scopeLoc;

src/parser/cxx/ast_slot.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5408,24 +5408,19 @@ void ASTSlot::visit(SimpleNestedNameSpecifierAST* ast) {
54085408

54095409
void ASTSlot::visit(DecltypeNestedNameSpecifierAST* ast) {
54105410
switch (slot_) {
5411-
case 0: // nestedNameSpecifier
5412-
value_ = reinterpret_cast<std::intptr_t>(ast->nestedNameSpecifier);
5413-
slotKind_ = ASTSlotKind::kNode;
5414-
slotNameIndex_ = SlotNameIndex{140};
5415-
break;
5416-
case 1: // decltypeSpecifier
5411+
case 0: // decltypeSpecifier
54175412
value_ = reinterpret_cast<std::intptr_t>(ast->decltypeSpecifier);
54185413
slotKind_ = ASTSlotKind::kNode;
54195414
slotNameIndex_ = SlotNameIndex{58};
54205415
break;
5421-
case 2: // scopeLoc
5416+
case 1: // scopeLoc
54225417
value_ = ast->scopeLoc.index();
54235418
slotKind_ = ASTSlotKind::kToken;
54245419
slotNameIndex_ = SlotNameIndex{177};
54255420
break;
54265421
} // switch
54275422

5428-
slotCount_ = 3;
5423+
slotCount_ = 2;
54295424
}
54305425

54315426
void ASTSlot::visit(TemplateNestedNameSpecifierAST* ast) {

0 commit comments

Comments
 (0)