From 0a08067e20b32ab6d2eba89e7a2a5046dd1f528b Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 1 Oct 2019 22:02:46 +0000 Subject: [PATCH] CGVTables - silence static analyzer getAs null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but we should be able to use castAs directly and if not assert will fire for us. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373398 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGVTables.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp index 3055ea3bfd..a74905fd70 100644 --- a/lib/CodeGen/CGVTables.cpp +++ b/lib/CodeGen/CGVTables.cpp @@ -157,7 +157,7 @@ CodeGenFunction::GenerateVarArgsThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo, GlobalDecl GD, const ThunkInfo &Thunk) { const CXXMethodDecl *MD = cast(GD.getDecl()); - const FunctionProtoType *FPT = MD->getType()->getAs(); + const FunctionProtoType *FPT = MD->getType()->castAs(); QualType ResultType = FPT->getReturnType(); // Get the original function @@ -242,7 +242,6 @@ void CodeGenFunction::StartThunk(llvm::Function *Fn, GlobalDecl GD, // Build FunctionArgs. const CXXMethodDecl *MD = cast(GD.getDecl()); QualType ThisType = MD->getThisType(); - const FunctionProtoType *FPT = MD->getType()->getAs(); QualType ResultType; if (IsUnprototyped) ResultType = CGM.getContext().VoidTy; @@ -251,7 +250,7 @@ void CodeGenFunction::StartThunk(llvm::Function *Fn, GlobalDecl GD, else if (CGM.getCXXABI().hasMostDerivedReturn(GD)) ResultType = CGM.getContext().VoidPtrTy; else - ResultType = FPT->getReturnType(); + ResultType = MD->getType()->castAs()->getReturnType(); FunctionArgList FunctionArgs; // Create the implicit 'this' parameter declaration. -- 2.40.0