]> andersk Git - splint.git/blobdiff - src/context.c
*** empty log message ***
[splint.git] / src / context.c
index 9644d3bddc606053640f69e6efb88a60b0791085..1faa4c28be8ce0d5db98aaaf5080ff6556aebf61 100644 (file)
@@ -17,8 +17,8 @@
 ** 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 information on splint: splint@cs.virginia.edu
+** To report a bug: splint-bug@cs.virginia.edu
 ** For more information: http://www.splint.org
 */
 /*
@@ -33,7 +33,7 @@
  *   or, if not set "." will be used.
  */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "llbasic.h"
 
 # ifndef NOLCL
@@ -676,9 +676,8 @@ context_resetModeFlags (void)
        {
          context_setFlag (code, FALSE);
        }
-    } end_allFlagCodes;
-
-  }
+    } end_allFlagCodes;  
+}
 
 /*
 ** resetAllFlags
@@ -704,6 +703,8 @@ conext_resetAllCounters (void)
 void
 context_resetAllFlags (void) 
 {
+  DPRINTF (("******** Reset all flags"));
+
   allFlagCodes (code)
     {
       gc.flags[code] = FALSE;
@@ -747,13 +748,15 @@ context_resetAllFlags (void)
            }
          /*@=loopswitchbreak@*/          
 
+         DPRINTF (("Set value: [%s] / %d",  flagcode_unparse (code), val));
          context_setValue (code, val);
+         DPRINTF (("Set value: [%s] / %d",  flagcode_unparse (code), context_getValue (code)));
+         llassert (context_getValue (code) == val);
        }
       else if (flagcode_hasChar (code))
        {
          llassert (code == FLG_COMMENTCHAR);
          context_setCommentMarkerChar (DEFAULT_COMMENTCHAR);
-         break;
        }
       else if (flagcode_hasString (code))
        {
@@ -885,8 +888,12 @@ context_resetAllFlags (void)
   gc.flags[FLG_TYPE] = TRUE;
   gc.flags[FLG_INCOMPLETETYPE] = TRUE;
   gc.flags[FLG_ABSTRACT] = TRUE;
-  gc.flags[FLG_ITER] = TRUE;
-  gc.flags[FLG_CONTROL] = TRUE;
+  gc.flags[FLG_ITERBALANCE] = TRUE;
+  gc.flags[FLG_ITERYIELD] = TRUE;
+  gc.flags[FLG_DUPLICATECASES] = TRUE;
+  gc.flags[FLG_ALWAYSEXITS] = TRUE;
+  gc.flags[FLG_EMPTYRETURN] = TRUE;
+  gc.flags[FLG_MACRORETURN] = TRUE;
   gc.flags[FLG_UNRECOG] = TRUE;
   gc.flags[FLG_SYSTEMUNRECOG] = TRUE;
   gc.flags[FLG_LINTCOMMENTS] = TRUE;
@@ -904,6 +911,11 @@ context_resetAllFlags (void)
 
   gc.flags[FLG_GNUEXTENSIONS] = TRUE;
 
+  /*
+    Changed for 3.0.0.19
+   */
+  gc.flags[FLG_ORCONSTRAINT] = TRUE;
+  gc.flags[FLG_CONSTRAINTLOCATION] = TRUE;
   /*
   ** On by default for Win32, but not Unix (to support MS/VC++ error message format).
   */
@@ -926,8 +938,22 @@ context_resetAllFlags (void)
                          flagcode_unparse (modeflags[i]))); } \
       else { context_setFlag (modeflags[i], TRUE); }  i++; }}
 
+static void context_setModeAux (cstring p_s, bool p_warn) ;
+
 void
 context_setMode (cstring s)
+{
+  context_setModeAux (s, TRUE);
+}
+
+void
+context_setModeNoWarn (cstring s)
+{
+  context_setModeAux (s, FALSE);
+}
+
+void
+context_setModeAux (cstring s, bool warn)
 {
   intSet setflags = intSet_new ();
   
@@ -968,11 +994,14 @@ context_setMode (cstring s)
            }
        } end_intSet_elements ;
       
-      voptgenerror (FLG_WARNFLAGS,
-                   message ("Setting mode %s after setting mode flags will "
-                            "override set values of flags: %s",
-                            s, rflags),
-                   g_currentloc);
+      if (warn)
+       {
+         voptgenerror (FLG_WARNFLAGS,
+                       message ("Setting mode %s after setting mode flags will "
+                                "override set values of flags: %s",
+                                s, rflags),
+                       g_currentloc);
+       }
 
       cstring_free (rflags);
     }
@@ -2770,7 +2799,8 @@ context_setValue (flagcode flag, int val)
     default:
       break;
     }
-    
+
+  DPRINTF (("Set value [%s] %d = %d", flagcode_unparse (flag), index, val));
   gc.values[index] = val;
 }
 
