[clang-tidy] checkOverridingFunctionReturnType - 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
This commit is contained in:
Simon Pilgrim 2022-02-12 10:41:43 +00:00
parent 437d4e01fe
commit 389bee71ea
1 changed files with 2 additions and 2 deletions

View File

@ -40,11 +40,11 @@ static bool checkOverridingFunctionReturnType(const ASTContext *Context,
const CXXMethodDecl *BaseMD,
const CXXMethodDecl *DerivedMD) {
QualType BaseReturnTy = BaseMD->getType()
->getAs<FunctionType>()
->castAs<FunctionType>()
->getReturnType()
.getCanonicalType();
QualType DerivedReturnTy = DerivedMD->getType()
->getAs<FunctionType>()
->castAs<FunctionType>()
->getReturnType()
.getCanonicalType();