Skip to content

Commit 45e8b00

Browse files
committed
Move binding of type ids out of the Parser
1 parent e1965fe commit 45e8b00

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/parser/cxx/binder.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ void Binder::bind(UsingDirectiveAST* ast) {
491491
}
492492
}
493493

494+
void Binder::bind(TypeIdAST* ast, const Decl& decl) {
495+
ast->type = getDeclaratorType(unit_, ast->declarator, decl.specs.getType());
496+
}
497+
494498
auto Binder::declareTypedef(DeclaratorAST* declarator, const Decl& decl)
495499
-> TypeAliasSymbol* {
496500
auto name = decl.getName();

src/parser/cxx/binder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ class Binder {
123123

124124
void bind(UsingDirectiveAST* ast);
125125

126+
void bind(TypeIdAST* ast, const Decl& decl);
127+
126128
[[nodiscard]] auto instantiate(SimpleTemplateIdAST* templateId) -> Symbol*;
127129

128130
[[nodiscard]] auto resolve(NestedNameSpecifierAST* nestedNameSpecifier,

src/parser/cxx/parser.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5698,8 +5698,7 @@ auto Parser::parse_type_id(TypeIdAST*& yyast) -> bool {
56985698
Decl decl{specs};
56995699
parse_optional_abstract_declarator(yyast->declarator, decl);
57005700

5701-
yyast->type =
5702-
getDeclaratorType(unit, yyast->declarator, decl.specs.getType());
5701+
binder_.bind(yyast, decl);
57035702

57045703
return true;
57055704
}
@@ -5726,7 +5725,8 @@ auto Parser::parse_defining_type_id(
57265725

57275726
ast->typeSpecifierList = typeSpecifierList;
57285727
ast->declarator = declarator;
5729-
ast->type = getDeclaratorType(unit, ast->declarator, decl.specs.getType());
5728+
5729+
binder_.bind(ast, decl);
57305730

57315731
return true;
57325732
}
@@ -7935,7 +7935,10 @@ auto Parser::parse_conversion_function_id(ConversionFunctionIdAST*& yyast)
79357935
auto typeId = make_node<TypeIdAST>(pool_);
79367936
typeId->typeSpecifierList = typeSpecifierList;
79377937
typeId->declarator = declarator;
7938-
typeId->type = getDeclaratorType(unit, declarator, specs.getType());
7938+
7939+
Decl decl{specs};
7940+
7941+
binder_.bind(typeId, decl);
79397942

79407943
auto ast = make_node<ConversionFunctionIdAST>(pool_);
79417944
yyast = ast;

0 commit comments

Comments
 (0)