================
@@ -4620,6 +4620,205 @@ bool SemaHLSL::transformInitList(const
InitializedEntity &Entity,
return true;
}
+QualType SemaHLSL::CheckMatrixComponent(Sema &S, QualType baseType,
+ ExprValueKind &VK, SourceLocation
OpLoc,
+ const IdentifierInfo *CompName,
+ SourceLocation CompLoc) {
+ const auto *MT = baseType->getAs<ConstantMatrixType>();
+ StringRef AccessorName = CompName->getName();
+ assert(MT &&
+ "CheckMatrixComponent is intended to be used on ConstantMatrixType");
+ assert(!AccessorName.empty() && "Matrix Accessor must have a name");
+
+ unsigned Rows = MT->getNumRows();
+ unsigned Cols = MT->getNumColumns();
+ bool IsZeroBasedAccessor = false;
+ unsigned ChunkLen = 0;
+ if (AccessorName.size() < 2) {
+ const char Expected[] = "length 4 for zero based: \'_mRC\' or length 3 for
"
+ "one-based: \'_RC\' accessor";
+ S.Diag(OpLoc, diag::err_builtin_matrix_invalid_member)
+ << CompName->getName() << StringRef(Expected, sizeof(Expected) - 1)
+ << SourceRange(CompLoc);
----------------
hekota wrote:
This style of error reporting seems to be used a lot in here. Consider making a
helper function `reportMatrixInvalidMember(Sema &S, StringRef Name, StringRef
Expected, SourceLocation CompLoc);`
Then instead of declaring `Expected` at each location and making a `StringRef`
out of it, it could be changed to `reportMatrixInvalidMember(S, AccessorName,
"length 4 for zero based...", CompLoc);`.
https://github.com/llvm/llvm-project/pull/171225
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits