[clang] 02ce49a - [NFC][CLANG] Fix bug with dereference null return value in GetFunctionTypeForVTable()

via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 2 13:28:12 PDT 2023


Author: Manna, Soumi
Date: 2023-06-02T13:28:06-07:00
New Revision: 02ce49afb9a078932c74f4d9b43189a5567e54e9

URL: https://github.com/llvm/llvm-project/commit/02ce49afb9a078932c74f4d9b43189a5567e54e9
DIFF: https://github.com/llvm/llvm-project/commit/02ce49afb9a078932c74f4d9b43189a5567e54e9.diff

LOG: [NFC][CLANG] Fix bug with dereference null return value in GetFunctionTypeForVTable()

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

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCall.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 09ccb63dceeb..b6b04fca6682 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -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());


        


More information about the cfe-commits mailing list