Skip to content

Commit d55c77e

Browse files
committed
Update the reflection syntax according to the latest draft
1 parent cf9426d commit d55c77e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+584
-693
lines changed

packages/cxx-frontend/src/AST.ts

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5041,31 +5041,6 @@ export class TryBlockStatementAST extends StatementAST {
50415041
}
50425042
}
50435043

5044-
/**
5045-
* GeneratedLiteralExpressionAST node.
5046-
*/
5047-
export class GeneratedLiteralExpressionAST extends ExpressionAST {
5048-
/**
5049-
* Traverse this node using the given visitor.
5050-
* @param visitor the visitor.
5051-
* @param context the context.
5052-
* @returns the result of the visit.
5053-
*/
5054-
accept<Context, Result>(
5055-
visitor: ASTVisitor<Context, Result>,
5056-
context: Context,
5057-
): Result {
5058-
return visitor.visitGeneratedLiteralExpression(this, context);
5059-
}
5060-
5061-
/**
5062-
* Returns the location of the literal token in this node
5063-
*/
5064-
getLiteralToken(): Token | undefined {
5065-
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
5066-
}
5067-
}
5068-
50695044
/**
50705045
* CharLiteralExpressionAST node.
50715046
*/
@@ -7012,9 +6987,9 @@ export class GlobalScopeReflectExpressionAST extends ExpressionAST {
70126987
}
70136988

