[clang] 574a77a - [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.
Volodymyr Sapsai via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 17 13:33:58 PST 2023
Author: Volodymyr Sapsai
Date: 2023-01-17T15:33:36-06:00
New Revision: 574a77ae85451adc5e2dd9e73652c62bf18eed8d
URL: https://github.com/llvm/llvm-project/commit/574a77ae85451adc5e2dd9e73652c62bf18eed8d
DIFF: https://github.com/llvm/llvm-project/commit/574a77ae85451adc5e2dd9e73652c62bf18eed8d.diff
LOG: [clang][sema][Matrix] Move code from try-cast to `TypeLocVisitor`. NFC intended.
`MatrixTypeLoc` is not "sugar" `TypeLoc` and doesn't require to use the
underlying `TypeLoc` instead.
Differential Revision: https://reviews.llvm.org/D141422
Added:
Modified:
clang/lib/Sema/SemaType.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 826a9ef954ee..eb61a5fe4fba 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -6053,6 +6053,21 @@ static void fillAttributedTypeLoc(AttributedTypeLoc TL,
TL.setAttr(State.takeAttrForAttributedType(TL.getTypePtr()));
}
+static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
+ const ParsedAttributesView &Attrs) {
+ for (const ParsedAttr &AL : 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<TypeSpecLocFiller> {
Sema &SemaRef;
@@ -6419,6 +6434,9 @@ namespace {
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 @@ fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL,
"no address_space attribute found at the expected location!");
}
-static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
- const ParsedAttributesView &Attrs) {
- for (const ParsedAttr &AL : 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 @@ GetTypeSourceInfoForDeclarator(TypeProcessingState &State,
CurrTL = TL.getPointeeTypeLoc().getUnqualifiedLoc();
}
- if (MatrixTypeLoc TL = CurrTL.getAs<MatrixTypeLoc>())
- fillMatrixTypeLoc(TL, D.getTypeObject(i).getAttrs());
-
// FIXME: Ordering here?
while (AdjustedTypeLoc TL = CurrTL.getAs<AdjustedTypeLoc>())
CurrTL = TL.getNextTypeLoc().getUnqualifiedLoc();
More information about the cfe-commits
mailing list