[clang] c49cde6 - [Sema] Fix `ExtVectorElementExpr` tree transform for the `isArrow` case.
Michele Scandale via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 11 13:29:32 PDT 2022
Author: Michele Scandale
Date: 2022-10-11T13:29:20-07:00
New Revision: c49cde6467f9bf200640db763152a9dc7f009520
URL: https://github.com/llvm/llvm-project/commit/c49cde6467f9bf200640db763152a9dc7f009520
DIFF: https://github.com/llvm/llvm-project/commit/c49cde6467f9bf200640db763152a9dc7f009520.diff
LOG: [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
Added:
Modified:
clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/instantiate-clang.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 82b6cfacf46b6..d772d7f69d80f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -2814,20 +2814,18 @@ class TreeTransform {
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide
diff erent 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,
- SS, SourceLocation(),
- /*FirstQualifierInScope*/ nullptr,
- NameInfo,
- /* TemplateArgs */ nullptr,
- /*S*/ nullptr);
+ return getSema().BuildMemberReferenceExpr(
+ Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
+ /*FirstQualifierInScope*/ nullptr, NameInfo,
+ /* TemplateArgs */ nullptr,
+ /*S*/ nullptr);
}
/// Build a new initializer list expression.
@@ -11424,9 +11422,9 @@ TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
// 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>
diff --git a/clang/test/SemaTemplate/instantiate-clang.cpp b/clang/test/SemaTemplate/instantiate-clang.cpp
index 34d68c4e59fd5..18b428834b0a2 100644
--- a/clang/test/SemaTemplate/instantiate-clang.cpp
+++ b/clang/test/SemaTemplate/instantiate-clang.cpp
@@ -18,7 +18,15 @@ struct ExtVectorAccess0 {
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 {
More information about the cfe-commits
mailing list