[clang] 57fc979 - [clang] CGDebugInfo::getOrCreateMethodType - 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:53 PST 2022
Author: Simon Pilgrim
Date: 2022-02-17T13:18:23Z
New Revision: 57fc9798d7145626809b0e81af9154a755b383eb
URL: https://github.com/llvm/llvm-project/commit/57fc9798d7145626809b0e81af9154a755b383eb
DIFF: https://github.com/llvm/llvm-project/commit/57fc9798d7145626809b0e81af9154a755b383eb.diff
LOG: [clang] CGDebugInfo::getOrCreateMethodType - use castAs<> instead of getAs<> to avoid dereference of nullptr
The pointer is always dereferenced, so assert the cast is correct instead of returning nullptr
Added:
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index c09adad09aa8..d75b5a1a9d12 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1725,7 +1725,7 @@ void CGDebugInfo::CollectRecordFields(
llvm::DISubroutineType *
CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
llvm::DIFile *Unit, bool decl) {
- const FunctionProtoType *Func = Method->getType()->getAs<FunctionProtoType>();
+ const auto *Func = Method->getType()->castAs<FunctionProtoType>();
if (Method->isStatic())
return cast_or_null<llvm::DISubroutineType>(
getOrCreateType(QualType(Func, 0), Unit));
More information about the cfe-commits
mailing list