From 4b432096839e719ec0b78cd0299e7950a59dce0b Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 13 Feb 2022 13:14:00 +0000 Subject: [PATCH] [clang][sema] Use castAs<> instead of getAs<> to avoid dereference of nullptr The pointers are referenced immediately, so assert the cast is correct instead of returning nullptr --- clang/lib/Sema/SemaExpr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 6629f3e..22b3f37 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3022,7 +3022,7 @@ Sema::PerformObjectMemberConversion(Expr *From, QualType QType = QualType(Qualifier->getAsType(), 0); assert(QType->isRecordType() && "lookup done with non-record type"); - QualType QRecordType = QualType(QType->getAs(), 0); + QualType QRecordType = QualType(QType->castAs(), 0); // In C++98, the qualifier type doesn't actually have to be a base // type of the object type, in which case we just ignore it. @@ -10035,7 +10035,7 @@ static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar, ExprResult *Vector) { QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType(); QualType VectorTy = Vector->get()->getType().getUnqualifiedType(); - const VectorType *VT = VectorTy->getAs(); + const auto *VT = VectorTy->castAs(); assert(!isa(VT) && "ExtVectorTypes should not be handled here!"); -- 2.7.4