[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review, Florian!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141422/new/

https://reviews.llvm.org/D141422

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-17 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG574a77ae8545: [clang][sema][Matrix] Move code from try-cast 
to `TypeLocVisitor`. NFC intended. (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141422/new/

https://reviews.llvm.org/D141422

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6053,6 +6053,21 @@
   TL.setAttr(State.takeAttrForAttributedType(TL.getTypePtr()));
 }
 
+static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
+  const ParsedAttributesView ) {
+  for (const ParsedAttr  : Attrs) {
+if (AL.getKind() == ParsedAttr::AT_MatrixType) {
+  MTL.setAttrNameLoc(AL.getLoc());
+  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
+  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
+  MTL.setAttrOperandParensRange(SourceRange());
+  return;
+}
+  }
+
+  llvm_unreachable("no matrix_type attribute found at the expected location!");
+}
+
 namespace {
   class TypeSpecLocFiller : public TypeLocVisitor {
 Sema 
@@ -6419,6 +6434,9 @@
 VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
   TL.setNameLoc(Chunk.Loc);
 }
+void VisitMatrixTypeLoc(MatrixTypeLoc TL) {
+  fillMatrixTypeLoc(TL, Chunk.getAttrs());
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");
@@ -6466,21 +6484,6 @@
   "no address_space attribute found at the expected location!");
 }
 
-static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
-  const ParsedAttributesView ) {
-  for (const ParsedAttr  : Attrs) {
-if (AL.getKind() == ParsedAttr::AT_MatrixType) {
-  MTL.setAttrNameLoc(AL.getLoc());
-  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
-  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
-  MTL.setAttrOperandParensRange(SourceRange());
-  return;
-}
-  }
-
-  llvm_unreachable("no matrix_type attribute found at the expected location!");
-}
-
 /// Create and instantiate a TypeSourceInfo with type source information.
 ///
 /// \param T QualType referring to the type as written in source code.
@@ -6532,9 +6535,6 @@
   CurrTL = TL.getPointeeTypeLoc().getUnqualifiedLoc();
 }
 
-if (MatrixTypeLoc TL = CurrTL.getAs())
-  fillMatrixTypeLoc(TL, D.getTypeObject(i).getAttrs());
-
 // FIXME: Ordering here?
 while (AdjustedTypeLoc TL = CurrTL.getAs())
   CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc();


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6053,6 +6053,21 @@
   TL.setAttr(State.takeAttrForAttributedType(TL.getTypePtr()));
 }
 
+static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
+  const ParsedAttributesView ) {
+  for (const ParsedAttr  : Attrs) {
+if (AL.getKind() == ParsedAttr::AT_MatrixType) {
+  MTL.setAttrNameLoc(AL.getLoc());
+  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
+  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
+  MTL.setAttrOperandParensRange(SourceRange());
+  return;
+}
+  }
+
+  llvm_unreachable("no matrix_type attribute found at the expected location!");
+}
+
 namespace {
   class TypeSpecLocFiller : public TypeLocVisitor {
 Sema 
@@ -6419,6 +6434,9 @@
 VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
   TL.setNameLoc(Chunk.Loc);
 }
+void VisitMatrixTypeLoc(MatrixTypeLoc TL) {
+  fillMatrixTypeLoc(TL, Chunk.getAttrs());
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");
@@ -6466,21 +6484,6 @@
   "no address_space attribute found at the expected location!");
 }
 
-static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
-  const ParsedAttributesView ) {
-  for (const ParsedAttr  : Attrs) {
-if (AL.getKind() == ParsedAttr::AT_MatrixType) {
-  MTL.setAttrNameLoc(AL.getLoc());
-  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
-  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
-  MTL.setAttrOperandParensRange(SourceRange());
-  return;
-}
-  }
-
-  llvm_unreachable("no matrix_type attribute found at the expected location!");
-}
-
 /// Create and instantiate a TypeSourceInfo with type source information.
 ///
 /// \param T QualType referring to the type as written in source code.
@@ -6532,9 +6535,6 @@
   CurrTL = TL.getPointeeTypeLoc().getUnqualifiedLoc();
 }
 
-if (MatrixTypeLoc TL = CurrTL.getAs())
-  fillMatrixTypeLoc(TL, D.getTypeObject(i).getAttrs());
-
 // FIXME: Ordering here?
 while (AdjustedTypeLoc TL = CurrTL.getAs())
   CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc();

