]> andersk Git - splint.git/blobdiff - src/constraintResolve.c
Removed /*bee:...*/ comments.
[splint.git] / src / constraintResolve.c
index c6ba1503368f2397e0997d7e9f251b033667dea3..1616acf83dce37f7ee0c9690df09c7519325703b 100644 (file)
@@ -1,40 +1,63 @@
+/*
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2003 University of Virginia,
+**         Massachusetts Institute of Technology
+**
+** This program is free software; you can redistribute it and/or modify it
+** under the terms of the GNU General Public License as published by the
+** Free Software Foundation; either version 2 of the License, or (at your
+** option) any later version.
+** 
+** This program is distributed in the hope that it will be useful, but
+** WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+** General Public License for more details.
+** 
+** The GNU General Public License is available from http://www.gnu.org/ or
+** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+** MA 02111-1307, USA.
+**
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
+** For more information: http://www.splint.org
+*/
+
 /*
 *
 ** constraintResolve.c
 */
 
-//#define DEBUGPRINT 1
+/* #define DEBUGPRINT 1 */
 
 # include <ctype.h> /* for isdigit */
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "cgrammar.h"
 # include "cgrammar_tokens.h"
 
 # include "exprChecks.h"
-# include "aliasChecks.h"
 # include "exprNodeSList.h"
-//# include "exprData.i"
 
 
-/*@access constraint, exprNode @*/
+/*@access constraint, exprNode @*/ /*!!! NO! Don't do this so recklessly - design your code more carefully so you don't need to! */
 
-static bool rangeCheck (arithType ar1, /*@observer@*/ constraintExpr expr1, arithType ar2, /*@observer@*/ constraintExpr expr2);
+static constraint  inequalitySubstitute  (/*@returned@*/ constraint p_c, constraintList p_p);
 
-static constraint  inequalitySubstituteUnsound  (/*@returned@*/ constraint c, constraintList p);
 
-static constraint constraint_searchandreplace (/*@returned@*/ constraint c, constraintExpr old, constraintExpr new);
+static bool rangeCheck (arithType p_ar1, /*@observer@*/ constraintExpr p_expr1, arithType p_ar2, /*@observer@*/ constraintExpr p_expr2);
 
+static constraint  inequalitySubstituteUnsound  (/*@returned@*/ constraint p_c, constraintList p_p);
 
-static constraint constraint_addOr (/*@returned@*/ constraint orig, /*@observer@*/ constraint or);
+static constraint  inequalitySubstituteStrong  (/*@returned@*/ constraint p_c, constraintList p_p);
 
-static bool resolveOr (/*@observer@*/ constraint c, /*@observer@*/ constraintList list);
+static constraint constraint_searchandreplace (/*@returned@*/ constraint p_c, constraintExpr p_old, constraintExpr p_newExpr);
 
-static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constraintList pre2, constraintList post1);
 
-/*********************************************/
+static constraint constraint_addOr (/*@returned@*/ constraint p_orig, /*@observer@*/ constraint p_orConstr);
 
+static bool resolveOr (/*@temp@*/constraint p_c, /*@observer@*/ /*@temp@*/ constraintList p_list);
 
+static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constraintList p_pre2, constraintList p_post1);
 
 
 /*@only@*/ constraintList constraintList_mergeEnsuresFreeFirst (constraintList list1, constraintList list2)
@@ -52,8 +75,6 @@ static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constrai
   constraintList ret;
   constraintList temp;
 
-  //ret = constraintList_makeNew();
-
   llassert(constraintList_isDefined(list1) );
   llassert(constraintList_isDefined(list2) );
 
@@ -70,15 +91,14 @@ static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constrai
   temp = constraintList_subsumeEnsures (list2, ret);
 
   temp = constraintList_addList (temp, ret);
-
+  constraintList_free(ret);
+  
   DPRINTF(( message ("constraintList_mergeEnsures: returning %s ",
                     constraintList_print(temp) )
                     ));
   
 
   return temp;
-  //ret = constraintList_addList (ret, list2);
-  //return ret;
 }
 
 
@@ -100,106 +120,46 @@ static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constrai
 
   DPRINTF((message ("constraintList_mergeRequires: merging  %s and %s ", constraintList_print (list1), constraintList_print(list2) ) ) );
 
+  if (context_getFlag (FLG_REDUNDANTCONSTRAINTS) )
+    {
+      ret = constraintList_copy(list1);
+      ret = constraintList_addList(ret, list2); 
+      return ret;
+    }
+    
   /* get constraints in list1 not satified by list2 */
-  temp = reflectChanges (list1, list2);
+  temp = constraintList_reflectChanges(list1, list2);
   DPRINTF((message ("constraintList_mergeRequires: temp = %s", constraintList_print(temp) ) ) );
 
 /*get constraints in list2 not satified by temp*/
-  ret = reflectChanges (list2, temp);
+  ret = constraintList_reflectChanges(list2, temp);
  
   DPRINTF((message ("constraintList_mergeRequires: ret =  %s", constraintList_print(ret) ) ) );
   
-  ret = constraintList_addList (ret, temp);
+  ret = constraintList_addListFree (ret, temp);
   
   DPRINTF((message ("constraintList_mergeRequires: returning  %s", constraintList_print(ret) ) ) );
 
   return ret;
 }
 
