michele.scandale created this revision.
michele.scandale added reviewers: rsmith, doug.gregor, rjmccall.
Herald added a project: All.
michele.scandale requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131698

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaTemplate/instantiate-clang.cpp


Index: clang/test/SemaTemplate/instantiate-clang.cpp
===================================================================
--- clang/test/SemaTemplate/instantiate-clang.cpp
+++ clang/test/SemaTemplate/instantiate-clang.cpp
@@ -18,7 +18,15 @@
 template struct ExtVectorAccess0<double2>;
 template struct ExtVectorAccess0<double4>;
 
-typedef __attribute__(( ext_vector_type(2) )) double double2;
+template<typename T>
+struct ExtVectorAccess1 {
+  void f(T *v1, double4 *v2) {
+    v1->xy = v2->yx;
+  }
+};
+
+template struct ExtVectorAccess1<double2>;
+template struct ExtVectorAccess1<double4>;
 
 template<typename T, typename U, int N, int M>
 struct ShuffleVector0 {
Index: clang/lib/Sema/TreeTransform.h
===================================================================
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -2779,15 +2779,15 @@
   ///
   /// By default, performs semantic analysis to build the new expression.
   /// Subclasses may override this routine to provide different behavior.
-  ExprResult RebuildExtVectorElementExpr(Expr *Base,
-                                               SourceLocation OpLoc,
-                                               SourceLocation AccessorLoc,
-                                               IdentifierInfo &Accessor) {
+  ExprResult RebuildExtVectorElementExpr(Expr *Base, SourceLocation OpLoc,
+                                         bool IsArrow,
+                                         SourceLocation AccessorLoc,
+                                         IdentifierInfo &Accessor) {
 
     CXXScopeSpec SS;
     DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
     return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
-                                              OpLoc, /*IsArrow*/ false,
+                                              OpLoc, IsArrow,
                                               SS, SourceLocation(),
                                               /*FirstQualifierInScope*/ 
nullptr,
                                               NameInfo,
@@ -11385,9 +11385,9 @@
   // FIXME: Bad source location
   SourceLocation FakeOperatorLoc =
       SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
-  return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
-                                                  E->getAccessorLoc(),
-                                                  E->getAccessor());
+  return getDerived().RebuildExtVectorElementExpr(
+      Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
+      E->getAccessor());
 }
 
 template<typename Derived>


Index: clang/test/SemaTemplate/instantiate-clang.cpp
===================================================================
--- clang/test/SemaTemplate/instantiate-clang.cpp
+++ clang/test/SemaTemplate/instantiate-clang.cpp
@@ -18,7 +18,15 @@
 template struct ExtVectorAccess0<double2>;
 template struct ExtVectorAccess0<double4>;
 
-typedef __attribute__(( ext_vector_type(2) )) double double2;
+template<typename T>
+struct ExtVectorAccess1 {
+  void f(T *v1, double4 *v2) {
+    v1->xy = v2->yx;
+  }
+};
+
+template struct ExtVectorAccess1<double2>;
+template struct ExtVectorAccess1<double4>;
 
 template<typename T, typename U, int N, int M>
 struct ShuffleVector0 {
Index: clang/lib/Sema/TreeTransform.h
===================================================================
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -2779,15 +2779,15 @@
   ///
   /// By default, performs semantic analysis to build the new expression.
   /// Subclasses may override this routine to provide different behavior.
-  ExprResult RebuildExtVectorElementExpr(Expr *Base,
-                                               SourceLocation OpLoc,
-                                               SourceLocation AccessorLoc,
-                                               IdentifierInfo &Accessor) {
+  ExprResult RebuildExtVectorElementExpr(Expr *Base, SourceLocation OpLoc,
+                                         bool IsArrow,
+                                         SourceLocation AccessorLoc,
+                                         IdentifierInfo &Accessor) {
 
     CXXScopeSpec SS;
     DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
     return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
-                                              OpLoc, /*IsArrow*/ false,
+                                              OpLoc, IsArrow,
                                               SS, SourceLocation(),
                                               /*FirstQualifierInScope*/ nullptr,
                                               NameInfo,
@@ -11385,9 +11385,9 @@
   // FIXME: Bad source location
   SourceLocation FakeOperatorLoc =
       SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
-  return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
-                                                  E->getAccessorLoc(),
-                                                  E->getAccessor());
+  return getDerived().RebuildExtVectorElementExpr(
+      Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
+      E->getAccessor());
 }
 
 template<typename Derived>
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D131698: [Sema] F... Michele Scandale via Phabricator via cfe-commits

Reply via email to