diff options
author | Joe Ellis <joe.ellis@arm.com> | 2021-02-19 17:09:50 +0000 |
---|---|---|
committer | Joe Ellis <joe.ellis@arm.com> | 2021-02-23 13:40:58 +0000 |
commit | 1b1b30cf0f7d9619afb32e16f4a7c007da4ffccf (patch) | |
tree | 70d788cfe5029262993332fd29a4f3905b2d33b5 /clang/lib/Sema/SemaChecking.cpp | |
parent | 2c54b293373ce22cd912ea50fece504b26f2bdc4 (diff) | |
download | llvm-1b1b30cf0f7d9619afb32e16f4a7c007da4ffccf.zip llvm-1b1b30cf0f7d9619afb32e16f4a7c007da4ffccf.tar.gz llvm-1b1b30cf0f7d9619afb32e16f4a7c007da4ffccf.tar.bz2 |
[clang][SVE] Don't warn on vector to sizeless builtin implicit conversion
This commit prevents warnings from -Wconversion when a clang vector type
is implicitly converted to a sizeless builtin type -- for example, when
implicitly converting a fixed-predicate to a scalable predicate.
The code below:
1 #include <arm_sve.h>
2
3 #define N __ARM_FEATURE_SVE_BITS
4 #define FIXED_ATTR __attribute__((arm_sve_vector_bits (N)))
5 typedef svbool_t fixed_svbool_t FIXED_ATTR;
6
7 inline fixed_svbool_t foo(fixed_svbool_t p) {
8 return svnot_z(svptrue_b64(), p);
9 }
would previously raise this warning:
warning: implicit conversion turns vector to scalar: \
'fixed_svbool_t' (vector of 8 'unsigned char' values) to 'svbool_t' \
(aka '__SVBool_t') [-Wconversion]
Note that many cases of these implicit conversions were already
permitted because many functions inside arm_sve.h are spawned via
preprocessor macros, and the call to isInSystemMacro would cover us in
this case. This commit fixes the remaining cases.
Differential Revision: https://reviews.llvm.org/D97053
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 2d3d36f..b41d943 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -12051,7 +12051,16 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, checkObjCDictionaryLiteral(S, QualType(Target, 0), DictionaryLiteral); // Strip vector types. - if (isa<VectorType>(Source)) { + if (const auto *SourceVT = dyn_cast<VectorType>(Source)) { + if (Target->isVLSTBuiltinType()) { + auto SourceVectorKind = SourceVT->getVectorKind(); + if (SourceVectorKind == VectorType::SveFixedLengthDataVector || + SourceVectorKind == VectorType::SveFixedLengthPredicateVector || + (SourceVectorKind == VectorType::GenericVector && + S.Context.getTypeSize(Source) == S.getLangOpts().ArmSveVectorBits)) + return; + } + if (!isa<VectorType>(Target)) { if (S.SourceMgr.isInSystemMacro(CC)) return; |