Skip to content

Commit a74a773

Browse files
committed
Recursive template instantations
1 parent 86207b1 commit a74a773

29 files changed

+1117
-964
lines changed

packages/cxx-frontend/src/ASTSlot.ts

Lines changed: 177 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -82,180 +82,181 @@ export enum ASTSlot {
8282
decltypeSpecifier = 59,
8383
defaultLoc = 60,
8484
deleteLoc = 61,
85-
designatorList = 62,
86-
doLoc = 63,
87-
dotLoc = 64,
88-
ellipsisLoc = 65,
89-
elseLoc = 66,
90-
elseStatement = 67,
91-
emicolonLoc = 68,
92-
enumLoc = 69,
93-
enumTypeSpecifier = 70,
94-
enumeratorList = 71,
95-
equalLoc = 72,
96-
exceptionDeclaration = 73,
97-
exceptionSpecifier = 74,
98-
exclaimLoc = 75,
99-
explicitLoc = 76,
100-
explicitSpecifier = 77,
101-
exportLoc = 78,
102-
expression = 79,
103-
expressionList = 80,
104-
externLoc = 81,
105-
extraAttributeList = 82,
106-
finalLoc = 83,
107-
foldOp = 84,
108-
foldOpLoc = 85,
109-
forLoc = 86,
110-
friendLoc = 87,
111-
functionBody = 88,
112-
genericAssociationList = 89,
113-
genericLoc = 90,
114-
globalModuleFragment = 91,
115-
gnuAtributeList = 92,
116-
gnuAttributeList = 93,
117-
gotoLabelList = 94,
118-
gotoLoc = 95,
119-
greaterLoc = 96,
120-
handlerList = 97,
121-
headerLoc = 98,
122-
id = 99,
123-
idExpression = 100,
124-
identifier = 101,
125-
identifierLoc = 102,
126-
ifLoc = 103,
127-
iffalseExpression = 104,
128-
iftrueExpression = 105,
129-
importLoc = 106,
130-
importName = 107,
131-
indexExpression = 108,
132-
initDeclaratorList = 109,
133-
initializer = 110,
134-
inlineLoc = 111,
135-
inputOperandList = 112,
136-
isFinal = 113,
137-
isIndirect = 114,
138-
isInline = 115,
139-
isNot = 116,
140-
isOverride = 117,
141-
isPack = 118,
142-
isPure = 119,
143-
isTemplateIntroduced = 120,
144-
isThisIntroduced = 121,
145-
isTrue = 122,
146-
isVariadic = 123,
147-
isVirtual = 124,
148-
lambdaSpecifierList = 125,
149-
lbraceLoc = 126,
150-
lbracket2Loc = 127,
151-
lbracketLoc = 128,
152-
leftExpression = 129,
153-
lessLoc = 130,
154-
literal = 131,
155-
literalLoc = 132,
156-
literalOperatorId = 133,
157-
lparen2Loc = 134,
158-
lparenLoc = 135,
159-
matchedAssocIndex = 136,
160-
memInitializerList = 137,
161-
minusGreaterLoc = 138,
162-
moduleDeclaration = 139,
163-
moduleLoc = 140,
164-
moduleName = 141,
165-
modulePartition = 142,
166-
moduleQualifier = 143,
167-
mutableLoc = 144,
168-
namespaceLoc = 145,
169-
nestedNameSpecifier = 146,
170-
nestedNamespaceSpecifierList = 147,
171-
newInitalizer = 148,
172-
newLoc = 149,
173-
newPlacement = 150,
174-
noexceptLoc = 151,
175-
noreturnLoc = 152,
176-
offsetofLoc = 153,
177-
op = 154,
178-
opLoc = 155,
179-
openLoc = 156,
180-
operatorFunctionId = 157,
181-
operatorLoc = 158,
182-
otherVirtualOrAccessLoc = 159,
183-
outputOperandList = 160,
184-
parameterDeclarationClause = 161,
185-
parameterDeclarationList = 162,
186-
privateLoc = 163,
187-
privateModuleFragment = 164,
188-
ptrOpList = 165,
189-
qualifier = 166,
190-
qualifierLoc = 167,
191-
questionLoc = 168,
192-
rangeDeclaration = 169,
193-
rangeInitializer = 170,
194-
rbraceLoc = 171,
195-
rbracket2Loc = 172,
196-
rbracketLoc = 173,
197-
refLoc = 174,
198-
refOp = 175,
199-
refQualifierLoc = 176,
200-
registerLoc = 177,
201-
requirementList = 178,
202-
requiresClause = 179,
203-
requiresLoc = 180,
204-
restrictLoc = 181,
205-
returnLoc = 182,
206-
rightExpression = 183,
207-
rparen2Loc = 184,
208-
rparenLoc = 185,
209-
scopeLoc = 186,
210-
secondColonLoc = 187,
211-
semicolonLoc = 188,
212-
sizeExpression = 189,
213-
sizeofLoc = 190,
214-
specifier = 191,
215-
specifierLoc = 192,
216-
splicer = 193,
217-
starLoc = 194,
218-
statement = 195,
219-
statementList = 196,
220-
staticAssertLoc = 197,
221-
staticLoc = 198,
222-
stringLiteral = 199,
223-
stringliteralLoc = 200,
224-
switchLoc = 201,
225-
symbolicName = 202,
226-
symbolicNameLoc = 203,
227-
templateArgumentList = 204,
228-
templateId = 205,
229-
templateLoc = 206,
230-
templateParameterList = 207,
231-
templateRequiresClause = 208,
232-
thisLoc = 209,
233-
threadLoc = 210,
234-
threadLocalLoc = 211,
235-
throwLoc = 212,
236-
tildeLoc = 213,
237-
trailingReturnType = 214,
238-
tryLoc = 215,
239-
typeConstraint = 216,
240-
typeId = 217,
241-
typeIdList = 218,
242-
typeLoc = 219,
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,
85+
depth = 62,
86+
designatorList = 63,
87+
doLoc = 64,
88+
dotLoc = 65,
89+
ellipsisLoc = 66,
90+
elseLoc = 67,
91+
elseStatement = 68,
92+
emicolonLoc = 69,
93+
enumLoc = 70,
94+
enumTypeSpecifier = 71,
95+
enumeratorList = 72,
96+
equalLoc = 73,
97+
exceptionDeclaration = 74,
98+
exceptionSpecifier = 75,
99+
exclaimLoc = 76,
100+
explicitLoc = 77,
101+
explicitSpecifier = 78,
102+
exportLoc = 79,
103+
expression = 80,
104+
expressionList = 81,
105+
externLoc = 82,
106+
extraAttributeList = 83,
107+
finalLoc = 84,
108+
foldOp = 85,
109+
foldOpLoc = 86,
110+
forLoc = 87,
111+
friendLoc = 88,
112+
functionBody = 89,
113+
genericAssociationList = 90,
114+
genericLoc = 91,
115+
globalModuleFragment = 92,
116+
gnuAtributeList = 93,
117+
gnuAttributeList = 94,
118+
gotoLabelList = 95,
119+
gotoLoc = 96,
120+
greaterLoc = 97,
121+
handlerList = 98,
122+
headerLoc = 99,
123+
id = 100,
124+
idExpression = 101,
125+
identifier = 102,
126+
identifierLoc = 103,
127+
ifLoc = 104,
128+
iffalseExpression = 105,
129+
iftrueExpression = 106,
130+
importLoc = 107,
131+
importName = 108,
132+
indexExpression = 109,
133+
initDeclaratorList = 110,
134+
initializer = 111,
135+
inlineLoc = 112,
136+
inputOperandList = 113,
137+
isFinal = 114,
138+
isIndirect = 115,
139+
isInline = 116,
140+
isNot = 117,
141+
isOverride = 118,
142+
isPack = 119,
143+
isPure = 120,
144+
isTemplateIntroduced = 121,
145+
isThisIntroduced = 122,
146+
isTrue = 123,
147+
isVariadic = 124,
148+
isVirtual = 125,
149+
lambdaSpecifierList = 126,
150+
lbraceLoc = 127,
151+
lbracket2Loc = 128,
152+
lbracketLoc = 129,
153+
leftExpression = 130,
154+
lessLoc = 131,
155+
literal = 132,
156+
literalLoc = 133,
157+
literalOperatorId = 134,
158+
lparen2Loc = 135,
159+
lparenLoc = 136,
160+
matchedAssocIndex = 137,
161+
memInitializerList = 138,
162+
minusGreaterLoc = 139,
163+
moduleDeclaration = 140,
164+
moduleLoc = 141,
165+
moduleName = 142,
166+
modulePartition = 143,
167+
moduleQualifier = 144,
168+
mutableLoc = 145,
169+
namespaceLoc = 146,
170+
nestedNameSpecifier = 147,
171+
nestedNamespaceSpecifierList = 148,
172+
newInitalizer = 149,
173+
newLoc = 150,
174+
newPlacement = 151,
175+
noexceptLoc = 152,
176+
noreturnLoc = 153,
177+
offsetofLoc = 154,
178+
op = 155,
179+
opLoc = 156,
180+
openLoc = 157,
181+
operatorFunctionId = 158,
182+
operatorLoc = 159,
183+
otherVirtualOrAccessLoc = 160,
184+
outputOperandList = 161,
185+
parameterDeclarationClause = 162,
186+
parameterDeclarationList = 163,
187+
privateLoc = 164,
188+
privateModuleFragment = 165,
189+
ptrOpList = 166,
190+
qualifier = 167,
191+
qualifierLoc = 168,
192+
questionLoc = 169,
193+
rangeDeclaration = 170,
194+
rangeInitializer = 171,
195+
rbraceLoc = 172,
196+
rbracket2Loc = 173,
197+
rbracketLoc = 174,
198+
refLoc = 175,
199+
refOp = 176,
200+
refQualifierLoc = 177,
201+
registerLoc = 178,
202+
requirementList = 179,
203+
requiresClause = 180,
204+
requiresLoc = 181,
205+
restrictLoc = 182,
206+
returnLoc = 183,
207+
rightExpression = 184,
208+
rparen2Loc = 185,
209+
rparenLoc = 186,
210+
scopeLoc = 187,
211+
secondColonLoc = 188,
212+
semicolonLoc = 189,
213+
sizeExpression = 190,
214+
sizeofLoc = 191,
215+
specifier = 192,
216+
specifierLoc = 193,
217+
splicer = 194,
218+
starLoc = 195,
219+
statement = 196,
220+
statementList = 197,
221+
staticAssertLoc = 198,
222+
staticLoc = 199,
223+
stringLiteral = 200,
224+
stringliteralLoc = 201,
225+
switchLoc = 202,
226+
symbolicName = 203,
227+
symbolicNameLoc = 204,
228+
templateArgumentList = 205,
229+
templateId = 206,
230+
templateLoc = 207,
231+
templateParameterList = 208,
232+
templateRequiresClause = 209,
233+
thisLoc = 210,
234+
threadLoc = 211,
235+
threadLocalLoc = 212,
236+
throwLoc = 213,
237+
tildeLoc = 214,
238+
trailingReturnType = 215,
239+
tryLoc = 216,
240+
typeConstraint = 217,
241+
typeId = 218,
242+
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,
261262
}