70146989
/**
7015-
* Returns the location of the caret token in this node
6990+
* Returns the location of the caretCaret token in this node
70166991
*/
7017-
getCaretToken(): Token | undefined {
6992+
getCaretCaretToken(): Token | undefined {
70186993
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
70196994
}
70206995

@@ -7044,9 +7019,9 @@ export class NamespaceReflectExpressionAST extends ExpressionAST {
70447019
}
70457020

70467021
/**
7047-
* Returns the location of the caret token in this node
7022+
* Returns the location of the caretCaret token in this node
70487023
*/
7049-
getCaretToken(): Token | undefined {
7024+
getCaretCaretToken(): Token | undefined {
70507025
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
70517026
}
70527027

@@ -7084,9 +7059,9 @@ export class TypeIdReflectExpressionAST extends ExpressionAST {
70847059
}
70857060

70867061
/**
7087-
* Returns the location of the caret token in this node
7062+
* Returns the location of the caretCaret token in this node
70887063
*/
7089-
getCaretToken(): Token | undefined {
7064+
getCaretCaretToken(): Token | undefined {
70907065
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
70917066
}
70927067

@@ -7119,9 +7094,9 @@ export class ReflectExpressionAST extends ExpressionAST {
71197094
}
71207095

71217096
/**
7122-
* Returns the location of the caret token in this node
7097+
* Returns the location of the caretCaret token in this node
71237098
*/
7124-
getCaretToken(): Token | undefined {
7099+
getCaretCaretToken(): Token | undefined {
71257100
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
71267101
}
71277102

@@ -8922,31 +8897,6 @@ export class ConstraintTypeParameterAST extends TemplateParameterAST {
89228897
}
89238898
}
89248899

8925-
/**
8926-
* GeneratedTypeSpecifierAST node.
8927-
*/
8928-
export class GeneratedTypeSpecifierAST extends SpecifierAST {
8929-
/**
8930-
* Traverse this node using the given visitor.
8931-
* @param visitor the visitor.
8932-
* @param context the context.
8933-
* @returns the result of the visit.
8934-
*/
8935-
accept<Context, Result>(
8936-
visitor: ASTVisitor<Context, Result>,
8937-
context: Context,
8938-
): Result {
8939-
return visitor.visitGeneratedTypeSpecifier(this, context);
8940-
}
8941-
8942-
/**
8943-
* Returns the location of the type token in this node
8944-
*/
8945-
getTypeToken(): Token | undefined {
8946-
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
8947-
}
8948-
}
8949-
89508900
/**
89518901
* TypedefSpecifierAST node.
89528902
*/
@@ -9461,9 +9411,9 @@ export class SignTypeSpecifierAST extends SpecifierAST {
94619411
}
94629412

94639413
/**
9464-
* VaListTypeSpecifierAST node.
9414+
* BuiltinTypeSpecifierAST node.
94659415
*/
9466-
export class VaListTypeSpecifierAST extends SpecifierAST {
9416+
export class BuiltinTypeSpecifierAST extends SpecifierAST {
94679417
/**
94689418
* Traverse this node using the given visitor.
94699419
* @param visitor the visitor.
@@ -9474,7 +9424,7 @@ export class VaListTypeSpecifierAST extends SpecifierAST {
94749424
visitor: ASTVisitor<Context, Result>,
94759425
context: Context,
94769426
): Result {
9477-
return visitor.visitVaListTypeSpecifier(this, context);
9427+
return visitor.visitBuiltinTypeSpecifier(this, context);
94789428
}
94799429

94809430
/**
@@ -13404,7 +13354,6 @@ const AST_CONSTRUCTORS: Array<
1340413354
GotoStatementAST,
1340513355
DeclarationStatementAST,
1340613356
TryBlockStatementAST,
13407-
GeneratedLiteralExpressionAST,
1340813357
CharLiteralExpressionAST,
1340913358
BoolLiteralExpressionAST,
1341013359
IntLiteralExpressionAST,
@@ -13475,7 +13424,6 @@ const AST_CONSTRUCTORS: Array<
1347513424
NonTypeTemplateParameterAST,
1347613425
TypenameTypeParameterAST,
1347713426
ConstraintTypeParameterAST,
13478-
GeneratedTypeSpecifierAST,
1347913427
TypedefSpecifierAST,
1348013428
FriendSpecifierAST,
1348113429
ConstevalSpecifierAST,
@@ -13495,7 +13443,7 @@ const AST_CONSTRUCTORS: Array<
1349513443
VoidTypeSpecifierAST,
1349613444
SizeTypeSpecifierAST,
1349713445
SignTypeSpecifierAST,
13498-
VaListTypeSpecifierAST,
13446+
BuiltinTypeSpecifierAST,
1349913447
IntegralTypeSpecifierAST,
1350013448
FloatingPointTypeSpecifierAST,
1350113449
ComplexTypeSpecifierAST,

packages/cxx-frontend/src/ASTKind.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ export enum ASTKind {
104104
TryBlockStatement,
105105

106106
// ExpressionAST
107-
GeneratedLiteralExpression,
108107
CharLiteralExpression,
109108
BoolLiteralExpression,
110109
IntLiteralExpression,
@@ -183,7 +182,6 @@ export enum ASTKind {
183182
ConstraintTypeParameter,
184183

185184
// SpecifierAST
186-
GeneratedTypeSpecifier,
187185
TypedefSpecifier,
188186
FriendSpecifier,
189187
ConstevalSpecifier,
@@ -203,7 +201,7 @@ export enum ASTKind {
203201
VoidTypeSpecifier,
204202
SizeTypeSpecifier,
205203
SignTypeSpecifier,
206-
VaListTypeSpecifier,
204+
BuiltinTypeSpecifier,
207205
IntegralTypeSpecifier,
208206
FloatingPointTypeSpecifier,
209207
ComplexTypeSpecifier,

packages/cxx-frontend/src/ASTSlot.ts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export enum ASTSlot {
4848
captureDefault = 25,
4949
captureDefaultLoc = 26,
5050
captureList = 27,
51-
caretLoc = 28,
51+
caretCaretLoc = 28,
5252
caseLoc = 29,
5353
castLoc = 30,
5454
catchLoc = 31,
@@ -240,23 +240,22 @@ export enum ASTSlot {
240240
typeConstraint = 217,
241241
typeId = 218,
242242
typeIdList = 219,
243-
typeLoc = 220,
244-
typeQualifierList = 221,
245-
typeSpecifier = 222,
246-
typeSpecifierList = 223,
247-
typeTraitLoc = 224,
248-
typedefLoc = 225,
249-
typeidLoc = 226,
250-
typenameLoc = 227,
251-
underlyingTypeLoc = 228,
252-
unqualifiedId = 229,
253-
usingDeclaratorList = 230,
254-
usingLoc = 231,
255-
vaArgLoc = 232,
256-
virtualLoc = 233,
257-
virtualOrAccessLoc = 234,
258-
voidLoc = 235,
259-
volatileLoc = 236,
260-
whileLoc = 237,
261-
yieldLoc = 238,
243+
typeQualifierList = 220,
244+
typeSpecifier = 221,
245+
typeSpecifierList = 222,
246+
typeTraitLoc = 223,
247+
typedefLoc = 224,
248+
typeidLoc = 225,
249+
typenameLoc = 226,
250+
underlyingTypeLoc = 227,
251+
unqualifiedId = 228,
252+
usingDeclaratorList = 229,
253+
usingLoc = 230,
254+
vaArgLoc = 231,
255+
virtualLoc = 232,
256+
virtualOrAccessLoc = 233,
257+
voidLoc = 234,
258+
volatileLoc = 235,
259+
whileLoc = 236,
260+
yieldLoc = 237,
262261
}

packages/cxx-frontend/src/ASTVisitor.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -890,18 +890,6 @@ export abstract class ASTVisitor<Context, Result> {
890890
context: Context,
891891
): Result;
892892

893-
/**
894-
* Visit GeneratedLiteralExpression node.
895-
*
896-
* @param node The node to visit.
897-
* @param context The context.
898-
* @returns The result of the visit.
899-
*/
900-
abstract visitGeneratedLiteralExpression(
901-
node: ast.GeneratedLiteralExpressionAST,
902-
context: Context,
903-
): Result;
904-
905893
/**
906894
* Visit CharLiteralExpression node.
907895
*
@@ -1742,18 +1730,6 @@ export abstract class ASTVisitor<Context, Result> {
17421730
context: Context,
17431731
): Result;
17441732

1745-
/**
1746-
* Visit GeneratedTypeSpecifier node.
1747-
*
1748-
* @param node The node to visit.
1749-
* @param context The context.
1750-
* @returns The result of the visit.
1751-
*/
1752-
abstract visitGeneratedTypeSpecifier(
1753-
node: ast.GeneratedTypeSpecifierAST,
1754-
context: Context,
1755-
): Result;
1756-
17571733
/**
17581734
* Visit TypedefSpecifier node.
17591735
*
@@ -1983,14 +1959,14 @@ export abstract class ASTVisitor<Context, Result> {
19831959
): Result;
19841960

19851961
/**
1986-
* Visit VaListTypeSpecifier node.
1962+
* Visit BuiltinTypeSpecifier node.
19871963
*
19881964
* @param node The node to visit.
19891965
* @param context The context.
19901966
* @returns The result of the visit.
19911967
*/
1992-
abstract visitVaListTypeSpecifier(
1993-
node: ast.VaListTypeSpecifierAST,
1968+
abstract visitBuiltinTypeSpecifier(
1969+
node: ast.BuiltinTypeSpecifierAST,
19941970
context: Context,
19951971
): Result;
19961972

packages/cxx-frontend/src/RecursiveASTVisitor.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,17 +1038,6 @@ export class RecursiveASTVisitor<Context> extends ASTVisitor<Context, void> {
10381038
}
10391039
}
10401040

1041-
/**
1042-
* Visit a GeneratedLiteralExpression node.
1043-
*
1044-
* @param node The node to visit.
1045-
* @param context The context.
1046-
*/
1047-
visitGeneratedLiteralExpression(
1048-
node: ast.GeneratedLiteralExpressionAST,
1049-
context: Context,
1050-
): void {}
1051-
10521041
/**
10531042
* Visit a CharLiteralExpression node.
10541043
*
@@ -1940,17 +1929,6 @@ export class RecursiveASTVisitor<Context> extends ASTVisitor<Context, void> {
19401929
this.accept(node.getTypeId(), context);
19411930
}
19421931

1943-
/**
1944-
* Visit a GeneratedTypeSpecifier node.
1945-
*
1946-
* @param node The node to visit.
1947-
* @param context The context.
1948-
*/
1949-
visitGeneratedTypeSpecifier(
1950-
node: ast.GeneratedTypeSpecifierAST,
1951-
context: Context,
1952-
): void {}
1953-
19541932
/**
19551933
* Visit a TypedefSpecifier node.
19561934
*
@@ -2148,13 +2126,13 @@ export class RecursiveASTVisitor<Context> extends ASTVisitor<Context, void> {
21482126
): void {}
21492127

21502128
/**
2151-
* Visit a VaListTypeSpecifier node.
2129+
* Visit a BuiltinTypeSpecifier node.
21522130
*
21532131
* @param node The node to visit.
21542132
* @param context The context.
21552133
*/
2156-
visitVaListTypeSpecifier(
2157-
node: ast.VaListTypeSpecifierAST,
2134+
visitBuiltinTypeSpecifier(
2135+
node: ast.BuiltinTypeSpecifierAST,
21582136
context: Context,
21592137
): void {}
21602138

packages/cxx-frontend/src/TokenKind.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export enum TokenKind {
4141
BAR_BAR,
4242
BAR_EQUAL,
4343
BAR,
44+
CARET_CARET,
4445
CARET_EQUAL,
4546
CARET,
4647
COLON_COLON,
@@ -100,6 +101,7 @@ export enum TokenKind {
100101
_NORETURN,
101102
__ATTRIBUTE__,
102103
__BUILTIN_BIT_CAST,
104+
__BUILTIN_META_INFO,
103105
__BUILTIN_OFFSETOF,
104106
__BUILTIN_VA_ARG,
105107
__BUILTIN_VA_LIST,

packages/cxx-gen-ast/src/tokens.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const OPERATORS: Array<[kind: string, spelling: string]> = [
4343
["BAR_BAR", "||"],
4444
["BAR_EQUAL", "|="],
4545
["BAR", "|"],
46+
["CARET_CARET", "^^"],
4647
["CARET_EQUAL", "^="],
4748
["CARET", "^"],
4849
["COLON_COLON", "::"],
@@ -182,6 +183,7 @@ export const CXX_KEYWORDS: string[] = [
182183
"__builtin_offsetof",
183184
"__builtin_va_arg",
184185
"__builtin_va_list",
186+
"__builtin_meta_info",
185187
"__complex__",
186188
"__extension__",
187189
"__float128",

src/mlir/cxx/mlir/codegen_expressions.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct Codegen::ExpressionVisitor {
4646
return type_cast<BoolType>(control()->remove_cv(type));
4747
}
4848

49-
auto operator()(GeneratedLiteralExpressionAST* ast) -> ExpressionResult;
5049
auto operator()(CharLiteralExpressionAST* ast) -> ExpressionResult;
5150
auto operator()(BoolLiteralExpressionAST* ast) -> ExpressionResult;
5251
auto operator()(IntLiteralExpressionAST* ast) -> ExpressionResult;
@@ -174,13 +173,6 @@ auto Codegen::newPlacement(NewPlacementAST* ast) -> NewPlacementResult {
174173
return {};
175174
}
176175

177-
auto Codegen::ExpressionVisitor::operator()(GeneratedLiteralExpressionAST* ast)
178-
-> ExpressionResult {
179-
auto op =
180-
gen.emitTodoExpr(ast->firstSourceLocation(), to_string(ast->kind()));
181-
return {op};
182-
}
183-
184176
auto Codegen::ExpressionVisitor::operator()(CharLiteralExpressionAST* ast)
185177
-> ExpressionResult {
186178
auto loc = gen.getLocation(ast->literalLoc);

0 commit comments

Comments
 (0)