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

Soumi Manna via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 1 18:15:44 PDT 2023


Manna created this revision.
Manna added a reviewer: erichkeane.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

This patch uses castAs instead of getAs which will assert if the type doesn't match In clang::​CodeGen::​CodeGenTypes::​GetFunctionTypeForVTable(clang::​GlobalDecl).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151957

Files:
  clang/lib/CodeGen/CGCall.cpp


Index: clang/lib/CodeGen/CGCall.cpp
===================================================================
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1751,7 +1751,7 @@
 
 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());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151957.527687.patch
Type: text/x-patch
Size: 573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230602/d017c3ff/attachment.bin>


More information about the cfe-commits mailing list