Skip to content

Commit 4b43209

Browse files
committed
[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
1 parent 1ea5843 commit 4b43209

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,7 @@ Sema::PerformObjectMemberConversion(Expr *From,
30223022
QualType QType = QualType(Qualifier->getAsType(), 0);
30233023
assert(QType->isRecordType() && "lookup done with non-record type");
30243024

3025-
QualType QRecordType = QualType(QType->getAs<RecordType>(), 0);
3025+
QualType QRecordType = QualType(QType->castAs<RecordType>(), 0);
30263026

30273027
// In C++98, the qualifier type doesn't actually have to be a base
30283028
// type of the object type, in which case we just ignore it.
@@ -10035,7 +10035,7 @@ static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar,
1003510035
ExprResult *Vector) {
1003610036
QualType ScalarTy = Scalar->get()->getType().getUnqualifiedType();
1003710037
QualType VectorTy = Vector->get()->getType().getUnqualifiedType();
10038-
const VectorType *VT = VectorTy->getAs<VectorType>();
10038+
const auto *VT = VectorTy->castAs<VectorType>();
1003910039

1004010040
assert(!isa<ExtVectorType>(VT) &&
1004110041
"ExtVectorTypes should not be handled here!");

0 commit comments

Comments
 (0)