]> andersk Git - splint.git/blobdiff - src/context.c
Made allocations involving sizeof work correctly (test/malloc.c).
[splint.git] / src / context.c
index 08198343d56be3f27edc3572f57f5d43aa6b5531..ad99f1366081ff4bdeddab83f3d79786dac5ff0a 100644 (file)
@@ -1059,10 +1059,12 @@ context_setModeAux (cstring s, bool warn)
          FLG_NESTEDEXTERN, 
          FLG_NUMLITERAL,
          FLG_ZEROBOOL,
+
          /* memchecks flags */
          FLG_NULLDEREF, 
          FLG_NULLSTATE, FLG_NULLASSIGN,
          FLG_NULLPASS, FLG_NULLRET,        
+         FLG_ALLOCMISMATCH,
 
          FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF,
          FLG_RETSTACK,
@@ -1195,6 +1197,7 @@ context_setModeAux (cstring s, bool warn)
 
          FLG_NULLSTATE, FLG_NULLDEREF, FLG_NULLASSIGN,
          FLG_NULLPASS, FLG_NULLRET,
+         FLG_ALLOCMISMATCH,
 
          FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF, FLG_RETSTACK,       
 
@@ -1311,9 +1314,14 @@ context_setModeAux (cstring s, bool warn)
          /* memchecks flags */
          FLG_NULLSTATE, FLG_NULLDEREF, FLG_NULLASSIGN,
          FLG_NULLPASS, FLG_NULLRET,
-
+         FLG_ALLOCMISMATCH,
          FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF,
 
+         /* memory checking flags */
+         FLG_BOUNDSREAD, FLG_BOUNDSWRITE,
+         FLG_LIKELYBOUNDSREAD, FLG_LIKELYBOUNDSWRITE,
+         FLG_CHECKPOST, 
+
          /* memtrans flags */
          FLG_EXPOSETRANS,
          FLG_OBSERVERTRANS,
@@ -4905,111 +4913,46 @@ valueTable context_createGlobalMarkerValueTable (stateInfo info)
     }
 }
 
-
-/*drl 12/30/01 these are some ugly functions that were added to facilitate struct annotations */
-
-
-/*drl added */
-static ctype lastStruct;
-
-ctype context_setLastStruct (/*@returned@*/ ctype s) /*@globals lastStruct@*/
+constraintList context_getImplicitFcnConstraints (uentry ue)
 {
-  lastStruct = s;
-  return s;
-}
-
-ctype context_getLastStruct (/*@returned@*/ /*ctype s*/) /*@globals lastStruct@*/
-{
-  return lastStruct;
-}
-
-/*
-** Why is this stuff in context.c?
-*/
-
-/*@unused@*/ static int sInfoNum = 0;
-
-
-struct getUe {
-  /*@unused@*/  uentry ue;
-  /*@unused@*/ sRef s;
-};
+  constraintList ret = constraintList_makeNew ();
+  uentryList params = uentry_getParams (ue);
 
-struct sInfo {
-  /*@unused@*/ ctype ct;
-  /*@unused@*/ constraintList inv;
- /*@unused@*/ int ngetUe;
- /*@unused@*/ struct getUe * t ;
-};
-
-/* unused: static struct sInfo globalStructInfo; */
-
-/*drl 1/6/2001: I didn't think these functions were solid enough to include in the
-  stable  release of splint.  I coomented them out so that they won't break anything
-  but didn't delete them because they will be fixed and included later
-
-
-*/
-
-/*@-paramuse@*/
-
-void context_setGlobalStructInfo (ctype ct, constraintList list)
-{
-# if 0
-  /* int i;
-  uentryList f;
-
-  f =  ctype_getFields (ct);
-  
-  if (constraintList_isDefined(list) )
+  uentryList_elements (params, el)
     {
-      globalStructInfo.ct = ct;
-      globalStructInfo.inv = list;
-
-      globalStructInfo.ngetUe = 0;
+      DPRINTF (("setImplicitfcnConstraints doing: %s", uentry_unparse(el)));
       
-      /* abstraction violation fix it * /
-      globalStructInfo.t   = dmalloc(f->nelements * sizeof(struct getUe) );
-
-      globalStructInfo.ngetUe = f->nelements;
-
-      i = 0;
-      
-      uentryList_elements(f, ue)
+      if (uentry_isElipsisMarker (el))
        {
-         globalStructInfo.t[i].ue = ue;
-         globalStructInfo.t[i].s = uentry_getSref(ue);
-         TPRINTF(( message(" setGlobalStructInfo:: adding ue=%s and sRef=%s",
-                           uentry_unparse(ue), sRef_unparse( uentry_getSref(ue) )
-                           )
-                   ));
-         i++;
+         ;
        }
-      end_uentryList_elements;
-    }
-  */
-# endif
-}
-
-# if 0
-/*
-
-bool hasInvariants (ctype ct) /*@* /
-{
-  if ( ctype_sameName(globalStructInfo.ct, ct) )
+      else
+       {
+         sRef s = uentry_getSref (el);
+         
+         DPRINTF (("Trying: %s", sRef_unparse (s)));
 
-    return TRUE;
+         if (ctype_isPointer (sRef_getType (s)))
+           {
+             constraint c = constraint_makeSRefWriteSafeInt (s, 0);
+             ret = constraintList_add (ret, c);
+             
+             /*drl 10/23/2002 added support for out*/
+             
+             if (!uentry_isOut(el))
+               {
+                 c = constraint_makeSRefReadSafeInt (s, 0);
+                 ret = constraintList_add (ret , c);
+               }
+           }
+         else
+           {
+             DPRINTF (("%s is NOT a pointer", sRef_unparseFull (s)));
+           }
+       }
+    } end_uentryList_elements;
 
-  else
-    
-    return FALSE;
-  
+  DPRINTF (("Returns ==> %s", constraintList_unparse (ret)));
+  return ret;
 }
-*/
-# endif
-
-/*@=paramuse@*/
-
-
-
 
This page took 0.228209 seconds and 4 git commands to generate.