Skip to content

Commit 7b57a54

Browse files
committed
Add missing attributes to BaseSpecifierAST
1 parent c133af7 commit 7b57a54

File tree

13 files changed

+62
-10
lines changed

13 files changed

+62
-10
lines changed

packages/cxx-frontend/src/AST.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7667,25 +7667,39 @@ export class BaseSpecifierAST extends AST {
76677667
);
76687668
}
76697669

7670+
/**
7671+
* Returns the location of the ellipsis token in this node
7672+
*/
7673+
getEllipsisToken(): Token | undefined {
7674+
return Token.from(cxx.getASTSlot(this.getHandle(), 6), this.parser);
7675+
}
7676+
76707677
/**
76717678
* Returns the isTemplateIntroduced attribute of this node
76727679
*/
76737680
getIsTemplateIntroduced(): boolean {
7674-
return cxx.getASTSlot(this.getHandle(), 6) !== 0;
7681+
return cxx.getASTSlot(this.getHandle(), 7) !== 0;
76757682
}
76767683

76777684
/**
76787685
* Returns the isVirtual attribute of this node
76797686
*/
76807687
getIsVirtual(): boolean {
7681-
return cxx.getASTSlot(this.getHandle(), 7) !== 0;
7688+
return cxx.getASTSlot(this.getHandle(), 8) !== 0;
7689+
}
7690+
7691+
/**
7692+
* Returns the isVariadic attribute of this node
7693+
*/
7694+
getIsVariadic(): boolean {
7695+
return cxx.getASTSlot(this.getHandle(), 9) !== 0;
76827696
}
76837697

76847698
/**
76857699
* Returns the accessSpecifier attribute of this node
76867700
*/
76877701
getAccessSpecifier(): TokenKind {
7688-
return cxx.getASTSlot(this.getHandle(), 8);
7702+
return cxx.getASTSlot(this.getHandle(), 10);
76897703
}
76907704
}
76917705

src/parser/cxx/ast.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,10 +1979,12 @@ auto BaseSpecifierAST::firstSourceLocation() -> SourceLocation {
19791979
if (auto loc = cxx::firstSourceLocation(nestedNameSpecifier)) return loc;
19801980
if (auto loc = cxx::firstSourceLocation(templateLoc)) return loc;
19811981
if (auto loc = cxx::firstSourceLocation(unqualifiedId)) return loc;
1982+
if (auto loc = cxx::firstSourceLocation(ellipsisLoc)) return loc;
19821983
return {};
19831984
}
19841985

