]> granicus.if.org Git - clang/commitdiff
Added transfer function support for casting to "void".
authorTed Kremenek <kremenek@apple.com>
Tue, 19 Feb 2008 18:47:04 +0000 (18:47 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 19 Feb 2008 18:47:04 +0000 (18:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47333 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp
Analysis/ValueState.cpp

index 8df9e5f305a4224d78e845af36bd94a4ce38d8e1..6d45beab32771275612be5749f609a68ed6bf903 100644 (file)
@@ -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;
index 963864662a9987a9f61d5f07a24c2bbfac52e1d4..5796238d48d3bc1c54bb217319c441610c825c0a 100644 (file)
@@ -252,6 +252,10 @@ RValue ValueStateManager::GetValue(ValueState St, Expr* E, bool* hasVal) {
       case Stmt::ImplicitCastExprClass: {
         ImplicitCastExpr* C = cast<ImplicitCastExpr>(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;