]> andersk Git - splint.git/blobdiff - src/constraintTerm.c
Improved tracking of state change locations. Added +showdeephistory
[splint.git] / src / constraintTerm.c
index 6af07e5a1ecd9140f251f63dbe0c84a8da2e3ff0..e49f75d96143b42e94ff2493f4429a9924a4598a 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2002 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,9 +17,9 @@
 ** 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
 */
 
 /*
@@ -29,7 +29,7 @@
 /* #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 "exprNodeSList.h"
 
 /*@-czechfcns@*/
+/*@-nullderef@*/ /* !!! DRL needs to fix this code! */
+/*@-nullstate@*/ /* !!! DRL needs to fix this code! */
+/*@-nullpass@*/ /* !!! DRL needs to fix this code! */
+/*@-temptrans@*/ /* !!! DRL needs to fix this code! */
 
-/*@access exprNode @*/
+/*@access exprNode@*/ /* !!! NO! Don't do this recklessly! */
 
 bool constraintTerm_isDefined (constraintTerm t)
 {
@@ -423,7 +427,20 @@ long constraintTerm_getValue (constraintTerm term)
   BADEXIT;
 }
 
-static /*@exposed@*/ sRef constraintTerm_getsRef (constraintTerm t)
+/*drl added this 10.30.001
+ */
+
+/*@exposed@*/ exprNode constraintTerm_getExprNode (constraintTerm t)
+{
+  llassert (t != NULL);
+  
+  llassert (t->kind == EXPRNODE);
+
+  return t->value.expr;
+
+}
+
+ /*@exposed@*/ sRef constraintTerm_getsRef (constraintTerm t)
 {
   llassert (t != NULL);
   if (t->kind == EXPRNODE)
@@ -445,7 +462,7 @@ bool constraintTerm_probSame (constraintTerm term1, constraintTerm term2)
 
   llassert (term1 !=NULL && term2 !=NULL);
      
- DPRINTF ( (message
+ DPRINTF ((message
            ("Comparing srefs for %s and  %s ", constraintTerm_print(term1), constraintTerm_print(term2)
             )
            )
@@ -497,7 +514,7 @@ bool constraintTerm_similar (constraintTerm term1, constraintTerm term2)
       return FALSE;
     }
   
-  DPRINTF( (message
+  DPRINTF((message
            ("Comparing srefs for %s and  %s ", constraintTerm_print(term1), constraintTerm_print(term2)
             )
            )
@@ -515,7 +532,7 @@ bool constraintTerm_similar (constraintTerm term1, constraintTerm term2)
     }       
 }
 
-void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
+void constraintTerm_dump (/*@observer@*/ constraintTerm t,  FILE *f)
 {
   fileloc loc;
   constraintTermValue value;
@@ -535,8 +552,7 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
       
     case EXPRNODE:
       u = exprNode_getUentry(t->value.expr);
-      fprintf(f, "%s\n", cstring_toCharsSafe( uentry_rawName (u) )
-             );
+      fprintf (f, "%s\n", cstring_toCharsSafe (uentry_rawName (u)));
       break;
       
     case SREF:
@@ -549,7 +565,7 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
          {
            fprintf(f, "Result\n");
          }
-       else if (sRef_isParam (s ) )
+       else if (sRef_isParam (s))
          {
            int param;
            ctype ct;
@@ -564,10 +580,14 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
            fprintf(f, "Param %s %d\n", cstring_toCharsSafe(ctString), (int) param );
            cstring_free(ctString);
          }
+       else if (sRef_isField (s) )
+         {
+           fprintf(f, "sRef_dump %s\n", cstring_toCharsSafe(sRef_dump(s)) );
+         }
        else
          {
            u = sRef_getUentry(s);
-           fprintf(f, "%s\n", cstring_toCharsSafe(uentry_rawName (u) ) );
+           fprintf (f, "%s\n", cstring_toCharsSafe (uentry_rawName (u)));
          }
        
       }
@@ -584,7 +604,7 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
 }
 
 
-/*@only@*/ constraintTerm constraintTerm_undump ( FILE *f)
+/*@only@*/ constraintTerm constraintTerm_undump (FILE *f)
 {
   constraintTermType kind;
   constraintTerm ret;
@@ -594,13 +614,17 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
   char *str;
   char *os;
 
-  str = mstring_create (MAX_DUMP_LINE_LENGTH);
-  os = str;
+  os = mstring_create (MAX_DUMP_LINE_LENGTH);
+
   str = fgets (os, MAX_DUMP_LINE_LENGTH, f);
 
+  llassert (str != NULL);
+
   kind = (constraintTermType) reader_getInt(&str);
   str = fgets(os, MAX_DUMP_LINE_LENGTH, f);
 
+  llassert (str != NULL);
+
   switch (kind)
     {
       
@@ -627,9 +651,14 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
 
            ostr2 = str2;
            t = ctype_undump(&str2) ;
-           s = sRef_makeParam (param, t, stateInfo_makeLoc (g_currentloc));
+           s = sRef_makeParam (param, t, stateInfo_makeLoc (g_currentloc, SA_CREATED));
            free (ostr2);
          }
+       else if (strcmp (term, "sRef_dump" ) == 0 )
+         {
+           reader_checkChar(&str, ' ');
+           s = sRef_undump (&str);
+         }
        else  /* This must be an identified that we can search for in usymTab */
          {
            cstring termStr = cstring_makeLiteralTemp(term);
@@ -682,4 +711,28 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
 
 
 
+/* drl added sometime before 10/17/001*/
+ctype constraintTerm_getCType (constraintTerm term)
+{
+  ctype ct;
+  
+  switch (term->kind)
+    {
+    case EXPRNODE:
+      ct = exprNode_getType (term->value.expr);
+      break;
+
+    case INTLITERAL:
+      /*@i888*/ /* hack */
+      ct = ctype_signedintegral;
+      break;
+      
+    case SREF:
+      ct = sRef_getType (term->value.sref) ;
+      break;
+    default:
+      BADEXIT;
+    }
+  return ct;
+}
 
This page took 0.171848 seconds and 4 git commands to generate.