<div dir="ltr">This seems to have broken multiple builds.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: echuraev<br class="gmail_msg">
Date: Wed Mar 29 00:08:18 2017<br class="gmail_msg">
New Revision: 298976<br class="gmail_msg">
<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=298976&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=298976&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
[OpenCL] Added parsing for OpenCL vector types.<br class="gmail_msg">
<br class="gmail_msg">
Reviewers: cfe-commits, Anastasia<br class="gmail_msg">
<br class="gmail_msg">
Reviewed By: Anastasia<br class="gmail_msg">
<br class="gmail_msg">
Subscribers: yaxunl, bader<br class="gmail_msg">
<br class="gmail_msg">
Differential Revision: <a href="https://reviews.llvm.org/D31183" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D31183</a><br class="gmail_msg">
<br class="gmail_msg">
Added:<br class="gmail_msg">
cfe/trunk/test/Parser/<a href="http://vector-cast-define.cl" rel="noreferrer" class="gmail_msg" target="_blank">vector-cast-define.cl</a><br class="gmail_msg">
Modified:<br class="gmail_msg">
cfe/trunk/include/clang/Parse/Parser.h<br class="gmail_msg">
cfe/trunk/lib/Parse/ParseExpr.cpp<br class="gmail_msg">
<br class="gmail_msg">
Modified: cfe/trunk/include/clang/Parse/Parser.h<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976&r1=298975&r2=298976&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976&r1=298975&r2=298976&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/trunk/include/clang/Parse/Parser.h (original)<br class="gmail_msg">
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017<br class="gmail_msg">
@@ -1449,10 +1449,12 @@ private:<br class="gmail_msg">
ExprResult ParseCastExpression(bool isUnaryExpression,<br class="gmail_msg">
bool isAddressOfOperand,<br class="gmail_msg">
bool &NotCastExpr,<br class="gmail_msg">
- TypeCastState isTypeCast);<br class="gmail_msg">
+ TypeCastState isTypeCast,<br class="gmail_msg">
+ bool isVectorLiteral = false);<br class="gmail_msg">
ExprResult ParseCastExpression(bool isUnaryExpression,<br class="gmail_msg">
bool isAddressOfOperand = false,<br class="gmail_msg">
- TypeCastState isTypeCast = NotTypeCast);<br class="gmail_msg">
+ TypeCastState isTypeCast = NotTypeCast,<br class="gmail_msg">
+ bool isVectorLiteral = false);<br class="gmail_msg">
<br class="gmail_msg">
/// Returns true if the next token cannot start an expression.<br class="gmail_msg">
bool isNotExpressionStart();<br class="gmail_msg">
<br class="gmail_msg">
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976&r1=298975&r2=298976&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976&r1=298975&r2=298976&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)<br class="gmail_msg">
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017<br class="gmail_msg">
@@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR<br class="gmail_msg">
///<br class="gmail_msg">
ExprResult Parser::ParseCastExpression(bool isUnaryExpression,<br class="gmail_msg">
bool isAddressOfOperand,<br class="gmail_msg">
- TypeCastState isTypeCast) {<br class="gmail_msg">
+ TypeCastState isTypeCast,<br class="gmail_msg">
+ bool isVectorLiteral) {<br class="gmail_msg">
bool NotCastExpr;<br class="gmail_msg">
ExprResult Res = ParseCastExpression(isUnaryExpression,<br class="gmail_msg">
isAddressOfOperand,<br class="gmail_msg">
NotCastExpr,<br class="gmail_msg">
- isTypeCast);<br class="gmail_msg">
+ isTypeCast,<br class="gmail_msg">
+ isVectorLiteral);<br class="gmail_msg">
if (NotCastExpr)<br class="gmail_msg">
Diag(Tok, diag::err_expected_expression);<br class="gmail_msg">
return Res;<br class="gmail_msg">
@@ -694,7 +696,8 @@ class CastExpressionIdValidator : public<br class="gmail_msg">
ExprResult Parser::ParseCastExpression(bool isUnaryExpression,<br class="gmail_msg">
bool isAddressOfOperand,<br class="gmail_msg">
bool &NotCastExpr,<br class="gmail_msg">
- TypeCastState isTypeCast) {<br class="gmail_msg">
+ TypeCastState isTypeCast,<br class="gmail_msg">
+ bool isVectorLiteral) {<br class="gmail_msg">
ExprResult Res;<br class="gmail_msg">
tok::TokenKind SavedKind = Tok.getKind();<br class="gmail_msg">
NotCastExpr = false;<br class="gmail_msg">
@@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b<br class="gmail_msg">
Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,<br class="gmail_msg">
isTypeCast == IsTypeCast, CastTy, RParenLoc);<br class="gmail_msg">
<br class="gmail_msg">
+ if (isVectorLiteral)<br class="gmail_msg">
+ return Res;<br class="gmail_msg">
+<br class="gmail_msg">
switch (ParenExprType) {<br class="gmail_msg">
case SimpleExpr: break; // Nothing else to do.<br class="gmail_msg">
case CompoundStmt: break; // Nothing else to do.<br class="gmail_msg">
@@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO<br class="gmail_msg">
return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc);<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+ if (Tok.is(tok::l_paren)) {<br class="gmail_msg">
+ // This could be OpenCL vector Literals<br class="gmail_msg">
+ if (getLangOpts().OpenCL)<br class="gmail_msg">
+ {<br class="gmail_msg">
+ TypeResult Ty;<br class="gmail_msg">
+ {<br class="gmail_msg">
+ InMessageExpressionRAIIObject InMessage(*this, false);<br class="gmail_msg">
+ Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);<br class="gmail_msg">
+ }<br class="gmail_msg">
+ if(Ty.isInvalid())<br class="gmail_msg">
+ {<br class="gmail_msg">
+ return ExprError();<br class="gmail_msg">
+ }<br class="gmail_msg">
+ QualType QT = Ty.get().get().getCanonicalType();<br class="gmail_msg">
+ if (QT->isVectorType())<br class="gmail_msg">
+ {<br class="gmail_msg">
+ // We parsed '(' vector-type-name ')' followed by '('<br class="gmail_msg">
+<br class="gmail_msg">
+ // Parse the cast-expression that follows it next.<br class="gmail_msg">
+ // isVectorLiteral = true will make sure we don't parse any<br class="gmail_msg">
+ // Postfix expression yet<br class="gmail_msg">
+ Result = ParseCastExpression(/*isUnaryExpression=*/false,<br class="gmail_msg">
+ /*isAddressOfOperand=*/false,<br class="gmail_msg">
+ /*isTypeCast=*/IsTypeCast,<br class="gmail_msg">
+ /*isVectorLiteral=*/true);<br class="gmail_msg">
+<br class="gmail_msg">
+ if (!Result.isInvalid()) {<br class="gmail_msg">
+ Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc,<br class="gmail_msg">
+ DeclaratorInfo, CastTy,<br class="gmail_msg">
+ RParenLoc, Result.get());<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ // After we performed the cast we can check for postfix-expr pieces.<br class="gmail_msg">
+ if (!Result.isInvalid()) {<br class="gmail_msg">
+ Result = ParsePostfixExpressionSuffix(Result);<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
+ return Result;<br class="gmail_msg">
+ }<br class="gmail_msg">
+ }<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
if (ExprType == CastExpr) {<br class="gmail_msg">
// We parsed '(' type-name ')' and the thing after it wasn't a '{'.<br class="gmail_msg">
<br class="gmail_msg">
@@ -2379,10 +2427,13 @@ Parser::ParseParenExpression(ParenParseO<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
// Parse the cast-expression that follows it next.<br class="gmail_msg">
+ // isVectorLiteral = true will make sure we don't parse any<br class="gmail_msg">
+ // Postfix expression yet<br class="gmail_msg">
// TODO: For cast expression with CastTy.<br class="gmail_msg">
Result = ParseCastExpression(/*isUnaryExpression=*/false,<br class="gmail_msg">
/*isAddressOfOperand=*/false,<br class="gmail_msg">
- /*isTypeCast=*/IsTypeCast);<br class="gmail_msg">
+ /*isTypeCast=*/IsTypeCast,<br class="gmail_msg">
+ /*isVectorLiteral=*/true);<br class="gmail_msg">
if (!Result.isInvalid()) {<br class="gmail_msg">
Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc,<br class="gmail_msg">
DeclaratorInfo, CastTy,<br class="gmail_msg">
<br class="gmail_msg">
Added: cfe/trunk/test/Parser/<a href="http://vector-cast-define.cl" rel="noreferrer" class="gmail_msg" target="_blank">vector-cast-define.cl</a><br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/vector-cast-define.cl?rev=298976&view=auto" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/vector-cast-define.cl?rev=298976&view=auto</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- cfe/trunk/test/Parser/<a href="http://vector-cast-define.cl" rel="noreferrer" class="gmail_msg" target="_blank">vector-cast-define.cl</a> (added)<br class="gmail_msg">
+++ cfe/trunk/test/Parser/<a href="http://vector-cast-define.cl" rel="noreferrer" class="gmail_msg" target="_blank">vector-cast-define.cl</a> Wed Mar 29 00:08:18 2017<br class="gmail_msg">
@@ -0,0 +1,10 @@<br class="gmail_msg">
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only<br class="gmail_msg">
+// expected-no-diagnostics<br class="gmail_msg">
+<br class="gmail_msg">
+typedef int int3 __attribute__((ext_vector_type(3)));<br class="gmail_msg">
+<br class="gmail_msg">
+void test()<br class="gmail_msg">
+{<br class="gmail_msg">
+ int index = (int3)(1, 2, 3).x * (int3)(3, 2, 1).y;<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
cfe-commits mailing list<br class="gmail_msg">
<a href="mailto:cfe-commits@lists.llvm.org" class="gmail_msg" target="_blank">cfe-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="gmail_msg">
</blockquote></div>