Skip to content

Commit 5d98b9d

Browse files
committed
Override the name of anonymous symbols that have a type alias.
1 parent abb9c82 commit 5d98b9d

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/parser/cxx/binder.cc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,28 @@ auto Binder::declareTypeAlias(SourceLocation identifierLoc, TypeIdAST* typeId)
412412
if (typeId) symbol->setType(typeId->type);
413413
symbol->setTemplateParameters(currentTemplateParameters());
414414
declaringScope()->addSymbol(symbol);
415+
416+
if (auto classType = type_cast<ClassType>(symbol->type())) {
417+
auto classSymbol = classType->symbol();
418+
if (!classSymbol->name()) {
419+
classSymbol->setName(symbol->name());
420+
}
421+
}
422+
423+
if (auto enumType = type_cast<EnumType>(symbol->type())) {
424+
auto enumSymbol = enumType->symbol();
425+
if (!enumSymbol->name()) {
426+
enumSymbol->setName(symbol->name());
427+
}
428+
}
429+
430+
if (auto scopedEnumType = type_cast<ScopedEnumType>(symbol->type())) {
431+
auto scopedEnumSymbol = scopedEnumType->symbol();
432+
if (!scopedEnumSymbol->name()) {
433+
scopedEnumSymbol->setName(symbol->name());
434+
}
435+
}
436+
415437
return symbol;
416438
}
417439

@@ -634,6 +656,28 @@ auto Binder::declareTypedef(DeclaratorAST* declarator, const Decl& decl)
634656
symbol->setName(name);
635657
symbol->setType(type);
636658
scope()->addSymbol(symbol);
659+
660+
if (auto classType = type_cast<ClassType>(symbol->type())) {
661+
auto classSymbol = classType->symbol();
662+
if (!classSymbol->name()) {
663+
classSymbol->setName(symbol->name());
664+
}
665+
}
666+
667+
if (auto enumType = type_cast<EnumType>(symbol->type())) {
668+
auto enumSymbol = enumType->symbol();
669+
if (!enumSymbol->name()) {
670+
enumSymbol->setName(symbol->name());
671+
}
672+
}
673+
674+
if (auto scopedEnumType = type_cast<ScopedEnumType>(symbol->type())) {
675+
auto scopedEnumSymbol = scopedEnumType->symbol();
676+
if (!scopedEnumSymbol->name()) {
677+
scopedEnumSymbol->setName(symbol->name());
678+
}
679+
}
680+
637681
return symbol;
638682
}
639683

0 commit comments

Comments
 (0)