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

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 15 07:28:43 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>


================
@@ -769,23 +769,81 @@ void SemaHLSL::ActOnTopLevelFunction(FunctionDecl *FD) {
   }
 }
 
-bool SemaHLSL::isSemanticValid(FunctionDecl *FD, DeclaratorDecl *D) {
-  const auto *AnnotationAttr = D->getAttr<HLSLAnnotationAttr>();
-  if (AnnotationAttr) {
-    CheckSemanticAnnotation(FD, D, AnnotationAttr);
-    return true;
+HLSLSemanticAttr *SemaHLSL::createSemantic(const SemanticInfo &Info,
+                                           DeclaratorDecl *TargetDecl) {
+  std::string SemanticName = Info.Semantic->getAttrName()->getName().upper();
+
+  if (SemanticName == "SV_DISPATCHTHREADID") {
----------------
llvm-beanz wrote:

DXC does make the assumption that `SV_` prefixed semantics are system values and that they have specific places they are allowed. It might be preferable to check if the semantic name starts with `"SV_"` and have a separate function to parse known system values to enums.

Here's an example of DXC rejecting an unknown system value: https://godbolt.org/z/PqhsTE84E

The message is somewhat awkward, I'd rather we had something like "unsupported system value semantic" for completely unrecognized values.

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


More information about the cfe-commits mailing list