From: Ted Kremenek Date: Tue, 19 Feb 2008 18:47:04 +0000 (+0000) Subject: Added transfer function support for casting to "void". X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=402563b86a2de8a2cb82e2de3c895a3dd8924ca0;p=clang Added transfer function support for casting to "void". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47333 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp index 8df9e5f305..6d45beab32 100644 --- a/Analysis/GRExprEngine.cpp +++ b/Analysis/GRExprEngine.cpp @@ -449,8 +449,9 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* E, NodeTy* Pred, NodeSet& Dst) { QualType T = CastE->getType(); - // Check for redundant casts. - if (E->getType() == T || + // Check for redundant casts or casting to "void" + if (T->isVoidType() || + E->getType() == T || (T->isPointerType() && E->getType()->isFunctionType())) { Dst.Add(Pred); return; diff --git a/Analysis/ValueState.cpp b/Analysis/ValueState.cpp index 963864662a..5796238d48 100644 --- a/Analysis/ValueState.cpp +++ b/Analysis/ValueState.cpp @@ -252,6 +252,10 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) { case Stmt::ImplicitCastExprClass: { ImplicitCastExpr* C = cast(E); QualType CT = C->getType(); + + if (CT->isVoidType()) + return UnknownVal(); + QualType ST = C->getSubExpr()->getType(); if (CT == ST || (CT->isPointerType() && ST->isFunctionType())) { @@ -266,6 +270,9 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) { QualType CT = C->getType(); QualType ST = C->getSubExpr()->getType(); + if (CT->isVoidType()) + return UnknownVal(); + if (CT == ST || (CT->isPointerType() && ST->isFunctionType())) { E = C->getSubExpr(); continue;