]> andersk Git - splint.git/blobdiff - src/constraintGeneration.c
Fixes after removing -unrecogcomments flag for make splintme.
[splint.git] / src / constraintGeneration.c
index 17f2569e02862f1170cf4334c0b5b5a734c13945..7595c148bf101026231119a55e0c96ebcecfa43f 100644 (file)
@@ -146,7 +146,7 @@ bool /*@alt void@*/ exprNode_generateConstraints (/*@temp@*/ exprNode e)
     constraintList_free(c);
   }    
 
-  DPRINTF ((message ("e->requiresConstraints %s", constraintList_printDetailed (e->requiresConstraints))));
+  DPRINTF ((message ("e->requiresConstraints %s", constraintList_unparseDetailed (e->requiresConstraints))));
   return FALSE;
 }
 
@@ -252,8 +252,8 @@ static void exprNode_stmt (/*@temp@*/ exprNode e)
   e->ensuresConstraints  = exprNode_traversEnsuresConstraints(snode);
 
   DPRINTF ((message ("smtlist constraints are: pre: %s \n and \t post %s\n",
-                     constraintList_print(e->requiresConstraints),
-                     constraintList_print(e->ensuresConstraints))));
+                     constraintList_unparse(e->requiresConstraints),
+                     constraintList_unparse(e->ensuresConstraints))));
 
   return; 
 }
@@ -293,8 +293,8 @@ static void exprNode_stmtList  (/*@dependent@*/ exprNode e)
   exprNode_mergeResolve (e, stmt1, stmt2);
   
   DPRINTF ((message ("smtlist constraints are: pre: %s \n and \t post %s\n",
-                     constraintList_print(e->requiresConstraints),
-                     constraintList_print(e->ensuresConstraints))));
+                     constraintList_unparse(e->requiresConstraints),
+                     constraintList_unparse(e->ensuresConstraints))));
   return;
 }
 
