[clang] [clang-tools-extra] [Attributes][HLSL] Teach EnumArgument to refer to an external enum (PR #70835)
Justin Bogner via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 31 11:41:38 PDT 2023
================
@@ -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:
The 'default' is only to appease `-Wswitch`, since otherwise we get things like "error: enumeration value 'Invalid' not handled in switch [-Werror,-Wswitch]"
https://github.com/llvm/llvm-project/pull/70835
More information about the cfe-commits
mailing list