[clang] [HLSL] Allow input semantics on structs (PR #159047)

Tex Riddell via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 20 13:39:37 PDT 2025


Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/159047 at github.com>


================
@@ -3078,6 +3078,17 @@ static void emitAttributes(const RecordKeeper &Records, raw_ostream &OS,
 
       OS << "  {\n";
 
+      // The generator puts the arguments for each attribute in the child class,
+      // even if those are set in the inherited attribute class (in the TD
+      // file). This means I cannot access those from the parent class, and have
+      // to do this weirdness. Maybe the generator should be changed to
+      // arguments are put in the class they are declared in inside the TD file?
+      if (HLSLSemantic) {
+        OS << "  if (SemanticExplicitIndex)\n";
+        OS << "    setSemanticIndex(SemanticIndex);\n";
+        OS << "  setTargetDecl(Target);\n";
+      }
+
----------------
tex3d wrote:

Can you add the needed fields manually to the parent class rather than declaring them through the .td file?

In any case, I think there should just be one semantic attribute representing the basic language element and capturing the string identifier exactly as written by the user, rather than having one for each system value, which would also solve this.
These could be interpreted into elements as I suggested when diagnosing an entry point decl, since only at that point are all relevant facts known to perform correct diagnostics.

I don't think early interpretation of properties like explicit index, or using new semantic attributes as element attributes, buys us anything other than additional diagnostic and attribute complexity.

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


More information about the cfe-commits mailing list