Skip to content

Commit 7ca52cd

Browse files
committed
[Sema] IsVectorConversion - merge isExtVectorType() and getAs<VectorType> calls. NFC.
Use getAs<ExtVectorType> directly to avoid duplicate getAs<> calls and static analyser warnings about dereferencing potentially null pointers.
1 parent 04a4254 commit 7ca52cd

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clang/lib/Sema/SemaOverload.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,21 +1980,21 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType,
19801980
return false;
19811981

19821982
// There are no conversions between extended vector types, only identity.
1983-
if (ToType->isExtVectorType()) {
1984-
if (FromType->isExtVectorType()) {
1983+
if (auto *ToExtType = ToType->getAs<ExtVectorType>()) {
1984+
if (auto *FromExtType = FromType->getAs<ExtVectorType>()) {
19851985
// HLSL allows implicit truncation of vector types.
19861986
if (S.getLangOpts().HLSL) {
1987-
unsigned FromElts = FromType->getAs<VectorType>()->getNumElements();
1988-
unsigned ToElts = ToType->getAs<VectorType>()->getNumElements();
1987+
unsigned FromElts = FromExtType->getNumElements();
1988+
unsigned ToElts = ToExtType->getNumElements();
19891989
if (FromElts < ToElts)
19901990
return false;
19911991
if (FromElts == ToElts)
19921992
ICK = ICK_Identity;
19931993
else
19941994
ICK = ICK_HLSL_Vector_Truncation;
19951995

1996-
QualType FromElTy = FromType->getAs<VectorType>()->getElementType();
1997-
QualType ToElTy = ToType->getAs<VectorType>()->getElementType();
1996+
QualType FromElTy = FromExtType->getElementType();
1997+
QualType ToElTy = ToExtType->getElementType();
19981998
if (S.Context.hasSameUnqualifiedType(FromElTy, ToElTy))
19991999
return true;
20002000
return IsVectorElementConversion(S, FromElTy, ToElTy, ElConv, From);

0 commit comments

Comments
 (0)