[NFC][CLANG] Fix bug with dereference null return value in GetFunctionTypeForVTable()
authorManna, Soumi <soumi.manna@intel.com>
Fri, 2 Jun 2023 20:23:51 +0000 (13:23 -0700)
committerManna, Soumi <soumi.manna@intel.com>
Fri, 2 Jun 2023 20:28:06 +0000 (13:28 -0700)
This patch uses castAs instead of getAs which will assert if the type doesn't match in clang::CodeGen::CodeGenTypes::GetFunctionTypeForVTable(clang::GlobalDecl).

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D151957

clang/lib/CodeGen/CGCall.cpp

index 09ccb63..b6b04fc 100644 (file)
@@ -1751,7 +1751,7 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
 
 llvm::Type *CodeGenTypes::GetFunctionTypeForVTable(GlobalDecl GD) {
   const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
-  const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
+  const FunctionProtoType *FPT = MD->getType()->castAs<FunctionProtoType>();
 
   if (!isFuncTypeConvertible(FPT))
     return llvm::StructType::get(getLLVMContext());