@@ -2787,6 +2817,7 @@ context_getValue (flagcode flag)
   int index = flagcode_valueIndex (flag);
 
   llassert (index >= 0 && index <= NUMVALUEFLAGS);
+  DPRINTF (("Get value [%s] %d = %d", flagcode_unparse (flag), index, gc.values[index]));
   return (gc.values[index]);
 }
 
@@ -2986,16 +3017,18 @@ void context_initMod (void)
     {
       gc.setGlobally[code] = FALSE;
       gc.setLocally[code] = FALSE;
-    } end_allFlagCodes ;
-
+    } 
+  end_allFlagCodes ;
+  
   usymtab_initMod ();
 
   context_resetAllFlags ();
+
   assertSet (gc.flags); /* Can't use global in defines */
   assertSet (gc.saveflags);
   assertSet (gc.values);
   assertSet (gc.strings);
-
+  
   conext_resetAllCounters ();
   assertSet (gc.counters);
 
@@ -3989,6 +4022,10 @@ context_setFlagAux (flagcode f, bool b, bool inFile,
       DOSET (FLG_FCNMACROS, b);
       DOSET (FLG_CONSTMACROS, b);
       break;
+    case FLG_BOUNDS:
+      DOSET (FLG_BOUNDSREAD, b);
+      DOSET (FLG_BOUNDSWRITE, b);
+      break;
     case FLG_CZECH:
       if (b) { DOSET (FLG_ACCESSCZECH, b); }
       DOSET (FLG_CZECHFUNCTIONS, b);
@@ -4716,3 +4753,165 @@ valueTable context_createGlobalMarkerValueTable (stateInfo sinfo)
 
 
 
+/*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@*/
+{
+  lastStruct = s;
+  return s;
+}
+
+ctype context_getLastStruct (/*@returned@*/ /*ctype s*/) /*@globals lastStruct@*/
+{
+  return lastStruct;
+}
+
+
+/*@unused@*/ static int sInfoNum = 0;
+
+
+struct getUe {
+  /*@unused@*/  uentry ue;
+  /*@unused@*/ sRef s;
+};
+
+struct sInfo {
+  /*@unused@*/ ctype ct;
+  /*@unused@*/ constraintList inv;
+ /*@unused@*/ int ngetUe;
+ /*@unused@*/ struct getUe * t ;
+};
+
+
+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
+*/
+
+/*
+void  setGlobalStructInfo(ctype ct, constraintList list)
+{
+  int i;
+  uentryList f;
+
+  f =  ctype_getFields (ct);
+  
+  if (constraintList_isDefined(list) )
+    {
+      globalStructInfo.ct = ct;
+      globalStructInfo.inv = list;
+
+      globalStructInfo.ngetUe = 0;
+      
+      / *abstraction violation fix it * /
+      globalStructInfo.t   = dmalloc(f->nelements * sizeof(struct getUe) );
+
+      globalStructInfo.ngetUe = f->nelements;
+
+      i = 0;
+      
+      uentryList_elements(f, ue)
+       {
+         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;
+    }
+}
+
+*/
+
+bool hasInvariants (ctype ct) /*@*/
+{
+  if ( ctype_sameName(globalStructInfo.ct, ct) )
+
+    return TRUE;
+
+  else
+    
+    return FALSE;
+  
+}
+
+/*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
+*/
+
+/*
+constraintList getInvariants (ctype ct)
+{
+  
+  llassert(hasInvariants(ct) );
+
+  return  globalStructInfo.inv;
+}
+*/
+
+/*
+static int getSref (ctype ct, sRef s)
+{
+  int i;
+
+  i = 0;
+
+  / *
+    DEBUGGIN INFO
+    
+    fprintf(stderr, "getSref: ct = %s (%x)\n",  ctype_unparse(ct), ct );
+    
+    fprintf(stderr,"getSref: s =  (%s) %X \n", sRef_unparse(s),  s);
+  * /
+  
+  while (i < globalStructInfo.ngetUe)
+    {
+      DPRINTF(( message(" getSref:: comparing ue=%s and sRef=%s",
+                       uentry_unparse(globalStructInfo.t[i].ue),
+                       sRef_unparse(globalStructInfo.t[i].s)
+                       )
+               ));
+
+      / *
+      fprintf (stderr, " globalStructInfo.t[i].s = %x\n ",
+              globalStructInfo.t[i].s );
+      * /
+      
+      if (sRef_same(globalStructInfo.t[i].s,s) )
+       return i;
+      
+      i++;
+    }
+  return -1;  
+}
+
+  
+sRef fixSref (ctype ct, sRef base, sRef fix)
+{
+  int index;
+  uentry ue;
+  cstring name;
+  index = getSref(ct, fix);
+
+  if (index < 0) 
+    return fix;
+
+  ue =  globalStructInfo.t[index].ue;
+  name = uentry_getName(ue);
+  fix = sRef_buildField(base, name );
+  cstring_free(name);
+  return fix;
+}
+
+*/
This page took 0.046188 seconds and 4 git commands to generate.