Skip to content

Commit cfee2ef

Browse files
committed
CGDebugInfo - silence static analyzer dyn_cast<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use cast<> directly and if not assert will fire for us. llvm-svn: 374989
1 parent cebfddc commit cfee2ef

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,7 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
17911791
CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset);
17921792
V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars);
17931793
}
1794+
assert(V && "Failed to find template parameter pointer");
17941795
V = V->stripPointerCasts();
17951796
}
17961797
TemplateParams.push_back(DBuilder.createTemplateValueParameter(
@@ -3327,13 +3328,13 @@ llvm::DISubprogram *CGDebugInfo::getFunctionFwdDeclOrStub(GlobalDecl GD,
33273328
unsigned Line = getLineNumber(Loc);
33283329
collectFunctionDeclProps(GD, Unit, Name, LinkageName, DContext, TParamsArray,
33293330
Flags);
3330-
auto *FD = dyn_cast<FunctionDecl>(GD.getDecl());
3331+
auto *FD = cast<FunctionDecl>(GD.getDecl());
33313332

33323333
// Build function type.
33333334
SmallVector<QualType, 16> ArgTypes;
3334-
if (FD)
3335-
for (const ParmVarDecl *Parm : FD->parameters())
3336-
ArgTypes.push_back(Parm->getType());
3335+
for (const ParmVarDecl *Parm : FD->parameters())
3336+
ArgTypes.push_back(Parm->getType());
3337+
33373338
CallingConv CC = FD->getType()->castAs<FunctionType>()->getCallConv();
33383339
QualType FnType = CGM.getContext().getFunctionType(
33393340
FD->getReturnType(), ArgTypes, FunctionProtoType::ExtProtoInfo(CC));

0 commit comments

Comments
 (0)