]> andersk Git - splint.git/blobdiff - src/constraintList.c
Trying to add dummyfile to be bin to stay in the repository.\18
[splint.git] / src / constraintList.c
index 65c243d56477a3f7468f0f56e7af3140b8652541..99dc7e747e9b6438f50d6e731dec52fcca54cba2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-** LCLint - annotation-assisted static program checker
+** Splint - annotation-assisted static program checker
 ** Copyright (C) 1994-2000 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
-** For more information: http://lclint.cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
+** For more information: http://www.splint.org
 */
+
 /*
 ** constraintList.c
 **
@@ -29,7 +30,7 @@
 ** where T has T_equal (or change this) and T_unparse
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
 
 
@@ -91,7 +92,7 @@ constraintList_add (/*@returned@*/ constraintList s, /*@only@*/ constraint el)
   llassert (constraintList_isDefined (s));
 
   /*drl7x */
-  //   el = constraint_simplify (el);
+
   if (constraintList_resolve (el, s) )
     {
       constraint_free (el);
@@ -124,7 +125,7 @@ static void constraintList_freeShallow (/*@only@*/ constraintList c)
   c = NULL;
 }
 
-/*@only@*/ constraintList constraintList_addList (/*@only@*/ /*@returned@*/ constraintList s, /*@observer@*/ constraintList newList)
+/*@only@*/ constraintList constraintList_addList (/*@only@*/ /*@returned@*/ constraintList s, /*@observer@*/ /*@temp@*/ constraintList newList)
 {
   llassert(constraintList_isDefined(s) );
   llassert(constraintList_isDefined(newList) );
@@ -160,11 +161,100 @@ constraintList constraintList_addListFree (/*@returned@*/ constraintList s, /*@o
 }
 
 
+constraintList constraintList_removeSurpressed (/*@only@*/ constraintList s)
+{
+  constraintList ret;
+  fileloc loc;
+  llassert(constraintList_isDefined(s) );
+
+  ret = constraintList_makeNew();
+  
+  constraintList_elements_private_only(s, elem)
+    {
+      loc = constraint_getFileloc(elem);
+
+      if (fileloc_isUndefined(loc))
+       {
+         ret = constraintList_add (ret, elem);
+       }
+      
+      else if (context_suppressFlagMsg(FLG_BOUNDSWRITE, loc) )
+       {
+         DPRINTF ((message ("constraintList_removeSurpressed getting rid of surpressed constraint %q", 
+                            constraint_print(elem))));
+         constraint_free(elem);
+       }
+      
+      else if (!constraint_hasMaxSet(elem) && context_suppressFlagMsg(FLG_BOUNDSREAD, loc))
+       {
+         DPRINTF ((message("constraintList_removeSurpressed getting rid of surpressed constraint %q", 
+                           constraint_print(elem))));
+         constraint_free(elem);
+       }
+      else
+       {
+         ret = constraintList_add (ret, elem);
+       } 
+      fileloc_free(loc);
+    } 
+  end_constraintList_elements_private_only;
+
+  constraintList_freeShallow(s);
+  
+  return ret;
+}
+
+
 extern /*@only@*/ cstring constraintList_unparse ( /*@observer@*/ constraintList s) /*@*/
 {
   return (constraintList_print(s));
 }
 
+# if 0
+static /*@only@*/ cstring
+constraintList_printLocation (/*@temp@*/ constraintList s) /*@*/
+{
+  int i;
+  cstring st = cstring_undefined;
+  bool first = TRUE;
+  
+  if (!constraintList_isDefined (s))
+    {
+      return cstring_makeLiteral ("<undefined>");
+    }
+
+  if (s->nelements == 0)
+    {
+      st = cstring_makeLiteral("<List Empty>");
+      return st;
+    }
+
+  for (i = 0; i < s->nelements; i++)
+    {
+      cstring type = cstring_undefined;
+      constraint current = s->elements[i];
+
+      if (constraint_isDefined(current) )
+       {
+         cstring temp1;
+             temp1 = constraint_printLocation(current);
+         type = message ("%q %q\n", type, temp1 );
+       }
+
+      if (first)
+       {
+         st = type;
+         first = FALSE;
+       }
+      else
+       {
+         st = message ("%q, %q", st, type);
+       }
+    } 
+
+  return st;
+}
+# endif
 
 /*@only@*/ cstring
 constraintList_print (/*@temp@*/ constraintList s) /*@*/
@@ -208,7 +298,7 @@ constraintList_print (/*@temp@*/ constraintList s) /*@*/
        {
          st = message ("%q, %q", st, type);
        }
-    } //end for
+    } 
 
   return st;
 }
@@ -297,7 +387,7 @@ constraintList_logicalOr (/*@observer@*/ constraintList l1, /*@observer@*/ const
 {
   constraint temp;
   constraintList ret;
-  DPRINTF ( (message ("Logical or on %s and %s",
+  DPRINTF ((message ("Logical or on %s and %s",
                      constraintList_print(l1), 
                      constraintList_print(l2)) ) );
   
@@ -393,7 +483,6 @@ constraintList constraintList_preserveCallInfo (/*@returned@*/ constraintList c,
 
   constraintList_elements_private (c, el)
   {
-    //  el = constraint_preserveOrig (el);
     el = constraint_setFcnPre(el);
     el = constraint_origAddGeneratingExpr (el, fcn);
   }
@@ -435,6 +524,25 @@ constraintList constraintList_addGeneratingExpr (constraintList c,/*@dependent@*
   constraintList_free(postconditions);
   return ret;
 }
+/*
+Commenting out because function is not yet stable
+  
+/ *@only@* / constraintList constraintList_doSRefFixStructConstraint(constraintList invars, sRef s, ctype ct )
+{
+  constraintList ret;
+  ret = constraintList_makeNew();
+  
+  constraintList_elements (invars, el)
+    {
+      ret = constraintList_add(ret, constraint_doSRefFixInvarConstraint (el, s, ct) );
+    }
+  end_constraintList_elements;
+
+  / *  constraintList_free (invars);* /
+
+  return ret;
+}
+*/
 
 /*@only@*/ constraintList constraintList_doSRefFixConstraintParam (constraintList preconditions, /*@temp@*/ /*@observer@*/ exprNodeList arglist)
 {
@@ -485,12 +593,12 @@ constraintList constraintList_togglePost (/*@returned@*/ constraintList c)
 /*@only@*/ constraintList constraintList_undump (FILE *f)
 {
   constraintList ret;
-  char *s = mstring_create (MAX_DUMP_LINE_LENGTH);
+  char *s;
   char *os;
   
   ret = constraintList_makeNew();
 
-  os = s;
+  os =  mstring_create (MAX_DUMP_LINE_LENGTH);
   s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
 
   while (s != NULL && *s != ';')
@@ -530,6 +638,11 @@ void constraintList_dump (/*@observer@*/ constraintList c,  FILE *f)
 constraintList constraintList_sort (/*@returned@*/ constraintList ret)
 {
   qsort (ret->elements, (size_t) ret->nelements,
-        (sizeof (*ret->elements) ), constraint_compare);
+        (sizeof (*ret->elements)), 
+        (int (*)(const void *, const void *)) constraint_compare);
+  
+  DPRINTF((message("onstraint_sort returning") ));
   return ret;
 }
+
+
This page took 0.048756 seconds and 4 git commands to generate.