src/frontend/cxx/frontend.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ void Frontend::Private::preparePreprocessor() {
416416

417417
void Frontend::Private::parse() {
418418
unit_->parse(ParserConfiguration{
419-
.checkTypes = cli.opt_fcheck || unit_->language() == LanguageKind::kC,
419+
.checkTypes =
420+
cli.opt_fcheck || needsIR() || unit_->language() == LanguageKind::kC,
420421
.fuzzyTemplateResolution = true,
421-
.reflect = !cli.opt_fno_reflect,
422422
});
423423

424424
if (cli.opt_freport_missing_types) {

src/lsp/cxx/lsp/cxx_document.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ void CxxDocument::parse(std::string source) {
279279
unit.parse(ParserConfiguration{
280280
.checkTypes = cli.opt_fcheck,
281281
.fuzzyTemplateResolution = true,
282-
.reflect = !cli.opt_fno_reflect,
283282
.stopParsingPredicate = stopParsingPredicate,
284283
.complete = complete,
285284
});

src/parser/cxx/ast.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ class TemplateDeclarationAST final : public DeclarationAST {
520520
RequiresClauseAST* requiresClause = nullptr;
521521
DeclarationAST* declaration = nullptr;
522522
TemplateParametersSymbol* symbol = nullptr;
523+
int depth = 0;
523524

524525
void accept(ASTVisitor* visitor) override { visitor->visit(this); }
525526

src/parser/cxx/ast_printer.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ void ASTPrinter::visit(FunctionDefinitionAST* ast) {
309309

310310
void ASTPrinter::visit(TemplateDeclarationAST* ast) {
311311
out_ << std::format("{}\n", "template-declaration");
312+
++indent_;
313+
out_ << std::format("{:{}}", "", indent_ * 2);
314+
out_ << std::format("depth: {}\n", ast->depth);
315+
--indent_;
312316
if (ast->templateParameterList) {
313317
++indent_;
314318
out_ << std::format("{:{}}", "", indent_ * 2);

0 commit comments

Comments
 (0)