From 57fc9798d7145626809b0e81af9154a755b383eb Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 17 Feb 2022 13:18:02 +0000 Subject: [PATCH] [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 --- clang/lib/CodeGen/CGDebugInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); + const auto *Func = Method->getType()->castAs(); if (Method->isStatic()) return cast_or_null( getOrCreateType(QualType(Func, 0), Unit));