Skip to content

Commit 9096466

Browse files
committed
Save the virtual and access specifier location of base class specifiers
1 parent 26aaa0d commit 9096466

File tree

11 files changed

+434
-382
lines changed

11 files changed

+434
-382
lines changed

packages/cxx-frontend/src/AST.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7626,12 +7626,26 @@ export class BaseSpecifierAST extends AST {
76267626
};
76277627
}
76287628

7629+
/**
7630+
* Returns the location of the virtualOrAccess token in this node
7631+
*/
7632+
getVirtualOrAccessToken(): Token | undefined {
7633+
return Token.from(cxx.getASTSlot(this.getHandle(), 1), this.parser);
7634+
}
7635+
7636+
/**
7637+
* Returns the location of the otherVirtualOrAccess token in this node
7638+
*/
7639+
getOtherVirtualOrAccessToken(): Token | undefined {
7640+
return Token.from(cxx.getASTSlot(this.getHandle(), 2), this.parser);
7641+
}
7642+
76297643
/**
76307644
* Returns the nestedNameSpecifier of this node
76317645
*/
76327646
getNestedNameSpecifier(): NestedNameSpecifierAST | undefined {
76337647
return AST.from<NestedNameSpecifierAST>(
7634-
cxx.getASTSlot(this.getHandle(), 1),
7648+
cxx.getASTSlot(this.getHandle(), 3),
76357649
this.parser,
76367650
);
76377651
}
@@ -7640,15 +7654,15 @@ export class BaseSpecifierAST extends AST {
76407654
* Returns the location of the template token in this node
76417655
*/
76427656
getTemplateToken(): Token | undefined {
7643-
return Token.from(cxx.getASTSlot(this.getHandle(), 2), this.parser);
7657+
return Token.from(cxx.getASTSlot(this.getHandle(), 4), this.parser);
76447658
}
76457659

76467660
/**
76477661
* Returns the unqualifiedId of this node
76487662
*/
76497663
getUnqualifiedId(): UnqualifiedIdAST | undefined {
76507664
return AST.from<UnqualifiedIdAST>(
7651-
cxx.getASTSlot(this.getHandle(), 3),
7665+
cxx.getASTSlot(this.getHandle(), 5),
76527666
this.parser,
76537667
);
76547668
}
@@ -7657,21 +7671,21 @@ export class BaseSpecifierAST extends AST {
76577671
* Returns the isTemplateIntroduced attribute of this node
76587672
*/
76597673
getIsTemplateIntroduced(): boolean {
7660-
return cxx.getASTSlot(this.getHandle(), 4) !== 0;
7674+
return cxx.getASTSlot(this.getHandle(), 6) !== 0;
76617675
}
76627676

76637677
/**
76647678
* Returns the isVirtual attribute of this node
76657679
*/
76667680
getIsVirtual(): boolean {
7667-
return cxx.getASTSlot(this.getHandle(), 5) !== 0;
7681+
return cxx.getASTSlot(this.getHandle(), 7) !== 0;
76687682
}
76697683

76707684
/**
76717685
* Returns the accessSpecifier attribute of this node
76727686
*/
76737687
getAccessSpecifier(): TokenKind {
7674-
return cxx.getASTSlot(this.getHandle(), 6);
7688+
return cxx.getASTSlot(this.getHandle(), 8);
76757689
}
76767690
}
76777691

packages/cxx-frontend/src/ASTSlot.ts

Lines changed: 77 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -171,79 +171,81 @@ export enum ASTSlot {
171171
openLoc = 149,
172172
operatorFunctionId = 150,
173173
operatorLoc = 151,
174-
outputOperandList = 152,
175-
parameterDeclarationClause = 153,
176-
parameterDeclarationList = 154,
177-
privateLoc = 155,
178-
privateModuleFragment = 156,
179-
ptrOpList = 157,
180-
qualifier = 158,
181-
qualifierLoc = 159,
182-
questionLoc = 160,
183-
rangeDeclaration = 161,
184-
rangeInitializer = 162,
185-
rbraceLoc = 163,
186-
rbracket2Loc = 164,
187-
rbracketLoc = 165,
188-
refLoc = 166,
189-
refOp = 167,
190-
refQualifierLoc = 168,
191-
requirementList = 169,
192-
requiresClause = 170,
193-
requiresLoc = 171,
194-
restrictLoc = 172,
195-
returnLoc = 173,
196-
rightExpression = 174,
197-
rparen2Loc = 175,
198-
rparenLoc = 176,
199-
scopeLoc = 177,
200-
secondColonLoc = 178,
201-
semicolonLoc = 179,
202-
sizeExpression = 180,
203-
sizeofLoc = 181,
204-
specifier = 182,
205-
specifierLoc = 183,
206-
splicer = 184,
207-
starLoc = 185,
208-
statement = 186,
209-
statementList = 187,
210-
staticAssertLoc = 188,
211-
staticLoc = 189,
212-
stringLiteral = 190,
213-
stringliteralLoc = 191,
214-
switchLoc = 192,
215-
symbolicName = 193,
216-
symbolicNameLoc = 194,
217-
templateArgumentList = 195,
218-
templateId = 196,
219-
templateLoc = 197,
220-
templateParameterList = 198,
221-
templateRequiresClause = 199,
222-
thisLoc = 200,
223-
threadLoc = 201,
224-
threadLocalLoc = 202,
225-
throwLoc = 203,
226-
tildeLoc = 204,
227-
trailingReturnType = 205,
228-
tryLoc = 206,
229-
typeConstraint = 207,
230-
typeId = 208,
231-
typeIdList = 209,
232-
typeLoc = 210,
233-
typeSpecifier = 211,
234-
typeSpecifierList = 212,
235-
typeTraitLoc = 213,
236-
typedefLoc = 214,
237-
typeidLoc = 215,
238-
typenameLoc = 216,
239-
underlyingTypeLoc = 217,
240-
unqualifiedId = 218,
241-
usingDeclaratorList = 219,
242-
usingLoc = 220,
243-
vaArgLoc = 221,
244-
virtualLoc = 222,
245-
voidLoc = 223,
246-
volatileLoc = 224,
247-
whileLoc = 225,
248-
yieldLoc = 226,
174+
otherVirtualOrAccessLoc = 152,
175+
outputOperandList = 153,
176+
parameterDeclarationClause = 154,
177+
parameterDeclarationList = 155,
178+
privateLoc = 156,
179+
privateModuleFragment = 157,
180+
ptrOpList = 158,
181+
qualifier = 159,
182+
qualifierLoc = 160,
183+
questionLoc = 161,
184+
rangeDeclaration = 162,
185+
rangeInitializer = 163,
186+
rbraceLoc = 164,
187+
rbracket2Loc = 165,
188+
rbracketLoc = 166,
189+
refLoc = 167,
190+
refOp = 168,
191+
refQualifierLoc = 169,
192+
requirementList = 170,
193+
requiresClause = 171,
194+
requiresLoc = 172,
195+
restrictLoc = 173,
196+
returnLoc = 174,
197+
rightExpression = 175,
198+
rparen2Loc = 176,
199+
rparenLoc = 177,
200+
scopeLoc = 178,
201+
secondColonLoc = 179,
202+
semicolonLoc = 180,
203+
sizeExpression = 181,
204+
sizeofLoc = 182,
205+
specifier = 183,
206+
specifierLoc = 184,
207+
splicer = 185,
208+
starLoc = 186,
209+
statement = 187,
210+
statementList = 188,
211+
staticAssertLoc = 189,
212+
staticLoc = 190,
213+
stringLiteral = 191,
214+
stringliteralLoc = 192,
215+
switchLoc = 193,
216+
symbolicName = 194,
217+
symbolicNameLoc = 195,
218+
templateArgumentList = 196,
219+
templateId = 197,
220+
templateLoc = 198,
221+
templateParameterList = 199,
222+
templateRequiresClause = 200,
223+
thisLoc = 201,
224+
threadLoc = 202,
225+
threadLocalLoc = 203,
226+
throwLoc = 204,
227+
tildeLoc = 205,
228+
trailingReturnType = 206,
229+
tryLoc = 207,
230+
typeConstraint = 208,
231+
typeId = 209,
232+
typeIdList = 210,
233+
typeLoc = 211,
234+
typeSpecifier = 212,
235+
typeSpecifierList = 213,
236+
typeTraitLoc = 214,
237+
typedefLoc = 215,
238+
typeidLoc = 216,
239+
typenameLoc = 217,
240+
underlyingTypeLoc = 218,
241+
unqualifiedId = 219,
242+
usingDeclaratorList = 220,
243+
usingLoc = 221,
244+
vaArgLoc = 222,
245+
virtualLoc = 223,
246+
virtualOrAccessLoc = 224,
247+
voidLoc = 225,
248+
volatileLoc = 226,
249+
whileLoc = 227,
250+
yieldLoc = 228,
249251
}

src/parser/cxx/ast.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,8 @@ auto HandlerAST::lastSourceLocation() -> SourceLocation {
19741974

19751975
auto BaseSpecifierAST::firstSourceLocation() -> SourceLocation {
19761976
if (auto loc = cxx::firstSourceLocation(attributeList)) return loc;
1977+
if (auto loc = cxx::firstSourceLocation(virtualOrAccessLoc)) return loc;
1978+
if (auto loc = cxx::firstSourceLocation(otherVirtualOrAccessLoc)) return loc;
19771979
if (auto loc = cxx::firstSourceLocation(nestedNameSpecifier)) return loc;
19781980
if (auto loc = cxx::firstSourceLocation(templateLoc)) return loc;
19791981
if (auto loc = cxx::firstSourceLocation(unqualifiedId)) return loc;
@@ -1984,6 +1986,8 @@ auto BaseSpecifierAST::lastSourceLocation() -> SourceLocation {
19841986
if (auto loc = cxx::lastSourceLocation(unqualifiedId)) return loc;
19851987
if (auto loc = cxx::lastSourceLocation(templateLoc)) return loc;
19861988
if (auto loc = cxx::lastSourceLocation(nestedNameSpecifier)) return loc;
1989+
if (auto loc = cxx::lastSourceLocation(otherVirtualOrAccessLoc)) return loc;
1990+
if (auto loc = cxx::lastSourceLocation(virtualOrAccessLoc)) return loc;
19871991
if (auto loc = cxx::lastSourceLocation(attributeList)) return loc;
19881992
return {};
19891993
}

src/parser/cxx/ast.fbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ table BaseSpecifier /* AST */ {
419419
nested_name_specifier: NestedNameSpecifier;
420420
unqualified_id: UnqualifiedId;
421421
access_specifier: uint32;
422+
virtual_or_access_loc: uint32;
423+
other_virtual_or_access_loc: uint32;
422424
template_loc: uint32;
423425
}
424426

src/parser/cxx/ast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,8 @@ class BaseSpecifierAST final : public AST {
24242424
BaseSpecifierAST() : AST(Kind) {}
24252425

24262426
List<AttributeSpecifierAST*>* attributeList = nullptr;
2427+
SourceLocation virtualOrAccessLoc;
2428+
SourceLocation otherVirtualOrAccessLoc;
24272429
NestedNameSpecifierAST* nestedNameSpecifier = nullptr;
24282430
SourceLocation templateLoc;
24292431
UnqualifiedIdAST* unqualifiedId = nullptr;

src/parser/cxx/ast_pretty_printer.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,12 @@ void ASTPrettyPrinter::operator()(BaseSpecifierAST* ast) {
10321032
operator()(it->value);
10331033
}
10341034

1035+
if (ast->virtualOrAccessLoc) {
1036+
writeToken(ast->virtualOrAccessLoc);
1037+
}
1038+
if (ast->otherVirtualOrAccessLoc) {
1039+
writeToken(ast->otherVirtualOrAccessLoc);
1040+
}
10351041
operator()(ast->nestedNameSpecifier);
10361042
if (ast->templateLoc) {
10371043
writeToken(ast->templateLoc);

src/parser/cxx/ast_rewriter.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,8 @@ auto ASTRewriter::operator()(BaseSpecifierAST* ast) -> BaseSpecifierAST* {
11251125
attributeList = &(*attributeList)->next;
11261126
}
11271127

1128+
copy->virtualOrAccessLoc = ast->virtualOrAccessLoc;
1129+
copy->otherVirtualOrAccessLoc = ast->otherVirtualOrAccessLoc;
11281130
copy->nestedNameSpecifier = operator()(ast->nestedNameSpecifier);
11291131
copy->templateLoc = ast->templateLoc;
11301132
copy->unqualifiedId = operator()(ast->unqualifiedId);

0 commit comments

Comments
 (0)