Skip to content

Commit c49cde6

Browse files
[Sema] Fix ExtVectorElementExpr tree transform for the isArrow case.
Make sure we propagate the value for `IsArrow` to `RebuildExtVectorElementExpr` in order to be able to handle correctly vector component accesses where the base value is a pointer. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D131698
1 parent 52c7ffb commit c49cde6

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

clang/lib/Sema/TreeTransform.h

+12-14
Original file line numberDiff line numberDiff line change
@@ -2814,20 +2814,18 @@ class TreeTransform {
28142814
///
28152815
/// By default, performs semantic analysis to build the new expression.
28162816
/// Subclasses may override this routine to provide different behavior.
2817-
ExprResult RebuildExtVectorElementExpr(Expr *Base,
2818-
SourceLocation OpLoc,
2819-
SourceLocation AccessorLoc,
2820-
IdentifierInfo &Accessor) {
2817+
ExprResult RebuildExtVectorElementExpr(Expr *Base, SourceLocation OpLoc,
2818+
bool IsArrow,
2819+
SourceLocation AccessorLoc,
2820+
IdentifierInfo &Accessor) {
28212821

28222822
CXXScopeSpec SS;
28232823
DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
2824-
return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
2825-
OpLoc, /*IsArrow*/ false,
2826-
SS, SourceLocation(),
2827-
/*FirstQualifierInScope*/ nullptr,
2828-
NameInfo,
2829-
/* TemplateArgs */ nullptr,
2830-
/*S*/ nullptr);
2824+
return getSema().BuildMemberReferenceExpr(
2825+
Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
2826+
/*FirstQualifierInScope*/ nullptr, NameInfo,
2827+
/* TemplateArgs */ nullptr,
2828+
/*S*/ nullptr);
28312829
}
28322830

28332831
/// Build a new initializer list expression.
@@ -11424,9 +11422,9 @@ TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
1142411422
// FIXME: Bad source location
1142511423
SourceLocation FakeOperatorLoc =
1142611424
SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
11427-
return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
11428-
E->getAccessorLoc(),
11429-
E->getAccessor());
11425+
return getDerived().RebuildExtVectorElementExpr(
11426+
Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
11427+
E->getAccessor());
1143011428
}
1143111429

1143211430
template<typename Derived>

clang/test/SemaTemplate/instantiate-clang.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ struct ExtVectorAccess0 {
1818
template struct ExtVectorAccess0<double2>;
1919
template struct ExtVectorAccess0<double4>;
2020

21-
typedef __attribute__(( ext_vector_type(2) )) double double2;
21+
template<typename T>
22+
struct ExtVectorAccess1 {
23+
void f(T *v1, double4 *v2) {
24+
v1->xy = v2->yx;
25+
}
26+
};
27+
28+
template struct ExtVectorAccess1<double2>;
29+
template struct ExtVectorAccess1<double4>;
2230

2331
template<typename T, typename U, int N, int M>
2432
struct ShuffleVector0 {

0 commit comments

Comments
 (0)