Skip to content

Commit 4d167fb

Browse files
committed
[Sema] TransformTypeOfExprType / TransformTypeOfType - don't dereference getAs<> results
Use castAs<> to assert the cast is valid to help avoid null dereferences Fixes static analyser warnings
1 parent 7c866cc commit 4d167fb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/Sema/TreeTransform.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6551,7 +6551,7 @@ QualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB,
65516551
return QualType();
65526552

65536553
QualType Result = TL.getType();
6554-
TypeOfKind Kind = Result->getAs<TypeOfExprType>()->getKind();
6554+
TypeOfKind Kind = Result->castAs<TypeOfExprType>()->getKind();
65556555
if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
65566556
Result =
65576557
getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
@@ -6576,7 +6576,7 @@ QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB,
65766576
return QualType();
65776577

65786578
QualType Result = TL.getType();
6579-
TypeOfKind Kind = Result->getAs<TypeOfType>()->getKind();
6579+
TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
65806580
if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
65816581
Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
65826582
if (Result.isNull())

0 commit comments

Comments
 (0)