diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -7658,24 +7658,8 @@ return; } - Expr *SizeExpr; - // Special case where the argument is a template id. - if (Attr.isArgIdent(0)) { - CXXScopeSpec SS; - SourceLocation TemplateKWLoc; - UnqualifiedId Id; - Id.setIdentifier(Attr.getArgAsIdent(0)->Ident, Attr.getLoc()); - - ExprResult Size = S.ActOnIdExpression(S.getCurScope(), SS, TemplateKWLoc, - Id, /*HasTrailingLParen=*/false, - /*IsAddressOfOperand=*/false); - - if (Size.isInvalid()) - return; - SizeExpr = Size.get(); - } else { - SizeExpr = Attr.getArgAsExpr(0); - } + assert(Attr.isArgExpr(0) && "Argument to should be an expression"); + Expr *SizeExpr = Attr.getArgAsExpr(0); QualType T = S.BuildVectorType(CurType, SizeExpr, Attr.getLoc()); if (!T.isNull()) @@ -7695,25 +7679,8 @@ return; } - Expr *sizeExpr; - - // Special case where the argument is a template id. - if (Attr.isArgIdent(0)) { - CXXScopeSpec SS; - SourceLocation TemplateKWLoc; - UnqualifiedId id; - id.setIdentifier(Attr.getArgAsIdent(0)->Ident, Attr.getLoc()); - - ExprResult Size = S.ActOnIdExpression(S.getCurScope(), SS, TemplateKWLoc, - id, /*HasTrailingLParen=*/false, - /*IsAddressOfOperand=*/false); - if (Size.isInvalid()) - return; - - sizeExpr = Size.get(); - } else { - sizeExpr = Attr.getArgAsExpr(0); - } + assert(Attr.isArgExpr(0) && "Argument to should be an expression"); + Expr *sizeExpr = Attr.getArgAsExpr(0); // Create the vector type. QualType T = S.BuildExtVectorType(CurType, sizeExpr, Attr.getLoc()); @@ -7991,44 +7958,13 @@ Expr *RowsExpr = nullptr; Expr *ColsExpr = nullptr; - // TODO: Refactor parameter extraction into separate function // Get the number of rows - if (Attr.isArgIdent(0)) { - CXXScopeSpec SS; - SourceLocation TemplateKeywordLoc; - UnqualifiedId id; - id.setIdentifier(Attr.getArgAsIdent(0)->Ident, Attr.getLoc()); - ExprResult Rows = S.ActOnIdExpression(S.getCurScope(), SS, - TemplateKeywordLoc, id, false, false); - - if (Rows.isInvalid()) - // TODO: maybe a good error message would be nice here - return; - RowsExpr = Rows.get(); - } else { - assert(Attr.isArgExpr(0) && - "Argument to should either be an identity or expression"); - RowsExpr = Attr.getArgAsExpr(0); - } + assert(Attr.isArgExpr(0) && "Argument should be an expression"); + RowsExpr = Attr.getArgAsExpr(0); // Get the number of columns - if (Attr.isArgIdent(1)) { - CXXScopeSpec SS; - SourceLocation TemplateKeywordLoc; - UnqualifiedId id; - id.setIdentifier(Attr.getArgAsIdent(1)->Ident, Attr.getLoc()); - ExprResult Columns = S.ActOnIdExpression( - S.getCurScope(), SS, TemplateKeywordLoc, id, false, false); - - if (Columns.isInvalid()) - // TODO: a good error message would be nice here - return; - RowsExpr = Columns.get(); - } else { - assert(Attr.isArgExpr(1) && - "Argument to should either be an identity or expression"); - ColsExpr = Attr.getArgAsExpr(1); - } + assert(Attr.isArgExpr(1) && "Argument to should be an expression"); + ColsExpr = Attr.getArgAsExpr(1); // Create the matrix type. QualType T = S.BuildMatrixType(CurType, RowsExpr, ColsExpr, Attr.getLoc());