[clang] 2614de8 - [clang] CGCXXABI::EmitLoadOfMemberFunctionPointer - use castAs<> instead of getAs<> to avoid dereference of nullptr
Simon Pilgrim via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 17 05:18:51 PST 2022
Author: Simon Pilgrim
Date: 2022-02-17T13:18:23Z
New Revision: 2614de82025bd9c04f8515747a611238c0ac4e05
URL: https://github.com/llvm/llvm-project/commit/2614de82025bd9c04f8515747a611238c0ac4e05
DIFF: https://github.com/llvm/llvm-project/commit/2614de82025bd9c04f8515747a611238c0ac4e05.diff
LOG: [clang] CGCXXABI::EmitLoadOfMemberFunctionPointer - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointer is always dereferenced by arrangeCXXMethodType, so assert the cast is correct instead of returning nullptr
Added:
Modified:
clang/lib/CodeGen/CGCXXABI.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp
index 0b441e382f11..42e6c916bed0 100644
--- a/clang/lib/CodeGen/CGCXXABI.cpp
+++ b/clang/lib/CodeGen/CGCXXABI.cpp
@@ -45,8 +45,7 @@ CGCallee CGCXXABI::EmitLoadOfMemberFunctionPointer(
ErrorUnsupportedABI(CGF, "calls through member pointers");
ThisPtrForCall = This.getPointer();
- const FunctionProtoType *FPT =
- MPT->getPointeeType()->getAs<FunctionProtoType>();
+ const auto *FPT = MPT->getPointeeType()->castAs<FunctionProtoType>();
const auto *RD =
cast<CXXRecordDecl>(MPT->getClass()->castAs<RecordType>()->getDecl());
llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
More information about the cfe-commits
mailing list