Skip to content

Commit 5e0a0b7

Browse files
committed
CGVTables - silence static analyzer getAs<FunctionProtoType> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but we should be able to use castAs<FunctionProtoType> directly and if not assert will fire for us. llvm-svn: 373398
1 parent 9128705 commit 5e0a0b7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ CodeGenFunction::GenerateVarArgsThunk(llvm::Function *Fn,
157157
const CGFunctionInfo &FnInfo,
158158
GlobalDecl GD, const ThunkInfo &Thunk) {
159159
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
160-
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
160+
const FunctionProtoType *FPT = MD->getType()->castAs<FunctionProtoType>();
161161
QualType ResultType = FPT->getReturnType();
162162

163163
// Get the original function
@@ -242,7 +242,6 @@ void CodeGenFunction::StartThunk(llvm::Function *Fn, GlobalDecl GD,
242242
// Build FunctionArgs.
243243
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
244244
QualType ThisType = MD->getThisType();
245-
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
246245
QualType ResultType;
247246
if (IsUnprototyped)
248247
ResultType = CGM.getContext().VoidTy;
@@ -251,7 +250,7 @@ void CodeGenFunction::StartThunk(llvm::Function *Fn, GlobalDecl GD,
251250
else if (CGM.getCXXABI().hasMostDerivedReturn(GD))
252251
ResultType = CGM.getContext().VoidPtrTy;
253252
else
254-
ResultType = FPT->getReturnType();
253+
ResultType = MD->getType()->castAs<FunctionProtoType>()->getReturnType();
255254
FunctionArgList FunctionArgs;
256255

257256
// Create the implicit 'this' parameter declaration.

0 commit comments

Comments
 (0)