19851986
auto BaseSpecifierAST::lastSourceLocation() -> SourceLocation {
1987+
if (auto loc = cxx::lastSourceLocation(ellipsisLoc)) return loc;
19861988
if (auto loc = cxx::lastSourceLocation(unqualifiedId)) return loc;
19871989
if (auto loc = cxx::lastSourceLocation(templateLoc)) return loc;
19881990
if (auto loc = cxx::lastSourceLocation(nestedNameSpecifier)) return loc;

src/parser/cxx/ast.fbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ table BaseSpecifier /* AST */ {
422422
virtual_or_access_loc: uint32;
423423
other_virtual_or_access_loc: uint32;
424424
template_loc: uint32;
425+
ellipsis_loc: uint32;
425426
}
426427

427428
table RequiresClause /* AST */ {

src/parser/cxx/ast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,8 +2429,10 @@ class BaseSpecifierAST final : public AST {
24292429
NestedNameSpecifierAST* nestedNameSpecifier = nullptr;
24302430
SourceLocation templateLoc;
24312431
UnqualifiedIdAST* unqualifiedId = nullptr;
2432+
SourceLocation ellipsisLoc;
24322433
bool isTemplateIntroduced = false;
24332434
bool isVirtual = false;
2435+
bool isVariadic = false;
24342436
TokenKind accessSpecifier = TokenKind::T_EOF_SYMBOL;
24352437
BaseClassSymbol* symbol = nullptr;
24362438

src/parser/cxx/ast_pretty_printer.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,9 @@ void ASTPrettyPrinter::operator()(BaseSpecifierAST* ast) {
10441044
writeToken(ast->templateLoc);
10451045
}
10461046
operator()(ast->unqualifiedId);
1047+
if (ast->ellipsisLoc) {
1048+
writeToken(ast->ellipsisLoc);
1049+
}
10471050
}
10481051

10491052
void ASTPrettyPrinter::operator()(RequiresClauseAST* ast) {

src/parser/cxx/ast_printer.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,12 @@ void ASTPrinter::visit(BaseSpecifierAST* ast) {
17291729
out_ << std::format("is-virtual: {}\n", ast->isVirtual);
17301730
--indent_;
17311731
}
1732+
if (ast->isVariadic) {
1733+
++indent_;
1734+
out_ << std::format("{:{}}", "", indent_ * 2);
1735+
out_ << std::format("is-variadic: {}\n", ast->isVariadic);
1736+
--indent_;
1737+
}
17321738
if (ast->accessSpecifier != TokenKind::T_EOF_SYMBOL) {
17331739
++indent_;
17341740
out_ << std::format("{:{}}", "", indent_ * 2);

src/parser/cxx/ast_slot.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3803,24 +3803,34 @@ void ASTSlot::visit(BaseSpecifierAST* ast) {
38033803
slotKind_ = ASTSlotKind::kNode;
38043804
slotNameIndex_ = SlotNameIndex{219};
38053805
break;
3806-
case 6: // isTemplateIntroduced
3806+
case 6: // ellipsisLoc
3807+
value_ = ast->ellipsisLoc.index();
3808+
slotKind_ = ASTSlotKind::kToken;
3809+
slotNameIndex_ = SlotNameIndex{63};
3810+
break;
3811+
case 7: // isTemplateIntroduced
38073812
value_ = std::intptr_t(ast->isTemplateIntroduced != 0);
38083813
slotKind_ = ASTSlotKind::kBoolAttribute;
38093814
slotNameIndex_ = SlotNameIndex{115};
38103815
break;
3811-
case 7: // isVirtual
3816+
case 8: // isVirtual
38123817
value_ = std::intptr_t(ast->isVirtual != 0);
38133818
slotKind_ = ASTSlotKind::kBoolAttribute;
38143819
slotNameIndex_ = SlotNameIndex{119};
38153820
break;
3816-
case 8: // accessSpecifier
3821+
case 9: // isVariadic
3822+
value_ = std::intptr_t(ast->isVariadic != 0);
3823+
slotKind_ = ASTSlotKind::kBoolAttribute;
3824+
slotNameIndex_ = SlotNameIndex{118};
3825+
break;
3826+
case 10: // accessSpecifier
38173827
value_ = std::intptr_t(ast->accessSpecifier);
38183828
slotKind_ = ASTSlotKind::kIntAttribute;
38193829
slotNameIndex_ = SlotNameIndex{2};
38203830
break;
38213831
} // switch
38223832

3823-
slotCount_ = 9;
3833+
slotCount_ = 11;
38243834
}
38253835

38263836
void ASTSlot::visit(RequiresClauseAST* ast) {

src/parser/cxx/binder.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ void Binder::setReportErrors(bool reportErrors) {
5555

5656
void Binder::error(SourceLocation loc, std::string message) {
5757
if (!reportErrors_) return;
58+
if (!unit_->config().checkTypes) return;
5859
unit_->error(loc, std::move(message));
5960
}
6061

6162
void Binder::warning(SourceLocation loc, std::string message) {
6263
if (!reportErrors_) return;
64+
if (!unit_->config().checkTypes) return;
6365
unit_->warning(loc, std::move(message));
6466
}
6567

src/parser/cxx/binder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class Binder {
157157
TranslationUnit* unit_ = nullptr;
158158
Scope* scope_ = nullptr;
159159
bool inTemplate_ = false;
160-
bool reportErrors_ = false;
160+
bool reportErrors_ = true;
161161
};
162162

163163
} // namespace cxx

src/parser/cxx/flatbuffers/ast_decoder.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,7 @@ auto ASTDecoder::decodeBaseSpecifier(const io::BaseSpecifier* node)
29242924
ast->templateLoc = SourceLocation(node->template_loc());
29252925
ast->unqualifiedId =
29262926
decodeUnqualifiedId(node->unqualified_id(), node->unqualified_id_type());
2927+
ast->ellipsisLoc = SourceLocation(node->ellipsis_loc());
29272928
ast->accessSpecifier = static_cast<TokenKind>(node->access_specifier());
29282929
return ast;
29292930
}

0 commit comments

Comments
 (0)