@@ -713,6 +713,17 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
713
713
if (kind == FunctionSignatureKind::CxxInlineThunk)
714
714
ClangSyntaxPrinter (os).printGenericSignature (Signature);
715
715
}
716
+ if (const auto *enumDecl = FD->getDeclContext ()->getSelfEnumDecl ()) {
717
+ // We cannot emit functions with the same name as an enum case yet, the resulting header
718
+ // does not compiler.
719
+ // FIXME: either do not emit cases as inline members, or rename the cases or the
720
+ // colliding functions.
721
+ for (const auto *enumElement : enumDecl->getAllElements ()) {
722
+ auto elementName = enumElement->getName ();
723
+ if (!elementName.isSpecial () && elementName.getBaseIdentifier ().is (name))
724
+ return ClangRepresentation::unsupported;
725
+ }
726
+ }
716
727
auto emittedModule = FD->getModuleContext ();
717
728
OutputLanguageMode outputLang = kind == FunctionSignatureKind::CFunctionProto
718
729
? OutputLanguageMode::ObjC
@@ -1521,7 +1532,8 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod(
1521
1532
auto result = printFunctionSignature (
1522
1533
FD, signature, cxx_translation::getNameForCxx (FD), resultTy,
1523
1534
FunctionSignatureKind::CxxInlineThunk, modifiers);
1524
- assert (!result.isUnsupported () && " C signature should be unsupported too" );
1535
+ if (result.isUnsupported ())
1536
+ return ;
1525
1537
1526
1538
declAndTypePrinter.printAvailability (os, FD);
1527
1539
if (!isDefinition) {
0 commit comments