@@ -309,23 +309,23 @@ static exprNode doIf (/*@returned@*/  exprNode e, /*@dependent@*/ exprNode test,
   llassert (exprNode_isDefined (body));
 
   
-      DPRINTF((message ("ensures constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->ensuresConstraints))));
+      DPRINTF((message ("ensures constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->ensuresConstraints))));
 
-      DPRINTF((message ("Requires constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->ensuresConstraints))));
+      DPRINTF((message ("Requires constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->ensuresConstraints))));
       
-      DPRINTF((message ("trueEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->trueEnsuresConstraints))));
+      DPRINTF((message ("trueEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->trueEnsuresConstraints))));
 
-      DPRINTF((message ("falseEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->falseEnsuresConstraints))));
+      DPRINTF((message ("falseEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->falseEnsuresConstraints))));
 
 
 
-      DPRINTF((message ("ensures constraints for %s are %s", exprNode_unparse(test), constraintList_printDetailed(test->ensuresConstraints))));
+      DPRINTF((message ("ensures constraints for %s are %s", exprNode_unparse(test), constraintList_unparseDetailed(test->ensuresConstraints))));
 
-      DPRINTF((message ("Requires constraints for %s are %s", exprNode_unparse(test), constraintList_printDetailed(test->ensuresConstraints))));
+      DPRINTF((message ("Requires constraints for %s are %s", exprNode_unparse(test), constraintList_unparseDetailed(test->ensuresConstraints))));
       
-      DPRINTF((message ("trueEnsures constraints for %s are %s", exprNode_unparse(test), constraintList_printDetailed(test->trueEnsuresConstraints))));
+      DPRINTF((message ("trueEnsures constraints for %s are %s", exprNode_unparse(test), constraintList_unparseDetailed(test->trueEnsuresConstraints))));
 
-      DPRINTF((message ("falseEnsures constraints for %s are %s", exprNode_unparse(test), constraintList_printDetailed(test->falseEnsuresConstraints))));
+      DPRINTF((message ("falseEnsures constraints for %s are %s", exprNode_unparse(test), constraintList_unparseDetailed(test->falseEnsuresConstraints))));
 
 
 
@@ -344,9 +344,9 @@ static exprNode doIf (/*@returned@*/  exprNode e, /*@dependent@*/ exprNode test,
 
   test->trueEnsuresConstraints = constraintList_substituteFreeTarget(test->trueEnsuresConstraints, test->ensuresConstraints);
   
-  DPRINTF ((message ("doIf: test ensures %s ", constraintList_print(test->ensuresConstraints))));
+  DPRINTF ((message ("doIf: test ensures %s ", constraintList_unparse(test->ensuresConstraints))));
     
-  DPRINTF ((message ("doIf: test true ensures %s ", constraintList_print(test->trueEnsuresConstraints))));
+  DPRINTF ((message ("doIf: test true ensures %s ", constraintList_unparse(test->trueEnsuresConstraints))));
   
   constraintList_free(e->requiresConstraints);
 
@@ -371,7 +371,7 @@ static exprNode doIf (/*@returned@*/  exprNode e, /*@dependent@*/ exprNode test,
                                                        test->falseEnsuresConstraints);
     }
   
-  DPRINTF ((message ("doIf: if requiers %s ", constraintList_print(e->requiresConstraints))));
+  DPRINTF ((message ("doIf: if requiers %s ", constraintList_unparse(e->requiresConstraints))));
   
   return e;
 }
@@ -434,8 +434,8 @@ static exprNode doIfElse (/*@returned@*/ exprNode e, /*@dependent@*/ exprNode p,
   constraintList_free(cons);
   constraintList_free(c1);
   
-  DPRINTF ((message ("doIfElse: if requires %q ", constraintList_print(e->requiresConstraints))));
-  DPRINTF ((message ("doIfElse: if ensures %q ", constraintList_print(e->ensuresConstraints))));
+  DPRINTF ((message ("doIfElse: if requires %q ", constraintList_unparse(e->requiresConstraints))));
+  DPRINTF ((message ("doIfElse: if ensures %q ", constraintList_unparse(e->ensuresConstraints))));
   
   return e;
 }
@@ -489,7 +489,7 @@ static exprNode doWhile (/*@returned@*/ exprNode e, /*@dependent@*/ exprNode tes
   end_sRefSet_elements ;
   
   DPRINTF((message("constraintList_makeFixedArrayConstraints returning %s",
-                   constraintList_print(ret))));
+                   constraintList_unparse(ret))));
   return ret;
 }
 
@@ -641,7 +641,7 @@ exprNode_doGenerateConstraintSwitch
                  DPRINTF((message("returning from exprNode_doGenerateConstraintSwitch: (switch %s) %s currentRequires:"
                                    "%s currentEnsures:%s",
                                    exprNode_unparse(switchExpr), exprNode_unparse(body),
-                                   constraintList_print(*currentRequires), constraintList_print(*currentEnsures)
+                                   constraintList_unparse(*currentRequires), constraintList_unparse(*currentEnsures)
                                   )));
                  /*@-onlytrans@*/
                  return;
@@ -679,26 +679,21 @@ exprNode_doGenerateConstraintSwitch
          *savedRequires = constraintList_mergeRequiresFreeFirst (*savedRequires, *currentRequires);
        }
       
-      con = constraint_makeEnsureEqual (switchExpr, exprData_getSingle
-                                       (stmt->edata), exprNode_getfileloc(stmt));
+      con = constraint_makeEnsureEqual (switchExpr, exprData_getSingle (stmt->edata), exprNode_loc (stmt));
 
-
-      constraintList_free(*currentEnsures);
+      constraintList_free (*currentEnsures);
       *currentEnsures = constraintList_makeNew();
       *currentEnsures = constraintList_add(*currentEnsures, con);
 
       constraintList_free(*currentRequires);
       *currentRequires = constraintList_makeNew();
-      DPRINTF((message("exprNode_doGenerateConstraintSwitch: (switch %s) %s savedRequires:"
-                       "%s savedEnsures:%s",
-                       exprNode_unparse(switchExpr), exprNode_unparse(body),
-                       constraintList_print(*savedRequires), constraintList_print(*savedEnsures)
-                       )));
-
+      DPRINTF (("exprNode_doGenerateConstraintSwitch: (switch %s) %s savedRequires:"
+               "%s savedEnsures:%s",
+               exprNode_unparse(switchExpr), exprNode_unparse(body),
+               constraintList_unparse(*savedRequires), constraintList_unparse(*savedEnsures)
+               ));
     }
-
-  else if (exprNode_isCaseMarker(stmt))
-    /* prior case has no break. */
+  else if (exprNode_isCaseMarker(stmt)) /* prior case has no break. */
     {
       /* 
         We don't do anything to the sved constraints because the case hasn't ended
@@ -708,38 +703,28 @@ exprNode_doGenerateConstraintSwitch
       
       constraintList temp;
       constraint con;
-
       constraintList ensuresTemp;
 
-      DPRINTF ((message("Got case marker with no prior break")));
-
-      con = constraint_makeEnsureEqual (switchExpr, exprData_getSingle
-                                       (stmt->edata), exprNode_getfileloc(stmt));
-
-      ensuresTemp = constraintList_makeNew();
-
+      con = constraint_makeEnsureEqual (switchExpr, exprData_getSingle (stmt->edata), exprNode_loc (stmt));
+      
+      ensuresTemp = constraintList_makeNew ();
       ensuresTemp = constraintList_add (ensuresTemp, con);
 
-      if (exprNode_isError(stmtList))
+      if (exprNode_isError (stmtList))
        {
-         constraintList_free(*currentEnsures);
-
-         *currentEnsures = constraintList_copy(ensuresTemp);
-         constraintList_free(ensuresTemp);
-
+         constraintList_free (*currentEnsures);
+         *currentEnsures = constraintList_copy (ensuresTemp);
+         constraintList_free (ensuresTemp);
        }
       else
        {
-         
          temp = constraintList_logicalOr (*currentEnsures, ensuresTemp);
-         
-         constraintList_free(*currentEnsures);
-         constraintList_free(ensuresTemp);
-
+         constraintList_free (*currentEnsures);
+         constraintList_free (ensuresTemp);
          *currentEnsures = temp;
        }
-      constraintList_free(*currentRequires);
-      
+
+      constraintList_free (*currentRequires);
       *currentRequires = constraintList_makeNew();
     }
   else
@@ -751,11 +736,12 @@ exprNode_doGenerateConstraintSwitch
       BADEXIT;
     }
 
-  DPRINTF((message("returning from exprNode_doGenerateConstraintSwitch: (switch %s) %s currentRequires:"
-                   "%s currentEnsures:%s",
-                   exprNode_unparse(switchExpr), exprNode_unparse(body),
-                   constraintList_print(*currentRequires), constraintList_print(*currentEnsures)
-                  )));
+  DPRINTF (("returning from exprNode_doGenerateConstraintSwitch: (switch %s) %s currentRequires:"
+           "%s currentEnsures:%s",
+           exprNode_unparse(switchExpr), exprNode_unparse(body),
+           constraintList_unparse(*currentRequires), constraintList_unparse(*currentEnsures)
+           ));
+
   /*@-onlytrans@*/ 
   return;
   /*@=onlytrans@*/ 
@@ -780,22 +766,21 @@ static void exprNode_generateConstraintSwitch (/*@notnull@*/ exprNode switchStmt
       return;
     }
 
-  /*@i22*/
   DPRINTF((message("")));
   
   if (body->kind == XPR_BLOCK)
     body = exprData_getSingle(body->edata);
 
-  /*
+  
   constraintsRequires = constraintList_undefined;
   constraintsEnsures = constraintList_undefined;
 
   lastRequires = constraintList_makeNew();
   lastEnsures = constraintList_makeNew();
-  */
+  
 
   /*@-mustfree@*/ 
-  /*@i6534 - evans 2002-01-01: spurious warnings for these becuase of stack allocated storage */
+  /* evans 2002-01-01: spurious warnings for these becuase of stack allocated storage */
   exprNode_doGenerateConstraintSwitch (switchExpr, body, &lastRequires, 
                                       &lastEnsures, &constraintsRequires, &constraintsEnsures);
   /*@=mustfree@*/
@@ -825,8 +810,8 @@ static void exprNode_generateConstraintSwitch (/*@notnull@*/ exprNode switchStmt
   constraintList_free (lastEnsures);
 
   DPRINTF(((message(" exprNode_generateConstraintSwitch returning requires: %s and ensures %s",
-                    constraintList_print(switchStmt->requiresConstraints),
-                    constraintList_print(switchStmt->ensuresConstraints)
+                    constraintList_unparse(switchStmt->requiresConstraints),
+                    constraintList_unparse(switchStmt->ensuresConstraints)
                    )
            )));
 }
@@ -955,7 +940,7 @@ void exprNode_multiStatement (/*@dependent@*/ exprNode e)
 
 
 
-      DPRINTF((message("p->trueEnsuresConstraints before substitue %s", constraintList_print(p->trueEnsuresConstraints)  )
+      DPRINTF((message("p->trueEnsuresConstraints before substitue %s", constraintList_unparse(p->trueEnsuresConstraints)  )
               ));
 
             /*drl 10/10/2002 this is a bit of a hack but the reason why we do this is so that any function post conditions or similar things get applied correctly to each branch.  e.g. in strlen(s) < 5 we want the trueEnsures to be maxRead(s) < 5*/
@@ -963,7 +948,7 @@ void exprNode_multiStatement (/*@dependent@*/ exprNode e)
       p->trueEnsuresConstraints = constraintList_substituteFreeTarget (p->trueEnsuresConstraints,
                                                                       p->ensuresConstraints);
       
-      DPRINTF(( message ("p->trueEnsuresConstraints after substitue %s", constraintList_print(p->trueEnsuresConstraints) )
+      DPRINTF(( message ("p->trueEnsuresConstraints after substitue %s", constraintList_unparse(p->trueEnsuresConstraints) )
                ));
       
       temp = p->falseEnsuresConstraints;
@@ -987,7 +972,7 @@ void exprNode_multiStatement (/*@dependent@*/ exprNode e)
       exprNode_generateConstraints (e2);
       exprNode_generateConstraints (e1);
       e = exprNode_copyConstraints (e, e2);
-      DPRINTF ((message ("e = %s  ", constraintList_print(e->requiresConstraints))));
+      DPRINTF ((message ("e = %s  ", constraintList_unparse(e->requiresConstraints))));
       
       break;
       
@@ -1251,7 +1236,6 @@ void exprNode_exprTraverse (/*@dependent@*/ exprNode e, bool definatelv, bool de
       exprNode_exprTraverse (exprData_getPairA (data), FALSE, TRUE, sequencePoint);
       exprNode_exprTraverse (exprData_getPairB (data), FALSE, TRUE, sequencePoint);
       
-      /*@i325 Should check which is array/index. */
       break;
       
     case XPR_PARENS: 
@@ -1333,7 +1317,7 @@ void exprNode_exprTraverse (/*@dependent@*/ exprNode e, bool definatelv, bool de
 
       break;
     case XPR_SIZEOFT:
-      /*@i43 drl possible problem : warning make sure the case can be ignored.. */
+      /*drl 4-11-03 I think this is the same as the next case...*/
       
       break;
       
@@ -1594,13 +1578,13 @@ void exprNode_exprTraverse (/*@dependent@*/ exprNode e, bool definatelv, bool de
 
   e->requiresConstraints = constraintList_removeSurpressed(e->requiresConstraints);
   
-  DPRINTF((message ("ensures constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->ensuresConstraints))));
+  DPRINTF((message ("ensures constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->ensuresConstraints))));
 
-  DPRINTF((message ("Requires constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->ensuresConstraints))));
+  DPRINTF((message ("Requires constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->ensuresConstraints))));
   
-  DPRINTF((message ("trueEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->trueEnsuresConstraints))));
+  DPRINTF((message ("trueEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->trueEnsuresConstraints))));
 
-  DPRINTF((message ("falseEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_printDetailed(e->falseEnsuresConstraints))));
+  DPRINTF((message ("falseEnsures constraints for %s are %s", exprNode_unparse(e), constraintList_unparseDetailed(e->falseEnsuresConstraints))));
 
   return;
 }
@@ -1694,7 +1678,6 @@ constraintList exprNode_traversTrueEnsuresConstraints (exprNode e)
       ret = constraintList_addListFree (ret,
                                     exprNode_traversTrueEnsuresConstraints
                                    (exprData_getFcn (data)));
-      /*@i11*/  /* exprNodeList_unparse (exprData_getArgs (data)); */
       break;
       
     case XPR_RETURN:
@@ -1827,7 +1810,6 @@ constraintList exprNode_traversFalseEnsuresConstraints (exprNode e)
       ret = constraintList_addListFree (ret,
                                     exprNode_traversFalseEnsuresConstraints
                                    (exprData_getFcn (data)));
-      /*@i11*/ /* exprNodeList_unparse (exprData_getArgs (data)); */
       break;
       
     case XPR_RETURN:
@@ -1963,7 +1945,6 @@ constraintList exprNode_traversFalseEnsuresConstraints (exprNode e)
       ret = constraintList_addListFree (ret,
                                     exprNode_traversRequiresConstraints
                                    (exprData_getFcn (data)));
-      /*@i11*/ /* exprNodeList_unparse (exprData_getArgs (data)); */
       break;
       
     case XPR_RETURN:
@@ -2037,7 +2018,7 @@ constraintList exprNode_traversFalseEnsuresConstraints (exprNode e)
   DPRINTF ((message ("exprnode_traversEnsuresConstraints call for %s with "
                     "constraintList of %s",
                     exprNode_unparse (e),
-                    constraintList_print(e->ensuresConstraints)
+                    constraintList_unparse(e->ensuresConstraints)
                     )
            ));
   
@@ -2106,7 +2087,6 @@ constraintList exprNode_traversFalseEnsuresConstraints (exprNode e)
       ret = constraintList_addListFree (ret,
                                        exprNode_traversEnsuresConstraints
                                        (exprData_getFcn (data)));
-      /*@i11*/ /* exprNodeList_unparse (exprData_getArgs (data)); */
       break;
     case XPR_RETURN:
       ret = constraintList_addListFree (ret,
@@ -2146,7 +2126,7 @@ constraintList exprNode_traversFalseEnsuresConstraints (exprNode e)
   DPRINTF((message ("exprnode_traversEnsuresConstraints call for %s with "
                    "constraintList of  is returning %s",
                    exprNode_unparse (e),
-                   constraintList_print(ret))));
+                   constraintList_unparse(ret))));
   
   return ret;
 }
@@ -2242,13 +2222,13 @@ we'll include it in a production release when its stable...
          invars = getInvariants(ct);
 
 
-         TPRINTF((message ("findStructs has invariants %s ", constraintList_print (invars))
+         TPRINTF((message ("findStructs has invariants %s ", constraintList_unparse (invars))
                   ));
          
          invars = constraintList_doSRefFixStructConstraint(invars, exprNode_getSref(expr), ct);
 
          
-         TPRINTF((message ("findStructs finded invariants to be %s ", constraintList_print (invars))
+         TPRINTF((message ("findStructs finded invariants to be %s ", constraintList_unparse (invars))
                   ));
        }
     }
@@ -2317,7 +2297,7 @@ constraintList checkCall (/*@dependent@*/ exprNode fcn, exprNodeList arglist)
     }
   
   DPRINTF ((message("Done checkCall\n")));
-  DPRINTF ((message("Returning list %q ", constraintList_printDetailed(preconditions))));
+  DPRINTF ((message("Returning list %q ", constraintList_unparseDetailed(preconditions))));
 
   /*
     drl we're going to comment this out for now
@@ -2337,7 +2317,6 @@ constraintList checkCall (/*@dependent@*/ exprNode fcn, exprNodeList arglist)
   I'm a bit nervous about modifying the exprNode
   but this is the easy way to do this
   If I have time I'd like to cause the exprNode to get created correctly in the first place */
-/*@i223*/
 void exprNode_findValue(exprNode e)
 {
   exprData data;
This page took 0.065236 seconds and 4 git commands to generate.