-void checkArgumentList (/*@out@*/ exprNode temp, exprNodeList arglist, fileloc sequencePoint)
-{
-  temp->requiresConstraints = constraintList_makeNew();
-  temp->ensuresConstraints = constraintList_makeNew();
-  temp->trueEnsuresConstraints = constraintList_makeNew();
-  temp->falseEnsuresConstraints = constraintList_makeNew();
-  
-  exprNodeList_elements (arglist, el)
-    {
-      constraintList temp2;
-      exprNode_exprTraverse (el, FALSE, FALSE, sequencePoint);
-      temp2 = el->requiresConstraints;
-      el->requiresConstraints = exprNode_traversRequiresConstraints(el);
-      constraintList_free(temp2);
-
-      temp2 = el->ensuresConstraints;
-      el->ensuresConstraints  = exprNode_traversEnsuresConstraints(el);
-      constraintList_free(temp2);
-
-      temp->requiresConstraints = constraintList_addList(temp->requiresConstraints,
-                                                           el->requiresConstraints);
-      
-      temp->ensuresConstraints = constraintList_addList(temp->ensuresConstraints,
-                                                          el->ensuresConstraints);
-    }
-  end_exprNodeList_elements;
-  
-}
-
-constraintList checkCall (exprNode fcn, exprNodeList arglist)
+/* old name mergeResolve renamed for czech naming convention */
+void exprNode_mergeResolve (exprNode parent, exprNode child1, exprNode child2)
 {
-  constraintList preconditions;
-  uentry temp;
-  DPRINTF ( (message ("Got call that %s ( %s) ",  exprNode_unparse(fcn),   exprNodeList_unparse (arglist ) ) ) );
+  constraintList temp, temp2;
 
-  temp = exprNode_getUentry (fcn);
+  DPRINTF((message ("magically merging constraint into parent:%s for", exprNode_unparse (parent) )) );
 
-  preconditions = uentry_getFcnPreconditions (temp);
+  DPRINTF((message (" children:  %s and %s", exprNode_unparse (child1), exprNode_unparse(child2) ) ) );
 
-  if (preconditions != constraintList_undefined)
-    {
-      preconditions= constraintList_togglePost (preconditions);   
-      preconditions = constraintList_doSRefFixConstraintParam (preconditions, arglist);
-    }
-  else
-    {
-      if (preconditions == NULL)
-       preconditions = constraintList_makeNew();
-    }
   
-  return preconditions;
-}
-
-constraintList getPostConditions (exprNode fcn, exprNodeList arglist, exprNode fcnCall)
-{
-  constraintList postconditions;
-  uentry temp;
-  DPRINTF ( (message ("Got call that %s ( %s) ",  exprNode_unparse(fcn),   exprNodeList_unparse (arglist ) ) ) );
-
-  temp = exprNode_getUentry (fcn);
-
-  postconditions = uentry_getFcnPostconditions (temp);
-
-  if (postconditions != constraintList_undefined)
-    {
-      postconditions = constraintList_doFixResult (postconditions, fcnCall);
-      postconditions = constraintList_doSRefFixConstraintParam (postconditions, arglist);
-    }
-  else
+  if (exprNode_isUndefined(parent) )
     {
-      postconditions = constraintList_makeNew();
+      llassert (exprNode_isDefined(parent) );
+      return;
     }
   
-  return postconditions;
-}
-
-void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
-{
-  constraintList temp, temp2;
-
-  DPRINTF( (message ("magically merging constraint into parent:%s for", exprNode_unparse (parent) )) );
-
-  DPRINTF( (message (" children:  %s and %s", exprNode_unparse (child1), exprNode_unparse(child2) ) ) );
-
+  
   if (exprNode_isError (child1)  || exprNode_isError(child2) )
     {
       if (exprNode_isError (child1) && !exprNode_isError(child2) )
@@ -220,15 +180,13 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
        else
         {
           llassert(exprNode_isError(child2) );
-          //parent->requiresConstraints = constraintList_makeNew();
-          //parent->ensuresConstraints = constraintList_makeNew();
           return;
         }
      }
 
    llassert(!exprNode_isError (child1)  && ! exprNode_isError(child2) );
    
-   DPRINTF( (message ("Child constraints are %s %s and %s %s",
+   DPRINTF((message ("Child constraints are %s %s and %s %s",
                     constraintList_print (child1->requiresConstraints),
                     constraintList_print (child1->ensuresConstraints),
                     constraintList_print (child2->requiresConstraints),
@@ -241,9 +199,9 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
   parent->requiresConstraints = constraintList_copy (child1->requiresConstraints);
 
   if ( context_getFlag (FLG_ORCONSTRAINT) )
-    temp = reflectChangesOr (child2->requiresConstraints, child1->ensuresConstraints);
+    temp = constraintList_reflectChangesOr (child2->requiresConstraints, child1->ensuresConstraints);
   else
-    temp = reflectChanges (child2->requiresConstraints, child1->ensuresConstraints);
+    temp = constraintList_reflectChanges(child2->requiresConstraints, child1->ensuresConstraints);
 
   temp2 = constraintList_mergeRequires (parent->requiresConstraints, temp);
   constraintList_free(parent->requiresConstraints);
@@ -251,7 +209,7 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
   
   parent->requiresConstraints = temp2;
 
-  DPRINTF( (message ("Parent requires constraints are %s  ",
+  DPRINTF((message ("Parent requires constraints are %s  ",
                     constraintList_print (parent->requiresConstraints)
                     ) ) );
 
@@ -261,7 +219,7 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
                                                           child2->ensuresConstraints);
 
   
-  DPRINTF( (message ("Parent constraints are %s and %s ",
+  DPRINTF((message ("Parent constraints are %s and %s ",
                     constraintList_print (parent->requiresConstraints),
                     constraintList_print (parent->ensuresConstraints)
                     ) ) );
@@ -279,7 +237,7 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
     {
       
       DPRINTF ((message ("Examining %s", constraint_print (el) ) ) );
-      if (!resolve (el, list2) )
+      if (!constraintList_resolve (el, list2) )
        {
          constraint temp;
          temp = constraint_copy(el);
@@ -287,7 +245,7 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
        }
       else
        {
-         DPRINTF ( (message ("Subsuming %s", constraint_print (el) ) ) );
+         DPRINTF ((message ("Subsuming %s", constraint_print (el) ) ) );
        }
     } end_constraintList_elements;
 
@@ -296,12 +254,13 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
 
 
 
+/*used to be reflectChangesFreePre  renamed for Czech naming conventino*/
 /* tries to resolve constraints in list pre2 using post1 */
-/*@only@*/ constraintList reflectChangesFreePre (/*@only@*/ constraintList pre2, /*@observer@*/ constraintList post1)
+/*@only@*/ constraintList constraintList_reflectChangesFreePre (/*@only@*/ constraintList pre2, /*@observer@*/ constraintList post1)
 {
   constraintList ret;
   
-  ret = reflectChanges (pre2, post1);
+  ret = constraintList_reflectChanges(pre2, post1);
 
   constraintList_free (pre2);
   
@@ -309,38 +268,46 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
 }
 
 
+
 /* tries to resolve constraints in list pre2 using post1 */
-/*@only@*/ constraintList reflectChanges (/*@observer@*/ constraintList pre2, /*@observer@*/ constraintList post1)
+
+static /*@only@*/ constraintList reflectChangesNoOr (/*@observer@*/ /*@temp@*/ constraintList pre2, /*@observer@*/ /*@temp@*/ constraintList post1)
 {
   
   constraintList ret;
   constraint temp;
   constraint temp2;
 
+  llassert  (! context_getFlag (FLG_ORCONSTRAINT) );
+
   ret = constraintList_makeNew();
   DPRINTF((message ("reflectChanges: lists %s and %s", constraintList_print(pre2), constraintList_print(post1) )));
   
   constraintList_elements (pre2, el)
     {
-      if (!resolve (el, post1) )
+      if (!constraintList_resolve (el, post1) )
        {
-         temp = substitute (el, post1);
-         if (!resolve (temp, post1) )
+         temp = constraint_substitute (el, post1);
+         if (!constraintList_resolve (temp, post1) )
            {
-             // try inequality substitution
-             //constraint temp2;
-             
-             // the inequality substitution may cause us to lose information
-             //so we don't want to store the result but we do it anyway
+             /* try inequality substitution
+                the inequality substitution may cause us to lose information
+                so we don't want to store the result but we do it anyway
+             */
              temp2 = constraint_copy (temp);
-             //                  if (context_getFlag (FLG_ORCONSTRAINT) )
-                temp2 = inequalitySubstitute (temp2, post1); 
-                     if (!resolve (temp2, post1) )
-                       {
-                         temp2 = inequalitySubstituteUnsound (temp2, post1); 
-                         if (!resolve (temp2, post1) )
-                             ret = constraintList_add (ret, temp2);
-                       }
+             temp2 = inequalitySubstitute (temp2, post1); 
+             if (!constraintList_resolve (temp2, post1) )
+               {
+                 temp2 = inequalitySubstituteUnsound (temp2, post1); 
+                 if (!constraintList_resolve (temp2, post1) )
+                   ret = constraintList_add (ret, temp2);
+                 else
+                   constraint_free(temp2);
+               }
+             else
+               {
+                 constraint_free(temp2);
+               }
            }
          constraint_free(temp);
        }
@@ -350,19 +317,36 @@ void mergeResolve (exprNode parent, exprNode child1, exprNode child2)
     return ret;
 }
 
+/* tries to resolve constraints in list pre2 using post1 */
+/*@only@*/ constraintList constraintList_reflectChanges(/*@observer@*/ constraintList pre2, /*@observer@*/ constraintList post1)
+{
+  constraintList temp;
+  
+  if ( context_getFlag (FLG_ORCONSTRAINT) )
+    
+    temp = constraintList_reflectChangesOr (pre2, post1);
+  else
+    temp = reflectChangesNoOr(pre2, post1);
+
+  return temp;                          
+}
 
-static constraint constraint_addOr (/*@returned@*/ constraint orig, /*@observer@*/ constraint or)
+static constraint constraint_addOr (/*@returned@*/ constraint orig, /*@observer@*/ constraint orConstr)
 {
   constraint c;
+
+  llassert(constraint_isDefined(orig) );
+  
   c = orig;
 
-  DPRINTF((message("constraint_addor: oring %s onto %s", constraint_printOr(or), constraint_printOr(orig) ) ));
+  DPRINTF((message("constraint_addor: oring %s onto %s", constraint_printOr(orConstr), constraint_printOr(orig) ) ));
   
   while (c->or != NULL)
     {
       c = c->or;
     }
-  c->or = constraint_copy(or);
+  
+  c->or = constraint_copy(orConstr);
 
   DPRINTF((message("constraint_addor: returning %s",constraint_printOr(orig) ) ));
   
@@ -370,18 +354,27 @@ static constraint constraint_addOr (/*@returned@*/ constraint orig, /*@observer@
 }
 
 
-static bool resolveOr (/*@observer@*/ constraint c, /*@observer@*/ constraintList list)
+static bool resolveOr ( /*@temp@*/ constraint c, /*@observer@*/ /*@temp@*/ constraintList list)
 {
   constraint temp;
 
+  int numberOr;
+
+  numberOr = 0;
+
+    llassert(constraint_isDefined(c) );
+
   DPRINTF(( message("resolveOr: constraint %s and list %s", constraint_printOr(c), constraintList_print(list) ) ));
+  
   temp = c;
 
   do
     {
-      if (resolve (temp, list) )
+      if (constraintList_resolve (temp, list) )
        return TRUE;
       temp = temp->or;
+      numberOr++;
+      llassert(numberOr <= 10);
     }
   while (constraint_isDefined(temp));
 
@@ -393,60 +386,153 @@ static bool resolveOr (/*@observer@*/ constraint c, /*@observer@*/ constraintLis
 static /*@only@*/ constraint doResolve (/*@only@*/ constraint c, constraintList post1, bool * resolved)
 {
   constraint temp;
+
+  llassert(constraint_isDefined (c ) );
+
+  DPRINTF((message("doResolve:: call on constraint c = : %q and constraintList %q",
+                  constraint_printOr(c), constraintList_print(post1)
+                  )
+          ));
+  
+  if (!resolveOr (c, post1) )
+    {
+      
+      temp = constraint_substitute (c, post1);
+      
+      DPRINTF((message("doResolve:: after substitute temp is %q",
+                  constraint_printOr(temp)
+                      )
+              ));
   
if (!resolveOr (c, post1) )
     if (!resolveOr (temp, post1) )
        {
-
-         temp = substitute (c, post1);
+         /* try inequality substitution */
+         constraint temp2;
          
-         if (!resolveOr (temp, post1) )
+         /* the inequality substitution may cause us to lose information
+            so we don't want to store the result but we do  anyway
+         */
+         temp2 = constraint_copy (c);
+         temp2 = inequalitySubstitute (temp2, post1);
+
+         if (!resolveOr (temp2, post1) )
            {
-             // try inequality substitution
-             constraint temp2;
+             constraint temp3;
+             temp3 = constraint_copy(temp2);
              
-             // the inequality substitution may cause us to lose information
-             //so we don't want to store the result but we do it anyway
-             temp2 = constraint_copy (c);
-             //                  if (context_getFlag (FLG_ORCONSTRAINT) )
-             temp2 = inequalitySubstitute (temp2, post1); 
-             if (!resolveOr (temp2, post1) )
+             temp3 = inequalitySubstituteStrong (temp3, post1);
+             if (!resolveOr (temp3, post1) )
                {
                  temp2 = inequalitySubstituteUnsound (temp2, post1); 
                  if (!resolveOr (temp2, post1) )
                    {
                      if (!constraint_same (temp, temp2) )
-                       temp = constraint_addOr (temp, temp2);
+                       {
+                         /* drl added 8/28/2002*/
+                         /*make sure that the information from
+                           a post condition like i = i + 1 is transfered
+                         */
+                         constraint tempSub;
+                         tempSub = constraint_substitute (temp2, post1);
+
+                         DPRINTF((
+                                  message("doResolve: adding %s ",
+                                          constraint_printOr(tempSub)
+                                          )
+                                  ));
+                         
+                         DPRINTF((
+                                  message("doResolve: not adding %s ",
+                                          constraint_printOr(temp2)
+                                          )
+                                  ));
+                         
+                         temp = constraint_addOr (temp, tempSub);
+                         constraint_free(tempSub);
+                         
+                       }
+                     if (!constraint_same (temp, temp3) && !constraint_same (temp3, temp2) )
+                       {
+                        /* drl added 8/28/2002*/
+                         /*make sure that the information from
+                           a post condition like i = i + 1 is transfered
+                         */
+                         constraint tempSub;
+                         
+                         tempSub = constraint_substitute (temp3, post1);
+
+                         DPRINTF((
+                                  message("doResolve: adding %s ",
+                                          constraint_printOr(tempSub)
+                                          )
+                                  ));
+
+                         
+                         DPRINTF((
+                                  message("doResolve: not adding %s ",
+                                          constraint_printOr(temp3)
+                                          )
+                                  ));
+
+                         temp = constraint_addOr (temp, tempSub);
+
+                         constraint_free(tempSub);
+                       }
                      *resolved = FALSE;
-
+                     
                      constraint_free(temp2);
+                     constraint_free(temp3);
                      constraint_free(c);
-         
+                     
                      return temp;
                    }
+                 constraint_free(temp2);
+                 constraint_free(temp3);
+               }
+             else
+               {
+                 constraint_free(temp2);
+                 constraint_free(temp3);
                }
-             
-             constraint_free(temp2);
            }
-         constraint_free(temp);
+         else
+           {
+             constraint_free(temp2);
+           }             
+         
        }
- constraint_free(c);
- *resolved = TRUE;
- return NULL;
-
-
-
+      constraint_free(temp);
+    }
+  constraint_free(c);
+  
+  *resolved = TRUE;
+  return NULL;
 }
 
-static /*@only@*/ constraint doResolveOr (constraint c, constraintList post1, /*@out@*/bool * resolved)
+static /*@only@*/ constraint doResolveOr (/*@observer@*/ /*@temp@*/ constraint c, constraintList post1, /*@out@*/bool * resolved)
 {
   constraint ret;
   constraint next;
   constraint curr;
+
+  
+  DPRINTF(( message("doResolveOr: constraint %s and list %s", constraint_printOr(c), constraintList_print(post1) ) ));
+
+
   
-  *resolved = FALSE;
+   *resolved = FALSE;
+
+  llassert(constraint_isDefined(c) );
+
   ret = constraint_copy(c);
+
+  llassert(constraint_isDefined(ret) );
+
+  if (constraintList_isEmpty(post1) )
+    {
+      return ret;
+    }
+  
   next = ret->or;
   ret->or = NULL;
 
@@ -454,11 +540,15 @@ static /*@only@*/ constraint doResolveOr (constraint c, constraintList post1, /*
 
   if (*resolved)
     {
-      constraint_free(next);
-      constraint_free(ret);
+      if (next != NULL)
+       constraint_free(next);
+      
+      /*we don't need to free ret when resolved is false because ret is null*/
+      llassert(ret == NULL);
+      
       return NULL;
     }
-
+  
   while (next != NULL)
     {
       curr = next;
@@ -466,31 +556,32 @@ static /*@only@*/ constraint doResolveOr (constraint c, constraintList post1, /*
       curr->or = NULL;
 
       curr = doResolve (curr, post1, resolved);
-      if (*resolved)
+      
+       if (*resolved)
        {
-         constraint_free(curr);
-         constraint_free(next);
+         /* curr is null so we don't try to free it*/
+         llassert(curr == NULL);
+         
+         if (next != NULL)
+           constraint_free(next);
+
          constraint_free(ret);
          return NULL;
        }
       ret = constraint_addOr (ret, curr);
+      constraint_free(curr);
     }
-  constraint_free(curr);
   return ret;
 }
 
-
-
-
-
 /* tries to resolve constraints in list pr2 using post1 */
-/*@only@*/ constraintList reflectChangesOr (constraintList pre2, constraintList post1)
+/*@only@*/ constraintList constraintList_reflectChangesOr (constraintList pre2, constraintList post1)
 {
   bool resolved;
   constraintList ret;
   constraint temp;
   ret = constraintList_makeNew();
-  DPRINTF((message ("reflectChangesOr: lists %s and %s", constraintList_print(pre2), constraintList_print(post1) )));
+  DPRINTF((message ("constraintList_reflectChangesOr: lists %s and %s", constraintList_print(pre2), constraintList_print(post1) )));
   
   constraintList_elements (pre2, el)
     {
@@ -500,11 +591,19 @@ static /*@only@*/ constraint doResolveOr (constraint c, constraintList post1, /*
        {
          ret = constraintList_add(ret, temp);
        }
+      else
+       {
+     /* we don't need to free temp when
+       resolved is false because temp is null */
+         llassert(temp == NULL);
+       }
+      
     } end_constraintList_elements;
 
-    DPRINTF((message ("reflectChangesOr: returning %s", constraintList_print(ret) ) ) );
+  DPRINTF((message ("constraintList_reflectChangesOr: returning %s", constraintList_print(ret) ) ) );
     return ret;
 }
+
 static /*@only@*/ constraintList reflectChangesEnsures (/*@observer@*/ constraintList pre2, constraintList post1)
 {  
   constraintList ret;
@@ -512,17 +611,19 @@ static /*@only@*/ constraintList reflectChangesEnsures (/*@observer@*/ constrain
   ret = constraintList_makeNew();
   constraintList_elements (pre2, el)
     {
-      if (!resolve (el, post1) )
+      if (!constraintList_resolve (el, post1) )
        {
-         temp = substitute (el, post1);
+         temp = constraint_substitute (el, post1);
          llassert (temp != NULL);
 
-         if (!resolve (temp, post1) )
+         if (!constraintList_resolve (temp, post1) )
            ret = constraintList_add (ret, temp);
+         else
+           constraint_free(temp);  
        }
       else
        {
-         DPRINTF ( (message ("Resolved away %s ", constraint_print(el) ) ) );
+         DPRINTF ((message ("Resolved away %s ", constraint_print(el) ) ) );
        }
     } end_constraintList_elements;
 
@@ -544,27 +645,63 @@ static /*@only@*/ constraintList reflectChangesEnsuresFree1 (/*@only@*/ constrai
 
 static bool constraint_conflict (constraint c1, constraint c2)
 {
-  
+
+  llassert(constraint_isDefined(c1) );
+  llassert(constraint_isDefined(c2) );
+
   if (constraintExpr_similar(c1->lexpr, c2->lexpr) )
     {
       if (c1->ar == EQ)
        if (c1->ar == c2->ar)
          {
-           DPRINTF ( (message ("%s conflicts with %s ", constraint_print (c1), constraint_print(c2) ) ) );
+           DPRINTF ((message ("%s conflicts with %s ", constraint_print (c1), constraint_print(c2) ) ) );
            return TRUE;
          }
     }  
 
-  DPRINTF ( (message ("%s doesn't conflict with %s ", constraint_print (c1), constraint_print(c2) ) ) );
+  /* This is a slight kludg to prevent circular constraints like
+     strlen(str) == maxRead(s) + strlen(str);
+  */
+
+  /*@i324234*/ /*this code is functional but it may be worth cleaning up at some point. */
+  
+  if (c1->ar == EQ)
+    if (c1->ar == c2->ar)
+      {
+       if (constraintExpr_search (c1->lexpr, c2->expr) )
+         if (constraintExpr_isTerm(c1->lexpr) )
+           {
+             constraintTerm term;
+             
+             term = constraintExpr_getTerm(c1->lexpr);
+
+             if (constraintTerm_isExprNode(term) )
+               {
+                 DPRINTF ((message ("%s conflicts with %s ", constraint_print (c1), constraint_print(c2) ) ) );
+                 return TRUE;
+               }
+           }
+      }
+
+  if (constraint_tooDeep(c1) || constraint_tooDeep(c2) )
+       {
+         DPRINTF ((message ("%s conflicts with %s (constraint is too deep", constraint_print (c1), constraint_print(c2) ) ) );
+         return TRUE;
+       }
+  
+  DPRINTF ((message ("%s doesn't conflict with %s ", constraint_print (c1), constraint_print(c2) ) ) );
 
   return FALSE; 
 
 }
 
-static void constraint_fixConflict ( constraint good, /*@observer@*/ constraint conflicting) /*@modifies good@*/
+static void constraint_fixConflict (/*@temp@*/ constraint good, /*@temp@*/ /*@observer@*/ constraint conflicting) /*@modifies good@*/
 {
+  llassert(constraint_isDefined(conflicting) );
+  
   if (conflicting->ar ==EQ )
     {
+      llassert(constraint_isDefined(good) );
       good->expr = constraintExpr_searchandreplace (good->expr, conflicting->lexpr, conflicting->expr);
       good = constraint_simplify (good);
     }
@@ -588,8 +725,11 @@ static bool conflict (constraint c, constraintList list)
 
 }
 
-//check if constraint in list1 conflicts with constraints in List2.  If so we
-//remove form list1 and change list2.
+/*
+  check if constraint in list1 conflicts with constraints in List2.  If so we
+  remove form list1 and change list2.
+*/
+
 constraintList constraintList_fixConflicts (constraintList list1, constraintList list2)
 {
   constraintList ret;
@@ -611,6 +751,9 @@ constraintList constraintList_fixConflicts (constraintList list1, constraintList
 /*returns true if constraint post satifies cosntriant pre */
 static bool satifies (constraint pre, constraint post)
 {
+  llassert(constraint_isDefined(pre) );
+  llassert(constraint_isDefined(post) );
+
   if (constraint_isAlwaysTrue (pre)  )
     return TRUE;
   
@@ -618,7 +761,7 @@ static bool satifies (constraint pre, constraint post)
     {
       return FALSE;
     }
-  if (post->expr == NULL)
+  if (constraintExpr_isUndefined(post->expr))
     {
       llassert(FALSE);
       return FALSE;
@@ -628,19 +771,19 @@ static bool satifies (constraint pre, constraint post)
 }
 
 
-bool resolve (/*@observer@*/ constraint c, /*@observer@*/ constraintList p)
+bool constraintList_resolve (/*@temp@*/ /*@observer@*/ constraint c, /*@temp@*/ /*@observer@*/ constraintList p)
 {
   constraintList_elements (p, el)
     {
       if ( satifies (c, el) )
        {
-         DPRINTF ( (message ("\n%s Satifies %s\n ", constraint_print(el), constraint_print(c) ) ) );
+         DPRINTF ((message ("\n%s Satifies %s\n ", constraint_print(el), constraint_print(c) ) ) );
          return TRUE;
        }
-        DPRINTF ( (message ("\n%s does not satify %s\n ", constraint_print(el), constraint_print(c) ) ) );
+        DPRINTF ((message ("\n%s does not satify %s\n ", constraint_print(el), constraint_print(c) ) ) );
     }
   end_constraintList_elements;
-  DPRINTF ( (message ("no constraints satify %s", constraint_print(c) ) ));
+  DPRINTF ((message ("no constraints satify %s", constraint_print(c) ) ));
   return FALSE;
 }
 
@@ -650,7 +793,7 @@ static bool arithType_canResolve (arithType ar1, arithType ar2)
     {
     case GTE:
     case GT:
-      if ( (ar2 == GT) || (ar2 == GTE) || (ar2 == EQ) )
+      if ((ar2 == GT) || (ar2 == GTE) || (ar2 == EQ) )
        {
          return TRUE;
        }
@@ -663,8 +806,7 @@ static bool arithType_canResolve (arithType ar1, arithType ar2)
 
     case LT:
     case LTE:
-      //      llassert(FALSE); 
-      if ( (ar2 == LT) || (ar2 == LTE) || (ar2 == EQ) )
+      if ((ar2 == LT) || (ar2 == LTE) || (ar2 == EQ) )
        return TRUE;
       break;
     default:
@@ -673,19 +815,159 @@ static bool arithType_canResolve (arithType ar1, arithType ar2)
   return FALSE;          
 }
 
+/*checks for the case expr2 == sizeof buf1  and buf1 is a fixed array*/
+static bool  sizeofBufComp(constraintExpr buf1, constraintExpr expr2)
+{
+  constraintTerm ct;
+  exprNode e, t;
+  sRef s1, s2;
+
+  llassert(constraintExpr_isDefined(buf1) && constraintExpr_isDefined(expr2) );
+
+  /*@access constraintExpr@*/
+  
+  if ((expr2->kind != term) && (buf1->kind != term) )
+    return FALSE;
+
+  
+  ct = constraintExprData_termGetTerm(expr2->data);
+
+  if (!constraintTerm_isExprNode(ct) )
+    return FALSE;
+
+  e = constraintTerm_getExprNode(ct);
+
+  llassert(exprNode_isDefined(e) );
+
+  if (! (exprNode_isDefined(e) ) )
+    return FALSE;
+  
+  if (e->kind != XPR_SIZEOF)
+    return FALSE;
+  
+  t = exprData_getSingle (e->edata);
+  s1 = exprNode_getSref (t);
+
+  s2 = constraintTerm_getsRef(constraintExprData_termGetTerm(buf1->data) );
+
+  /*@i223@*/ /*this may be the wronge thing to test for */
+  if (sRef_similarRelaxed(s1, s2)   || sRef_sameName (s1, s2) )
+    {
+      /*@i22*/ /* get rid of this test of now */
+      /* if (ctype_isFixedArray (sRef_getType (s2) ) ) */
+       return TRUE;
+    }
+  return FALSE;
+}
+
+/* look for the special case of
+   maxSet(buf) >= sizeof(buf) - 1
+*/
+
+/*@i223@*/ /*need to add some type checking */
+
+static bool sizeOfMaxSet( /*@observer@*/ /*@temp@*/ constraint c)
+{
+  constraintExpr l, r, buf1, buf2, con;
+
+  DPRINTF(( message("sizeOfMaxSet: checking %s ", constraint_print(c) )
+           ));
+
+  llassert (constraint_isDefined(c) );
+    
+  l = c->lexpr;
+  r = c->expr;
+
+  if (!((c->ar == EQ) || (c->ar == GTE) || (c->ar == LTE) ) )
+    return FALSE;
+
+  llassert (constraintExpr_isDefined(l)  );
+  llassert (constraintExpr_isDefined(r)  );
+
+  /*check if the constraintExpr is MaxSet(buf) */
+  if (l->kind == unaryExpr)
+    {
+      if (constraintExprData_unaryExprGetOp(l->data) == MAXSET)
+       {
+         buf1 = constraintExprData_unaryExprGetExpr(l->data);
+       }
+      else
+       return FALSE;
+    }
+  else
+    return FALSE;
+
+  
+  if (r->kind != binaryexpr)
+    return FALSE;
+  
+  buf2 = constraintExprData_binaryExprGetExpr1(r->data);
+  con = constraintExprData_binaryExprGetExpr2(r->data);
+  
+  if (constraintExprData_binaryExprGetOp(r->data) == BINARYOP_MINUS)
+    {
+      if (constraintExpr_canGetValue(con) )
+       {
+         long i;
+         
+         i = constraintExpr_getValue(con);
+         if (i != 1)
+           {
+             return FALSE;
+           }
+       }
+      else
+       return FALSE;
+    }
+
+  if (constraintExprData_binaryExprGetOp(r->data) == BINARYOP_PLUS)
+    {
+      if (constraintExpr_canGetValue(con) )
+       {
+         long i;
+         
+         i = constraintExpr_getValue(con);
+         if (i != -1)
+           {
+             return FALSE;
+           }
+       }
+      else
+       return FALSE;
+    }
+
+  if (sizeofBufComp(buf1, buf2))
+    {
+      return TRUE;
+    }
+  else
+    {
+     return FALSE;
+    } 
+    
+
+}
+/*@noaccess constraintExpr@*/
+
 /* We look for constraint which are tautologies */
 
-bool constraint_isAlwaysTrue (/*@observer@*/ constraint c)
+bool constraint_isAlwaysTrue (/*@observer@*/ /*@temp@*/ constraint c)
 {
   constraintExpr l, r;
-  bool /*@unused@*/ lHasConstant, rHasConstant;
-  int /*@unused@*/ lConstant, rConstant;
+  bool rHasConstant;
+  int rConstant;
+
+  
+  llassert (constraint_isDefined(c) );  
   
   l = c->lexpr;
   r = c->expr;
 
   DPRINTF(( message("constraint_IsAlwaysTrue:examining %s", constraint_print(c) ) ));
-    
+
+  if (sizeOfMaxSet(c) )
+    return TRUE;
+  
   if (constraintExpr_canGetValue(l) && constraintExpr_canGetValue(r) )
     {
       int cmp;
@@ -732,7 +1014,6 @@ bool constraint_isAlwaysTrue (/*@observer@*/ constraint c)
   l = constraintExpr_copy (c->lexpr);
   r = constraintExpr_copy (c->expr);
 
-  //  l = constraintExpr_propagateConstants (l, &lHasConstant, &lConstant);
   r = constraintExpr_propagateConstants (r, &rHasConstant, &rConstant);
 
   if (constraintExpr_similar (l,r) && (rHasConstant ) )
@@ -784,101 +1065,118 @@ static bool rangeCheck (arithType ar1, /*@observer@*/ constraintExpr expr1, arit
   switch (ar1)
  {
  case GTE:
-      if (constraintExpr_similar (expr1, expr2) )
-        return TRUE;
-      /*@fallthrough@*/
- case GT:
-   if (!  (constraintExpr_canGetValue (expr1) &&
-          constraintExpr_canGetValue (expr2) ) )
-     {
-       constraintExpr e1, e2;
-       bool p1, p2;
-       int const1, const2;
-       
-       e1 = constraintExpr_copy(expr1);
-       e2 = constraintExpr_copy(expr2);
-
-       e1 = constraintExpr_propagateConstants (e1, &p1, &const1);
-
-       e2 = constraintExpr_propagateConstants (e2, &p2, &const2);
-
-       if (p1 && p2)
-        if (const1 <= const2)
-          if (constraintExpr_similar (e1, e2) )
-            {
-              constraintExpr_free(e1);
-              constraintExpr_free(e2);
-              return TRUE;
-            }
-       
-       DPRINTF( ("Can't Get value"));
-       
-       constraintExpr_free(e1);
-       constraintExpr_free(e2);
-       return FALSE;
-     }
-   
-   if (constraintExpr_compare (expr2, expr1) >= 0)
-     return TRUE;
-  
-  return FALSE;
- case EQ:
-   if (constraintExpr_similar (expr1, expr2) )
-        return TRUE;
-   
-   return FALSE;
- case LTE:
-   if (constraintExpr_similar (expr1, expr2) )
-        return TRUE;
-   /*@fallthrough@*/
- case LT:
+       if (constraintExpr_similar (expr1, expr2) )
+         return TRUE;
+       /*@fallthrough@*/
+  case GT:
     if (!  (constraintExpr_canGetValue (expr1) &&
-          constraintExpr_canGetValue (expr2) ) )
-     {
-      constraintExpr e1, e2;
-       bool p1, p2;
-       int const1, const2;
-       
-       e1 = constraintExpr_copy(expr1);
-       e2 = constraintExpr_copy(expr2);
-
-       e1 = constraintExpr_propagateConstants (e1, &p1, &const1);
-
-       e2 = constraintExpr_propagateConstants (e2, &p2, &const2);
-
-       if (p1 && p2)
-        if (const1 >= const2)
-          if (constraintExpr_similar (e1, e2) )
-            {
-              constraintExpr_free(e1);
-              constraintExpr_free(e2);
-              return TRUE;
-            }
-       constraintExpr_free(e1);
-       constraintExpr_free(e2);
-       
-       DPRINTF( ("Can't Get value"));
-       return FALSE;
-     }
-   
-   if (constraintExpr_compare (expr2, expr1) <= 0)
-     return TRUE;
+              constraintExpr_canGetValue (expr2) ) )
+           {
+                 constraintExpr e1, e2;
+                 bool p1, p2;
+                 int const1, const2;
+
+                 e1 = constraintExpr_copy(expr1);
+                 e2 = constraintExpr_copy(expr2);
+
+                 e1 = constraintExpr_propagateConstants (e1, &p1, &const1);
+
+                 e2 = constraintExpr_propagateConstants (e2, &p2, &const2);
+
+                 if (p1 || p2)
+                    {
+                     if (!p1)
+                          const1 = 0;
+
+                     if (!p2)
+                          const2 = 0;
+
+                     if (const1 <= const2)
+                          if (constraintExpr_similar (e1, e2) )
+                                 {
+                                        constraintExpr_free(e1);
+                                        constraintExpr_free(e2);
+                                        return TRUE;
+                                      }
+                     }
+                 DPRINTF(("Can't Get value"));
+
+                 constraintExpr_free(e1);
+                 constraintExpr_free(e2);
+                 return FALSE;
+               }
+
+    if (constraintExpr_compare (expr2, expr1) >= 0)
+           return TRUE;
 
    return FALSE;
-   
- default:
-     llcontbug((message("Unhandled case in switch: %q", arithType_print(ar1) ) ) );
- }
+  case EQ:
+    if (constraintExpr_similar (expr1, expr2) )
+       return TRUE;
+
+    return FALSE;
+  case LTE:
+    if (constraintExpr_similar (expr1, expr2) )
+       return TRUE;
+    /*@fallthrough@*/
+  case LT:
+     if (!  (constraintExpr_canGetValue (expr1) &&
+               constraintExpr_canGetValue (expr2) ) )
+            {
+                 constraintExpr e1, e2;
+                  bool p1, p2;
+                  int const1, const2;
+
+                  e1 = constraintExpr_copy(expr1);
+                  e2 = constraintExpr_copy(expr2);
+
+                  e1 = constraintExpr_propagateConstants (e1, &p1, &const1);
+
+                  e2 = constraintExpr_propagateConstants (e2, &p2, &const2);
+
+                  if (p1 || p2)
+                     {
+                      if (!p1)
+                           const1 = 0;
+
+                      if (!p2)
+                           const2 = 0;
+
+                      if (const1 >= const2)
+                           if (constraintExpr_similar (e1, e2) )
+                                  {
+                                         constraintExpr_free(e1);
+                                         constraintExpr_free(e2);
+                                         return TRUE;
+                                       }
+                      }
+                  constraintExpr_free(e1);
+                  constraintExpr_free(e2);
+
+                  DPRINTF(("Can't Get value"));
+                  return FALSE;
+                }
+
+    if (constraintExpr_compare (expr2, expr1) <= 0)
+           return TRUE;
+
+    return FALSE;
+
+  default:
+      llcontbug((message("Unhandled case in switch: %q", arithType_print(ar1) ) ) );
+  }
   BADEXIT;
 }
 
-
-static constraint constraint_searchandreplace (/*@returned@*/ constraint c, constraintExpr old, constraintExpr new)
+static constraint constraint_searchandreplace (/*@returned@*/ constraint c, constraintExpr old, constraintExpr newExpr)
 {
+   llassert (constraint_isDefined(c)  );
+
   DPRINTF (("Doing replace for lexpr") );
-  c->lexpr = constraintExpr_searchandreplace (c->lexpr, old, new);
+  
+  c->lexpr = constraintExpr_searchandreplace (c->lexpr, old, newExpr);
   DPRINTF (("Doing replace for expr") );
-  c->expr = constraintExpr_searchandreplace (c->expr, old, new);
+  c->expr = constraintExpr_searchandreplace (c->expr, old, newExpr);
   return c;
 }
 
@@ -886,34 +1184,36 @@ bool constraint_search (constraint c, constraintExpr old) /*@*/
 {
   bool ret;
   ret = FALSE;
-
+  
+  llassert (constraint_isDefined(c)  );
+  
   ret  = constraintExpr_search (c->lexpr, old);
   ret = ret || constraintExpr_search (c->expr, old);
   return ret;
 }
 
-//adjust file locs and stuff
+/* adjust file locs and stuff */
 static constraint constraint_adjust (/*@returned@*/ constraint substitute, /*@observer@*/ constraint old)
 {
   fileloc loc1, loc2, loc3;
 
-  DPRINTF ( (message("Start adjust on %s and %s", constraint_print(substitute),
+  DPRINTF ((message("Start adjust on %s and %s", constraint_print(substitute),
                     constraint_print(old))
                   ));
 
+  llassert(constraint_isDefined(substitute));
+  llassert(constraint_isDefined(old));
+          
   loc1 = constraint_getFileloc (old);
-
   loc2 = constraintExpr_getFileloc (substitute->lexpr);
-
   loc3 = constraintExpr_getFileloc (substitute->expr);
-
   
-  // special case of an equality that "contains itself"
+  /* special case of an equality that "contains itself" */
   if (constraintExpr_search (substitute->expr, substitute->lexpr) )
       if (fileloc_closer (loc1, loc3, loc2))
       {
        constraintExpr temp;
-       DPRINTF ( (message("Doing adjust on %s", constraint_print(substitute) )
+       DPRINTF ((message("Doing adjust on %s", constraint_print(substitute) )
                   ));
        temp = substitute->lexpr;
        substitute->lexpr = substitute->expr;
@@ -935,28 +1235,29 @@ static constraint constraint_adjust (/*@returned@*/ constraint substitute, /*@ob
 
    Warning this is sound but throws out information
  */
+
 constraint  inequalitySubstitute  (/*@returned@*/ constraint c, constraintList p)
 {
+  llassert(constraint_isDefined(c) );
+
   if (c->ar != GTE)
     return c;
   
   constraintList_elements (p, el)
     {
-       if ( el->ar == LT)
-        //      if (!constraint_conflict (c, el) )
+      
+      llassert(constraint_isDefined(el) );
+      
+      if ((el->ar == LT )  )
+       /* if (!constraint_conflict (c, el) ) */ /*@i523 explain this! */
           {
-            //constraint temp;
             constraintExpr  temp2;
             
             /*@i22*/
 
-            //temp = constraint_copy(el);
-            
-            //      temp = constraint_adjust(temp, c);
-
             if (constraintExpr_same (el->expr, c->expr) )
               {
-                DPRINTF((message ("inequalitySubstitute Replacing %s in %s with  %s",
+                DPRINTF((message ("inequalitySubstitute Replacing %q in %q with  %q",
                                   constraintExpr_print (c->expr),
                                   constraint_print (c),
                                   constraintExpr_print (el->expr) )
@@ -964,6 +1265,74 @@ constraint  inequalitySubstitute  (/*@returned@*/ constraint c, constraintList p
                 temp2   = constraintExpr_copy (el->lexpr);
                 constraintExpr_free(c->expr);
                 c->expr =  constraintExpr_makeIncConstraintExpr (temp2);
+
+              }
+            
+          }
+    }
+  end_constraintList_elements;
+
+  c = constraint_simplify(c);
+  return c;
+}
+
+
+/* drl7x 7/26/001
+
+   THis function is like inequalitySubstitute but it adds the rule
+   added the rules x >= y &&  y <= b  ===> x >= b
+    x >= y &&  y < b  ===> x >= b + 1
+
+   This is sound but sonce it throws out additional information it should only one used
+   if we're oring constraints.
+ */
+
+static constraint  inequalitySubstituteStrong  (/*@returned@*/ constraint c, constraintList p)
+{
+  DPRINTF (( message ("inequalitySubstituteStrong examining substituting for %q", constraint_print(c) ) ));      
+
+  llassert(constraint_isDefined(c) );
+
+  if (! (constraint_isDefined(c) ) )
+  {
+    return c;
+  }
+  
+  if (c->ar != GTE)
+    return c;
+  
+  DPRINTF (( message ("inequalitySubstituteStrong examining substituting for %q with %q",
+                     constraint_print(c), constraintList_print(p) ) ));      
+  constraintList_elements (p, el)
+    {
+      
+      DPRINTF (( message ("inequalitySubstituteStrong examining substituting %s on %s", constraint_print(el), constraint_print(c) ) ));      
+
+      llassert(constraint_isDefined(el) );
+      if ((el->ar == LT ) ||  (el->ar == LTE )  )
+       /* if (!constraint_conflict (c, el) ) */ /*@i523@*/
+          {
+            constraintExpr  temp2;
+            
+            /*@i22*/
+
+            if (constraintExpr_same (el->lexpr, c->expr) )
+              {
+                DPRINTF((message ("inequalitySubstitute Replacing %s in %s with  %s",
+                                  constraintExpr_print (c->expr),
+                                  constraint_print (c),
+                                  constraintExpr_print (el->expr) )
+                         ));
+                temp2   = constraintExpr_copy (el->expr);
+                constraintExpr_free(c->expr);
+                if ((el->ar == LTE ) )
+                  {
+                    c->expr = temp2;
+                  }
+                else
+                  {
+                    c->expr =  constraintExpr_makeIncConstraintExpr (temp2);
+                  }
               }
             
           }
@@ -974,6 +1343,7 @@ constraint  inequalitySubstitute  (/*@returned@*/ constraint c, constraintList p
   return c;
 }
 
+
 /* This function performs substitutions based on the rule:
    for a constraint of the form expr1 >= expr2;   a < b =>
    a = b -1 for all a in expr1.  This will work in most cases.
@@ -984,22 +1354,23 @@ constraint  inequalitySubstitute  (/*@returned@*/ constraint c, constraintList p
 static constraint  inequalitySubstituteUnsound  (/*@returned@*/ constraint c, constraintList p)
 {
   DPRINTF (( message ("Doing inequalitySubstituteUnsound " ) ));
+
+    llassert(constraint_isDefined(c) );
   
   if (c->ar != GTE)
     return c;
   
   constraintList_elements (p, el)
     {
-  DPRINTF (( message ("inequalitySubstituteUnsound examining substituting %s on %s", constraint_print(el), constraint_print(c) ) ));      
-       if ( ( el->ar == LTE) || (el->ar == LT) )
-        //      if (!constraint_conflict (c, el) )
+
+      llassert(constraint_isDefined(el) );
+
+      DPRINTF (( message ("inequalitySubstituteUnsound examining substituting %s on %s", constraint_print(el), constraint_print(c) ) ));      
+       if (( el->ar == LTE) || (el->ar == LT) )
+        /* if (!constraint_conflict (c, el) ) */ /*@i532@*/
           {
-            // constraint temp;
             constraintExpr  temp2;
-            
-            //temp = constraint_copy(el);
-            
-            //      temp = constraint_adjust(temp, c);
+
             temp2   = constraintExpr_copy (el->expr);
             
             if (el->ar == LT)
@@ -1020,13 +1391,14 @@ static constraint  inequalitySubstituteUnsound  (/*@returned@*/ constraint c, co
   return c;
 }
 
-/*@only@*/ constraint substitute (/*@observer@*/ constraint c, constraintList p)
+/*@only@*/ constraint constraint_substitute (/*@observer@*/ /*@temp@*/ constraint c, constraintList p)
 {
   constraint ret;
 
   ret = constraint_copy(c);
   constraintList_elements (p, el)
     {
+      llassert(constraint_isDefined(el) );
        if ( el->ar == EQ)
         if (!constraint_conflict (ret, el) )
 
@@ -1037,20 +1409,25 @@ static constraint  inequalitySubstituteUnsound  (/*@returned@*/ constraint c, co
             
             temp = constraint_adjust(temp, ret);
 
-            DPRINTF((message ("Substituting %s in the constraint %s",
-                              constraint_print (temp), constraint_print (ret)
+            llassert(constraint_isDefined(temp) );
+
+            
+            DPRINTF((message ("constraint_substitute :: Substituting in %s using %s",
+                              constraint_print (ret), constraint_print (temp)
                               ) ) );
                               
          
             ret = constraint_searchandreplace (ret, temp->lexpr, temp->expr);
-            DPRINTF(( message ("The new constraint is %s", constraint_print (ret) ) ));
+            DPRINTF(( message (" constraint_substitute :: The new constraint is %s", constraint_print (ret) ) ));
             constraint_free(temp);
           }
     }
   end_constraintList_elements;
-  DPRINTF(( message ("The finial new constraint is %s", constraint_print (ret) ) ));
 
   ret = constraint_simplify(ret);
+
+  DPRINTF(( message (" constraint_substitute :: The final new constraint is %s", constraint_print (ret) ) ));
+
   return ret;
 }
 
@@ -1078,10 +1455,9 @@ return ret;
   constraintList_elements(target, el)
   { 
     constraint temp;
-    #warning make sure this side effect is the right things
-    #warning make sure that a side effect is not expected
+    /* drl possible problem : warning make sure that a side effect is not expected */
 
-    temp = substitute(el, subList);
+    temp = constraint_substitute(el, subList);
     ret = constraintList_add (ret, temp);
   }
   end_constraintList_elements;
@@ -1089,11 +1465,14 @@ return ret;
   return ret;
 }
 
-constraint constraint_solve (constraint c)
+static constraint constraint_solve (/*@returned@*/ constraint c)
 {
-  DPRINTF( (message ("Solving %s\n", constraint_print(c) ) ) );
+
+  llassert(constraint_isDefined(c) );
+
+  DPRINTF((message ("Solving %s\n", constraint_print(c) ) ) );
   c->expr = constraintExpr_solveBinaryExpr (c->lexpr, c->expr);
-  DPRINTF( (message ("Solved and got %s\n", constraint_print(c) ) ) );
+  DPRINTF((message ("Solved and got %s\n", constraint_print(c) ) ) );
 
   return c;
 }
@@ -1121,6 +1500,9 @@ static arithType flipAr (arithType ar)
 static constraint  constraint_swapLeftRight (/*@returned@*/ constraint c)
 {
   constraintExpr temp;
+
+  llassert(constraint_isDefined(c) );
+
   c->ar = flipAr (c->ar);
   temp = c->lexpr;
   c->lexpr = c->expr;
@@ -1133,6 +1515,18 @@ static constraint  constraint_swapLeftRight (/*@returned@*/ constraint c)
 
 constraint constraint_simplify ( /*@returned@*/ constraint c)
 {
+  
+  llassert(constraint_isDefined(c) );
+       
+  DPRINTF(( message("constraint_simplify on %q ", constraint_print(c) ) ));
+
+  if (constraint_tooDeep(c))
+    {
+        DPRINTF(( message("constraint_simplify: constraint to complex aborting %q ", constraint_print(c) ) ));
+      return c;
+
+    }
+  
   c->lexpr = constraintExpr_simplify (c->lexpr);
   c->expr  = constraintExpr_simplify (c->expr);
 
@@ -1150,6 +1544,9 @@ constraint constraint_simplify ( /*@returned@*/ constraint c)
       /*I don't think this will be an infinate loop*/
       c = constraint_simplify(c);
     }
+
+  DPRINTF(( message("constraint_simplify returning  %q ", constraint_print(c) ) ));
+
   return c;
 }
 
This page took 0.110648 seconds and 4 git commands to generate.