SemaType.cpp - use castAs<> instead of getAs<> for dereferenced pointers

Fix static analyzer warnings - castAs<> will assert the type is correct, but getAs<> just returns null, which would just result in a dereferenced null pointer.
This commit is contained in:
Simon Pilgrim 2020-12-08 16:37:05 +00:00
parent 111ae220a3
commit 25f5df7e0b
1 changed files with 2 additions and 2 deletions

View File

@ -7967,7 +7967,7 @@ static void HandleOpenCLAccessAttr(QualType &CurType, const ParsedAttr &Attr,
diag::note_opencl_typedef_access_qualifier) << PrevAccessQual;
} else if (CurType->isPipeType()) {
if (Attr.getSemanticSpelling() == OpenCLAccessAttr::Keyword_write_only) {
QualType ElemType = CurType->getAs<PipeType>()->getElementType();
QualType ElemType = CurType->castAs<PipeType>()->getElementType();
CurType = S.Context.getWritePipeType(ElemType);
}
}
@ -9021,7 +9021,7 @@ QualType Sema::BuildUnaryTransformType(QualType BaseType,
return QualType();
}
EnumDecl *ED = BaseType->getAs<EnumType>()->getDecl();
EnumDecl *ED = BaseType->castAs<EnumType>()->getDecl();
assert(ED && "EnumType has no EnumDecl");
DiagnoseUseOfDecl(ED, Loc);