summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorStephen Canon <scanon@apple.com>2015-09-15 00:21:56 +0000
committerStephen Canon <scanon@apple.com>2015-09-15 00:21:56 +0000
commitca8eefddb7a5c85ad1e26773eb1ba894c7b930f5 (patch)
treee871321ae8c3e862ec29416e99d8dd93d9f195b5 /clang/lib/Sema/SemaExpr.cpp
parent1b76da6a6c5a1e8ec79d77cfd61a48a516491d7d (diff)
downloadbcm5719-llvm-ca8eefddb7a5c85ad1e26773eb1ba894c7b930f5.tar.gz
bcm5719-llvm-ca8eefddb7a5c85ad1e26773eb1ba894c7b930f5.zip
Prevent implicit re-interpret casts between ExtVector and Scalar types.
Previously, in certain cases lax vector conversions could occur between scalar floating-point values and ExtVector types; these conversions would be simple bitcasts. We need to allow them with other vector types to support some common headers, but we don't need them for ExtVector. Preventing them here makes them behave like other operations involving scalars and ExtVectors. llvm-svn: 247643
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d55ac5ee833..6b20f59046d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5562,6 +5562,14 @@ static bool breakDownVectorType(QualType type, uint64_t &len,
/// vector nor a real type.
bool Sema::areLaxCompatibleVectorTypes(QualType srcTy, QualType destTy) {
assert(destTy->isVectorType() || srcTy->isVectorType());
+
+ // Disallow lax conversions between scalars and ExtVectors (these
+ // conversions are allowed for other vector types because common headers
+ // depend on them). Most scalar OP ExtVector cases are handled by the
+ // splat path anyway, which does what we want (convert, not bitcast).
+ // What this rules out for ExtVectors is crazy things like char4*float.
+ if (srcTy->isScalarType() && destTy->isExtVectorType()) return false;
+ if (destTy->isScalarType() && srcTy->isExtVectorType()) return false;
uint64_t srcLen, destLen;
QualType srcElt, destElt;
OpenPOWER on IntegriCloud