[clang] [clang-tools-extra] [Attributes][HLSL] Teach EnumArgument to refer to an external enum (PR #70835)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 31 10:37:12 PDT 2023


================
@@ -898,23 +898,29 @@ namespace {
   }
 
   class EnumArgument : public Argument {
-    std::string type;
+    std::string fullType;
+    StringRef shortType;
     std::vector<StringRef> values, enums, uniques;
+    bool isExternal;
 
   public:
     EnumArgument(const Record &Arg, StringRef Attr)
-        : Argument(Arg, Attr), type(std::string(Arg.getValueAsString("Type"))),
-          values(Arg.getValueAsListOfStrings("Values")),
+        : Argument(Arg, Attr), values(Arg.getValueAsListOfStrings("Values")),
           enums(Arg.getValueAsListOfStrings("Enums")),
-          uniques(uniqueEnumsInOrder(enums)) {
+          uniques(uniqueEnumsInOrder(enums)),
+          isExternal(Arg.getValueAsBit("External")) {
+      StringRef Type = Arg.getValueAsString("Type");
+      shortType = isExternal ? getAttrName().rsplit("::").second : Type;
----------------
erichkeane wrote:

An assert that `shortType` contains only identifier characters would be a nice improvement here.  And fullType is only identifier and `:` characters (or even better, identifier and `::` tokens).

https://github.com/llvm/llvm-project/pull/70835


More information about the cfe-commits mailing list