[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-17 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM ,thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141422/new/

https://reviews.llvm.org/D141422

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141422/new/

https://reviews.llvm.org/D141422

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Doing this minor clean-up for D141424 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141422/new/

https://reviews.llvm.org/D141422

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141422: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.

2023-01-10 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added a reviewer: fhahn.
Herald added subscribers: StephenFan, tschuett, ributzka.
Herald added a project: All.
vsapsai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`MatrixTypeLoc` is not "sugar" `TypeLoc` and doesn't require to use the
underlying `TypeLoc` instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141422

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6049,6 +6049,21 @@
   TL.setAttr(State.takeAttrForAttributedType(TL.getTypePtr()));
 }
 
+static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
+  const ParsedAttributesView ) {
+  for (const ParsedAttr  : Attrs) {
+if (AL.getKind() == ParsedAttr::AT_MatrixType) {
+  MTL.setAttrNameLoc(AL.getLoc());
+  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
+  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
+  MTL.setAttrOperandParensRange(SourceRange());
+  return;
+}
+  }
+
+  llvm_unreachable("no matrix_type attribute found at the expected location!");
+}
+
 namespace {
   class TypeSpecLocFiller : public TypeLocVisitor {
 Sema 
@@ -6415,6 +6430,9 @@
 VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
   TL.setNameLoc(Chunk.Loc);
 }
+void VisitMatrixTypeLoc(MatrixTypeLoc TL) {
+  fillMatrixTypeLoc(TL, Chunk.getAttrs());
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");
@@ -6462,21 +6480,6 @@
   "no address_space attribute found at the expected location!");
 }
 
-static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
-  const ParsedAttributesView ) {
-  for (const ParsedAttr  : Attrs) {
-if (AL.getKind() == ParsedAttr::AT_MatrixType) {
-  MTL.setAttrNameLoc(AL.getLoc());
-  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
-  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
-  MTL.setAttrOperandParensRange(SourceRange());
-  return;
-}
-  }
-
-  llvm_unreachable("no matrix_type attribute found at the expected location!");
-}
-
 /// Create and instantiate a TypeSourceInfo with type source information.
 ///
 /// \param T QualType referring to the type as written in source code.
@@ -6528,9 +6531,6 @@
   CurrTL = TL.getPointeeTypeLoc().getUnqualifiedLoc();
 }
 
-if (MatrixTypeLoc TL = CurrTL.getAs())
-  fillMatrixTypeLoc(TL, D.getTypeObject(i).getAttrs());
-
 // FIXME: Ordering here?
 while (AdjustedTypeLoc TL = CurrTL.getAs())
   CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc();


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -6049,6 +6049,21 @@
   TL.setAttr(State.takeAttrForAttributedType(TL.getTypePtr()));
 }
 
+static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
+  const ParsedAttributesView ) {
+  for (const ParsedAttr  : Attrs) {
+if (AL.getKind() == ParsedAttr::AT_MatrixType) {
+  MTL.setAttrNameLoc(AL.getLoc());
+  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
+  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
+  MTL.setAttrOperandParensRange(SourceRange());
+  return;
+}
+  }
+
+  llvm_unreachable("no matrix_type attribute found at the expected location!");
+}
+
 namespace {
   class TypeSpecLocFiller : public TypeLocVisitor {
 Sema 
@@ -6415,6 +6430,9 @@
 VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
   TL.setNameLoc(Chunk.Loc);
 }
+void VisitMatrixTypeLoc(MatrixTypeLoc TL) {
+  fillMatrixTypeLoc(TL, Chunk.getAttrs());
+}
 
 void VisitTypeLoc(TypeLoc TL) {
   llvm_unreachable("unsupported TypeLoc kind in declarator!");
@@ -6462,21 +6480,6 @@
   "no address_space attribute found at the expected location!");
 }
 
-static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
-  const ParsedAttributesView ) {
-  for (const ParsedAttr  : Attrs) {
-if (AL.getKind() == ParsedAttr::AT_MatrixType) {
-  MTL.setAttrNameLoc(AL.getLoc());
-  MTL.setAttrRowOperand(AL.getArgAsExpr(0));
-  MTL.setAttrColumnOperand(AL.getArgAsExpr(1));
-  MTL.setAttrOperandParensRange(SourceRange());
-  return;
-}
-  }
-
-  llvm_unreachable("no matrix_type attribute found at the expected location!");
-}
-
 /// Create and instantiate a TypeSourceInfo with type source information.
 ///
 /// \param T QualType referring to the type as written in source code.
@@ -6528,9 +6531,6 @@
   CurrTL = TL.getPointeeTypeLoc().getUnqualifiedLoc();
 }
 
-if (MatrixTypeLoc TL = CurrTL.getAs())
-  fillMatrixTypeLoc(TL, D.getTypeObject(i).getAttrs());
-
 // FIXME: Ordering here?
 while