summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/Expr.cpp11
-rw-r--r--clang/test/CodeGen/ext-vector.c2
-rw-r--r--clang/test/Coverage/c-language-features.inc2
3 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 6540b2ccc36..4dd06b924a2 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1160,6 +1160,17 @@ unsigned ExtVectorElementExpr::getNumElements() const {
bool ExtVectorElementExpr::containsDuplicateElements() const {
const char *compStr = Accessor.getName();
unsigned length = Accessor.getLength();
+
+ // Halving swizzles do not contain duplicate elements.
+ if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") ||
+ !strcmp(compStr, "even") || !strcmp(compStr, "odd"))
+ return false;
+
+ // Advance past s-char prefix on hex swizzles.
+ if (*compStr == 's') {
+ compStr++;
+ length--;
+ }
for (unsigned i = 0; i != length-1; i++) {
const char *s = compStr+i;
diff --git a/clang/test/CodeGen/ext-vector.c b/clang/test/CodeGen/ext-vector.c
index 657b2858535..ae877edb815 100644
--- a/clang/test/CodeGen/ext-vector.c
+++ b/clang/test/CodeGen/ext-vector.c
@@ -15,7 +15,7 @@ float4 vec4, vec4_2;
float f;
void test2() {
- vec2 = vec4.rg; // shorten
+ vec2 = vec4.xy; // shorten
f = vec2.x; // extract elt
vec4 = vec4.yyyy; // splat
diff --git a/clang/test/Coverage/c-language-features.inc b/clang/test/Coverage/c-language-features.inc
index 6944b9d65e9..9a52e56c21d 100644
--- a/clang/test/Coverage/c-language-features.inc
+++ b/clang/test/Coverage/c-language-features.inc
@@ -136,7 +136,7 @@ typedef __attribute__((ext_vector_type(4))) float float4;
void f5() {
float4 t0 = (float4) { 0, 1, 2, 3 };
float4 t1 = t0;
- t0.lo.e = t1.hi.x;
+ t0.lo.even = t1.hi.x;
}
void f6() {
OpenPOWER on IntegriCloud