r298976 - [OpenCL] Added parsing for OpenCL vector types.
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 29 03:26:05 PDT 2017
It seems like the following change causes the failures:
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 4dcdfbf..e1439d6 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -2379,10 +2427,13 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
}
// Parse the cast-expression that follows it next.
+ // isVectorLiteral = true will make sure we don't parse any
+ // Postfix expression yet
// TODO: For cast expression with CastTy.
Result = ParseCastExpression(/*isUnaryExpression=*/false,
/*isAddressOfOperand=*/false,
- /*isTypeCast=*/IsTypeCast);
+ /*isTypeCast=*/IsTypeCast,
+ /*isVectorLiteral=*/true);
Although it appears in the review as well, but did you intend to change this?
Just FYI, passing "make check-clang" is a minimal testing requirement for Clang changes. Could you, please, try to verify it for your future commits. ;)
Thanks!
Anastasia
From: cfe-commits [mailto:cfe-commits-bounces at lists.llvm.org] On Behalf Of Egor Churaev via cfe-commits
Sent: 29 March 2017 06:51
To: Dean Michael Berris
Cc: cfe-commits at lists.llvm.org
Subject: Re: r298976 - [OpenCL] Added parsing for OpenCL vector types.
I see it. I'm reverting this patch and I'll investigate why it has happend.
2017-03-29 8:43 GMT+03:00 Dean Michael Berris <dberris at google.com<mailto:dberris at google.com>>:
This seems to have broken multiple builds.
On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits <cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>> wrote:
Author: echuraev
Date: Wed Mar 29 00:08:18 2017
New Revision: 298976
URL: http://llvm.org/viewvc/llvm-project?rev=298976&view=rev
Log:
[OpenCL] Added parsing for OpenCL vector types.
Reviewers: cfe-commits, Anastasia
Reviewed By: Anastasia
Subscribers: yaxunl, bader
Differential Revision: https://reviews.llvm.org/D31183
Added:
cfe/trunk/test/Parser/vector-cast-define.cl<http://vector-cast-define.cl>
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseExpr.cpp
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976&r1=298975&r2=298976&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017
@@ -1449,10 +1449,12 @@ private:
ExprResult ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
bool &NotCastExpr,
- TypeCastState isTypeCast);
+ TypeCastState isTypeCast,
+ bool isVectorLiteral = false);
ExprResult ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand = false,
- TypeCastState isTypeCast = NotTypeCast);
+ TypeCastState isTypeCast = NotTypeCast,
+ bool isVectorLiteral = false);
/// Returns true if the next token cannot start an expression.
bool isNotExpressionStart();
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976&r1=298975&r2=298976&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017
@@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR
///
ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
- TypeCastState isTypeCast) {
+ TypeCastState isTypeCast,
+ bool isVectorLiteral) {
bool NotCastExpr;
ExprResult Res = ParseCastExpression(isUnaryExpression,
isAddressOfOperand,
NotCastExpr,
- isTypeCast);
+ isTypeCast,
+ isVectorLiteral);
if (NotCastExpr)
Diag(Tok, diag::err_expected_expression);
return Res;
@@ -694,7 +696,8 @@ class CastExpressionIdValidator : public
ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
bool isAddressOfOperand,
bool &NotCastExpr,
- TypeCastState isTypeCast) {
+ TypeCastState isTypeCast,
+ bool isVectorLiteral) {
ExprResult Res;
tok::TokenKind SavedKind = Tok.getKind();
NotCastExpr = false;
@@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b
Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/,
isTypeCast == IsTypeCast, CastTy, RParenLoc);
+ if (isVectorLiteral)
+ return Res;
+
switch (ParenExprType) {
case SimpleExpr: break; // Nothing else to do.
case CompoundStmt: break; // Nothing else to do.
@@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO
return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc);
}
+ if (Tok.is(tok::l_paren)) {
+ // This could be OpenCL vector Literals
+ if (getLangOpts().OpenCL)
+ {
+ TypeResult Ty;
+ {
+ InMessageExpressionRAIIObject InMessage(*this, false);
+ Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo);
+ }
+ if(Ty.isInvalid())
+ {
+ return ExprError();
+ }
+ QualType QT = Ty.get().get().getCanonicalType();
+ if (QT->isVectorType())
+ {
+ // We parsed '(' vector-type-name ')' followed by '('
+
+ // Parse the cast-expression that follows it next.
+ // isVectorLiteral = true will make sure we don't parse any
+ // Postfix expression yet
+ Result = ParseCastExpression(/*isUnaryExpression=*/false,
+ /*isAddressOfOperand=*/false,
+ /*isTypeCast=*/IsTypeCast,
+ /*isVectorLiteral=*/true);
+
+ if (!Result.isInvalid()) {
+ Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc,
+ DeclaratorInfo, CastTy,
+ RParenLoc, Result.get());
+ }
+
+ // After we performed the cast we can check for postfix-expr pieces.
+ if (!Result.isInvalid()) {
+ Result = ParsePostfixExpressionSuffix(Result);
+ }
+
+ return Result;
+ }
+ }
+ }
+
if (ExprType == CastExpr) {
// We parsed '(' type-name ')' and the thing after it wasn't a '{'.
@@ -2379,10 +2427,13 @@ Parser::ParseParenExpression(ParenParseO
}
// Parse the cast-expression that follows it next.
+ // isVectorLiteral = true will make sure we don't parse any
+ // Postfix expression yet
// TODO: For cast expression with CastTy.
Result = ParseCastExpression(/*isUnaryExpression=*/false,
/*isAddressOfOperand=*/false,
- /*isTypeCast=*/IsTypeCast);
+ /*isTypeCast=*/IsTypeCast,
+ /*isVectorLiteral=*/true);
if (!Result.isInvalid()) {
Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc,
DeclaratorInfo, CastTy,
Added: cfe/trunk/test/Parser/vector-cast-define.cl<http://vector-cast-define.cl>
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/vector-cast-define.cl?rev=298976&view=auto
==============================================================================
--- cfe/trunk/test/Parser/vector-cast-define.cl<http://vector-cast-define.cl> (added)
+++ cfe/trunk/test/Parser/vector-cast-define.cl<http://vector-cast-define.cl> Wed Mar 29 00:08:18 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// expected-no-diagnostics
+
+typedef int int3 __attribute__((ext_vector_type(3)));
+
+void test()
+{
+ int index = (int3)(1, 2, 3).x * (int3)(3, 2, 1).y;
+}
+
_______________________________________________
cfe-commits mailing list
cfe-commits at lists.llvm.org<mailto:cfe-commits at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
--
Best regards,
Egor Churaev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170329/188c0b56/attachment-0001.html>
More information about the cfe-commits
mailing list