From: Ted Kremenek Date: Fri, 15 May 2009 05:34:49 +0000 (+0000) Subject: Use dyn_cast instead of cast to allow our assumptions to be safely wrong. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=725b7476649f0ef49e477a71897a43a77c82257c;p=clang Use dyn_cast instead of cast to allow our assumptions to be safely wrong. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71843 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp index a298629529..9aea12447d 100644 --- a/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -631,22 +631,30 @@ static const Stmt *GetDerefExpr(const ExplodedNode *N) { static const Stmt *GetReceiverExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); - return cast(S)->getReceiver(); + if (const ObjCMessageExpr *ME = dyn_cast(S)) + return ME->getReceiver(); + return NULL; } static const Stmt *GetDenomExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); - return cast(S)->getRHS(); + if (const BinaryOperator *BE = dyn_cast(S)) + return BE->getRHS(); + return NULL; } static const Stmt *GetCalleeExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); - return cast(S)->getCallee(); + if (const CallExpr *CE = dyn_cast(S)) + return CE->getCallee(); + return NULL; } static const Stmt *GetRetValExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); - return cast(S)->getRetValue(); + if (const ReturnStmt *RS = dyn_cast(S)) + return RS->getRetValue(); + return NULL; } namespace {