[clang] [HLSL] Rewrite semantics parsing (PR #152537)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 14 06:47:07 PDT 2025
================
@@ -1513,29 +1517,71 @@ bool SemaHLSL::diagnosePositionType(QualType T, const ParsedAttr &AL) {
return true;
}
-void SemaHLSL::handleSV_PositionAttr(Decl *D, const ParsedAttr &AL) {
- auto *VD = cast<ValueDecl>(D);
- if (!diagnosePositionType(VD->getType(), AL))
- return;
-
- D->addAttr(::new (getASTContext()) HLSLSV_PositionAttr(getASTContext(), AL));
-}
+void SemaHLSL::diagnoseSystemSemanticAttr(Decl *D, const ParsedAttr &AL,
+ std::optional<unsigned> Index) {
+ StringRef SemanticName = AL.getAttrName()->getName();
-void SemaHLSL::handleSV_GroupThreadIDAttr(Decl *D, const ParsedAttr &AL) {
auto *VD = cast<ValueDecl>(D);
- if (!diagnoseInputIDType(VD->getType(), AL))
- return;
-
- D->addAttr(::new (getASTContext())
- HLSLSV_GroupThreadIDAttr(getASTContext(), AL));
-}
+ QualType ValueType = VD->getType();
+ if (auto *FD = dyn_cast<FunctionDecl>(D))
+ ValueType = FD->getReturnType();
+
+ bool IsOutput = false;
+ if (HLSLParamModifierAttr *MA = D->getAttr<HLSLParamModifierAttr>()) {
+ if (MA->isOut()) {
+ IsOutput = true;
+ ValueType = cast<ReferenceType>(ValueType)->getPointeeType();
+ }
+ }
-void SemaHLSL::handleSV_GroupIDAttr(Decl *D, const ParsedAttr &AL) {
- auto *VD = cast<ValueDecl>(D);
- if (!diagnoseInputIDType(VD->getType(), AL))
+#define CHECK_OUTPUT_FORBIDDEN(AL) \
----------------
llvm-beanz wrote:
This is very much not normal LLVM style to use a macro like this. I think the code is a lot easier to read if you expand the code in place.
https://github.com/llvm/llvm-project/pull/152537
More information about the cfe-commits
mailing list