@@ -713,6 +713,17 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
713713 if (kind == FunctionSignatureKind::CxxInlineThunk)
714714 ClangSyntaxPrinter (os).printGenericSignature (Signature);
715715 }
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+ }
716727 auto emittedModule = FD->getModuleContext ();
717728 OutputLanguageMode outputLang = kind == FunctionSignatureKind::CFunctionProto
718729 ? OutputLanguageMode::ObjC
@@ -1521,7 +1532,8 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod(
15211532 auto result = printFunctionSignature (
15221533 FD, signature, cxx_translation::getNameForCxx (FD), resultTy,
15231534 FunctionSignatureKind::CxxInlineThunk, modifiers);
1524- assert (!result.isUnsupported () && " C signature should be unsupported too" );
1535+ if (result.isUnsupported ())
1536+ return ;
15251537
15261538 declAndTypePrinter.printAvailability (os, FD);
15271539 if (!isDefinition) {
0 commit comments