Skip to content

Commit d3c974a

Browse files
committed
Add checks for isNull
1 parent 4e28bb4 commit d3c974a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,20 @@ static bool areBinaryOperatorOperandsTypesEqual(const Expr *E,
5757
if (!WithoutImplicitAndParen)
5858
return false;
5959
if (const auto *B = dyn_cast<BinaryOperator>(WithoutImplicitAndParen)) {
60-
const QualType NonReferenceType =
61-
WithoutImplicitAndParen->getType().getNonReferenceType();
62-
if (!areTypesEquals(
63-
B->getLHS()->IgnoreImplicit()->getType().getNonReferenceType(),
64-
NonReferenceType, IgnoreTypeAliases))
60+
const QualType Type = WithoutImplicitAndParen->getType();
61+
if (Type.isNull())
62+
return false;
63+
64+
const QualType NonReferenceType = Type.getNonReferenceType();
65+
const QualType LHSType = B->getLHS()->IgnoreImplicit()->getType();
66+
if (!LHSType.isNull() &&
67+
!areTypesEquals(LHSType.getNonReferenceType(), NonReferenceType,
68+
IgnoreTypeAliases))
6569
return true;
66-
if (!areTypesEquals(
67-
B->getRHS()->IgnoreImplicit()->getType().getNonReferenceType(),
68-
NonReferenceType, IgnoreTypeAliases))
70+
const QualType RHSType = B->getRHS()->IgnoreImplicit()->getType();
71+
if (!RHSType.isNull() &&
72+
!areTypesEquals(RHSType.getNonReferenceType(), NonReferenceType,
73+
IgnoreTypeAliases))
6974
return true;
7075
}
7176
return false;

0 commit comments

Comments
 (0)