Index: lib/AST/MicrosoftMangle.cpp =================================================================== --- lib/AST/MicrosoftMangle.cpp +++ lib/AST/MicrosoftMangle.cpp @@ -884,11 +884,13 @@ // associate typedef mangled in if they have one. Name += "getName(); - } else if (auto *ED = dyn_cast(TD)) { - auto EnumeratorI = ED->enumerator_begin(); - assert(EnumeratorI != ED->enumerator_end()); + } else if (isa(TD) && + cast(TD)->enumerator_begin() != + cast(TD)->enumerator_end()) { + // Anonymous non-empty enums mangle in the first enumerator. + auto *ED = cast(TD); Name += "getName(); + Name += ED->enumerator_begin()->getName(); } else { // Otherwise, number the types using a $S prefix. Name += " @@ -350,3 +351,10 @@ void f(decltype(enumerator)) {} // CHECK-DAG: define internal void @"?f@@YAXW4@@@Z"( void use_f() { f(enumerator); } + +namespace pr37723 { +struct s { enum {}; enum {}; }; +// DBG-DAG: DW_TAG_enumeration_type{{.*}}identifier: ".?AW4@s@pr37723@@" +// DBG-DAG: DW_TAG_enumeration_type{{.*}}identifier: ".?AW4@s@pr37723@@" +s x; +}