================ @@ -1010,14 +1022,17 @@ namespace { // trivial because some enumeration values have multiple named // enumerators, such as type_visibility(internal) and // type_visibility(hidden) both mapping to TypeVisibilityAttr::Hidden. - OS << "const char *" << getAttrName() << "Attr::Convert" << type - << "ToStr(" << type << " Val) {\n" + OS << "const char *" << getAttrName() << "Attr::Convert" << shortType + << "ToStr(" << fullType << " Val) {\n" << " switch(Val) {\n"; SmallDenseSet<StringRef, 8> Uniques; for (size_t I = 0; I < enums.size(); ++I) { if (Uniques.insert(enums[I]).second) - OS << " case " << getAttrName() << "Attr::" << enums[I] - << ": return \"" << values[I] << "\";\n"; + OS << " case " << fullType << "::" << enums[I] << ": return \"" + << values[I] << "\";\n"; + } + if (isExternal) { + OS << " default: llvm_unreachable(\"Invalid attribute value\");\n"; ---------------- bogner wrote:
In `Attrs.inc` the only change is that we don't emit a declaration of the enum. In `AttrImpl.inc` we get something like this: ```c++ const char *HLSLResourceAttr::ConvertToStr(llvm::hlsl::ResourceClass Val) { switch(Val) { case llvm::hlsl::ResourceClass::SRV: return "SRV"; case llvm::hlsl::ResourceClass::UAV: return "UAV"; case llvm::hlsl::ResourceClass::CBuffer: return "CBuffer"; case llvm::hlsl::ResourceClass::Sampler: return "Sampler"; default: llvm_unreachable("Invalid attribute value"); } llvm_unreachable("No enumerator with that value"); } ``` Where previously the enum values were spelled like `HLSLResourceAttr::ResourceClass::SRV` and the `default` label wasn't present. https://github.com/llvm/llvm-project/pull/70835 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits