|
@@ -9888,10 +9888,13 @@ static void ValidateAttributeOnSwitchOrIf(Sema& S, Stmt* St, const AttributeList
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static StringRef ValidateAttributeStringArg(Sema& S, const AttributeList &A, _In_opt_z_ const char* values)
|
|
|
+static StringRef ValidateAttributeStringArg(Sema& S, const AttributeList &A, _In_opt_z_ const char* values, unsigned index = 0)
|
|
|
{
|
|
|
// values is an optional comma-separated list of potential values.
|
|
|
- Expr* E = A.getArgAsExpr(0);
|
|
|
+ if (A.getNumArgs() <= index)
|
|
|
+ return StringRef();
|
|
|
+
|
|
|
+ Expr* E = A.getArgAsExpr(index);
|
|
|
if (E->isTypeDependent() || E->isValueDependent() || E->getStmtClass() != Stmt::StringLiteralClass)
|
|
|
{
|
|
|
S.Diag(E->getLocStart(), diag::err_hlsl_attribute_expects_string_literal)
|
|
@@ -10150,9 +10153,14 @@ void hlsl::HandleDeclAttributeForHLSL(Sema &S, Decl *D, const AttributeList &A,
|
|
|
A.getAttributeSpellingListIndex());
|
|
|
break;
|
|
|
case AttributeList::AT_HLSLMaxVertexCount:
|
|
|
- declAttr = ::new (S.Context) HLSLMaxVertexCountAttr(A.getRange(), S.Context,
|
|
|
- ValidateAttributeIntArg(S, A), A.getAttributeSpellingListIndex());
|
|
|
- break;
|
|
|
+ declAttr = ::new (S.Context) HLSLMaxVertexCountAttr(A.getRange(), S.Context,
|
|
|
+ ValidateAttributeIntArg(S, A), A.getAttributeSpellingListIndex());
|
|
|
+ break;
|
|
|
+ case AttributeList::AT_HLSLExperimental:
|
|
|
+ declAttr = ::new (S.Context) HLSLExperimentalAttr(A.getRange(), S.Context,
|
|
|
+ ValidateAttributeStringArg(S, A, nullptr, 0), ValidateAttributeStringArg(S, A, nullptr, 1),
|
|
|
+ A.getAttributeSpellingListIndex());
|
|
|
+ break;
|
|
|
default:
|
|
|
Handled = false;
|
|
|
break; // SPIRV Change: was return;
|
|
@@ -11210,7 +11218,16 @@ void hlsl::CustomPrintHLSLAttr(const clang::Attr *A, llvm::raw_ostream &Out, con
|
|
|
Out << "[shader(\"" << ACast->getStage() << "\")]\n";
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ case clang::attr::HLSLExperimental:
|
|
|
+ {
|
|
|
+ Attr * noconst = const_cast<Attr*>(A);
|
|
|
+ HLSLExperimentalAttr *ACast = static_cast<HLSLExperimentalAttr*>(noconst);
|
|
|
+ Indent(Indentation, Out);
|
|
|
+ Out << "[experimental(\"" << ACast->getName() << "\", \"" << ACast->getValue() << "\")]\n";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
case clang::attr::HLSLMaxVertexCount:
|
|
|
{
|
|
|
Attr * noconst = const_cast<Attr*>(A);
|