================
@@ -5311,6 +5311,109 @@ TEST(Hover, FunctionParameters) {
   }
 }
 
+TEST(Hover, HLSLVectorAndMatrixSwizzle) {
+  struct {
+    const char *const Code;
+    const std::function<void(HoverInfo &)> ExpectedBuilder;
+  } Cases[] = {
+      {
+          R"cpp(
+            typedef float float3 __attribute__((ext_vector_type(3)));
+            void main() {
+              float3 v;
+              float3 s = v.^[[xyz]];
+            }
+          )cpp",
+          [](HoverInfo &HI) {
+            HI.Name = "xyz";
+            HI.Type = "float3";
+          }},
+      {
+          R"cpp(
+            typedef float float3 __attribute__((ext_vector_type(3)));
+            typedef float float2 __attribute__((ext_vector_type(2)));
+            void main() {
+              float3 v;
+              float2 s = v.^[[xy]];
+            }
+          )cpp",
+          [](HoverInfo &HI) {
+            HI.Name = "xy";
+            HI.Type = "float2";
+          }},
+      {
+          R"cpp(
+            typedef float float4x4 __attribute__((matrix_type(4, 4)));
+            void main() {
+              float4x4 m;
+              float e = m.^[[_m00]];
+            }
+          )cpp",
+          [](HoverInfo &HI) {
+            HI.Name = "_m00";
+            HI.Type = "float";
+          }},
+  };
+
+  for (const auto &Case : Cases) {
+    SCOPED_TRACE(Case.Code);
+    Annotations T(Case.Code);
+    TestTU TU = TestTU::withCode(T.code());
+    TU.Filename = "TestTU.hlsl";
+    TU.ExtraArgs.push_back("-x");
+    TU.ExtraArgs.push_back("hlsl");
+    TU.ExtraArgs.push_back("-fenable-matrix");
+    TU.ExtraArgs.push_back("--target=dxil-pc-shadermodel6.3-library");
+    auto AST = TU.build();
+    auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+    ASSERT_TRUE(H);
+    HoverInfo Expected;
+    Expected.SymRange = T.range();
+    Case.ExpectedBuilder(Expected);
+    SCOPED_TRACE(H->present(MarkupKind::PlainText));
+    EXPECT_EQ(H->Name, Expected.Name);
+    EXPECT_EQ(H->Type, Expected.Type);
+    EXPECT_EQ(H->SymRange, Expected.SymRange);
+  }
+}
+
+TEST(Hover, HLSLInvalidMatrixSwizzleNoCrash) {
----------------
bob80905 wrote:

Would that not count as "matrix element access" in the PR title?
Or maybe that is referring to the `._m22` operation/method.
Regardless, this is no longer a blocking comment, I imagine there's an issue 
tracking support for the matrix `operator[]` somewhere.

https://github.com/llvm/llvm-project/pull/212741
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to