Skip to content

Commit 729a2f6

Browse files
committed
CGBuiltin - silence static analyzer getAs<> null dereference warnings. NFCI.
The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 374987
1 parent c598ef7 commit 729a2f6

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,9 +1396,8 @@ EmitCheckedMixedSignMultiply(CodeGenFunction &CGF, const clang::Expr *Op1,
13961396
static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
13971397
Value *&RecordPtr, CharUnits Align,
13981398
llvm::FunctionCallee Func, int Lvl) {
1399-
const auto *RT = RType->getAs<RecordType>();
14001399
ASTContext &Context = CGF.getContext();
1401-
RecordDecl *RD = RT->getDecl()->getDefinition();
1400+
RecordDecl *RD = RType->castAs<RecordType>()->getDecl()->getDefinition();
14021401
std::string Pad = std::string(Lvl * 4, ' ');
14031402

14041403
Value *GString =
@@ -3693,13 +3692,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
36933692
case Builtin::BIget_pipe_num_packets:
36943693
case Builtin::BIget_pipe_max_packets: {
36953694
const char *BaseName;
3696-
const PipeType *PipeTy = E->getArg(0)->getType()->getAs<PipeType>();
3695+
const auto *PipeTy = E->getArg(0)->getType()->castAs<PipeType>();
36973696
if (BuiltinID == Builtin::BIget_pipe_num_packets)
36983697
BaseName = "__get_pipe_num_packets";
36993698
else
37003699
BaseName = "__get_pipe_max_packets";
3701-
auto Name = std::string(BaseName) +
3702-
std::string(PipeTy->isReadOnly() ? "_ro" : "_wo");
3700+
std::string Name = std::string(BaseName) +
3701+
std::string(PipeTy->isReadOnly() ? "_ro" : "_wo");
37033702

37043703
// Building the generic function prototype.
37053704
Value *Arg0 = EmitScalarExpr(E->getArg(0));

0 commit comments

Comments
 (0)