]> andersk Git - splint.git/blobdiff - src/constraintTerm.c
do..while control flow fix in exprNode.c
[splint.git] / src / constraintTerm.c
index 42f607ca7335b3577b524517dd2de3544a0fe69a..bac71fc45ff02306c7f57682625519577a3314e7 100644 (file)
@@ -2,7 +2,7 @@
 ** constraintExpr.c
 */
 
-//#define DEBUGPRINT 1
+/* #define DEBUGPRINT 1 */
 
 # include <ctype.h> /* for isdigit */
 # include "lclintMacros.nf"
@@ -15,8 +15,6 @@
 
 /*@-czechfcns@*/
 
-//#include "constraintExpr.h"
-
 /*@access exprNode @*/
 
 bool constraintTerm_isDefined (constraintTerm t)
@@ -24,8 +22,6 @@ bool constraintTerm_isDefined (constraintTerm t)
   return t != NULL;
 }
 
-/*@unused@*/ static bool constraintTerm_same (constraintTerm p_term1, constraintTerm p_term2) ;
-
 void constraintTerm_free (/*@only@*/ constraintTerm term)
 {
   llassert (constraintTerm_isDefined (term));
@@ -49,7 +45,7 @@ void constraintTerm_free (/*@only@*/ constraintTerm term)
       /* type was set incorrectly */
       llcontbug (message("constraintTerm_free type was set incorrectly"));
     }
-  //  term->value.intlit = 0;
+
   term->kind =  ERRORBADCONSTRAINTTERMTYPE;
   free (term);
 }
@@ -73,6 +69,62 @@ bool constraintTerm_isIntLiteral (constraintTerm term)
   return FALSE;
 }
 
+
+bool constraintTerm_isInitBlock (/*@observer@*/ /*@temp@*/ constraintTerm c) /*@*/
+{
+  llassert (c != NULL);
+  if (c->kind == EXPRNODE)
+    {
+      
+      if (exprNode_isInitBlock(c->value.expr) )
+       {
+         return TRUE;
+       }
+    }
+  return FALSE;
+}
+
+
+bool constraintTerm_isExprNode (/*@observer@*/ /*@temp@*/ constraintTerm c) /*@*/
+{
+  llassert (c != NULL);
+  if (c->kind == EXPRNODE)
+    {
+      return TRUE;
+    }
+  return FALSE;
+}
+
+
+int constraintTerm_getInitBlockLength (/*@observer@*/ /*@temp@*/ constraintTerm c) /*@*/
+{
+
+  exprNodeList  list;
+  int ret;
+  llassert (c != NULL);
+  llassert (constraintTerm_isInitBlock (c) );
+  llassert (c->kind == EXPRNODE);
+
+  llassert(exprNode_isDefined(c->value.expr) );
+
+  if (exprNode_isUndefined(c->value.expr) )
+    {
+      return 1;
+    }
+
+  if (c->value.expr->edata == exprData_undefined)
+    {
+      return 1;
+    }
+  list = exprData_getArgs(c->value.expr->edata);
+
+  ret = exprNodeList_size(list);
+
+  return ret;  
+}
+
+
+
 bool constraintTerm_isStringLiteral (constraintTerm c) /*@*/
 {
   llassert (c != NULL);
@@ -86,6 +138,8 @@ bool constraintTerm_isStringLiteral (constraintTerm c) /*@*/
   return FALSE;
 }
 
+
+
 cstring constraintTerm_getStringLiteral (constraintTerm c)
 {
   llassert (c != NULL);
@@ -201,7 +255,7 @@ static cstring constraintTerm_getName (constraintTerm term)
   switch (term->kind)
     {
     case EXPRNODE:
-      /*@i334*/  //wtf
+      /*@i334*/  /*wtf*/
       s = message ("%s", exprNode_unparse (term->value.expr) );
       break;
     case INTLITERAL:
@@ -229,18 +283,13 @@ constraintTerm_doSRefFixBaseParam (/*@returned@*/constraintTerm term, exprNodeLi
   switch (term->kind)
     {
     case EXPRNODE:
-      /*@i334*/  //wtf
-      //   s = message ("%s @ %s ", exprNode_unparse (term->value.expr),
-      //          fileloc_unparse (term->loc) );
+      /*@i334*/  /*wtf*/
       break;
     case INTLITERAL:
-      //  s = message (" %d ", term->value.intlit);
-       break;
+      break;
       
     case SREF:
       term->value.sref = sRef_fixBaseParam (term->value.sref, arglist);
-      //      s = message ("%s ", sRef_unparse (term->value.sref) );
-
       break;
     default:
       BADEXIT;
@@ -259,16 +308,16 @@ cstring constraintTerm_print (constraintTerm term)  /*@*/
   switch (term->kind)
     {
     case EXPRNODE:
-      /*@i334*/  //wtf
-      s = message ("%s @ %q ", exprNode_unparse (term->value.expr),
+      /*@i334*/  /*wtf*/
+      s = message ("%s @ %q", exprNode_unparse (term->value.expr),
                   fileloc_unparse (term->loc) );
       break;
     case INTLITERAL:
-      s = message (" %d ", (int)term->value.intlit);
+      s = message ("%d", (int)term->value.intlit);
       break;
       
     case SREF:
-      s = message ("%q ", sRef_unparseDebug (term->value.sref) );
+      s = message ("%q", sRef_unparseDebug (term->value.sref) );
 
       break;
     default:
@@ -347,36 +396,7 @@ long constraintTerm_getValue (constraintTerm term)
       BADBRANCH;
     }
 
-  BADBRANCH;
-}
-
-/* same and similar are similar but not the same*/
-static bool constraintTerm_same (constraintTerm term1, constraintTerm term2)
-{
-  llassert (term1 !=NULL && term2 !=NULL);
-
-  if ( (term1->kind != term2->kind) || (term1->kind != EXPRNODE) )
-    {
-      return FALSE;
-    }
-      
- DPRINTF ( (message
-           ("Comparing srefs for %s and  %s ", constraintTerm_print(term1), constraintTerm_print(term2)
-            )
-           )
-          );
- if (sRef_same (term1->value.expr->sref, term2->value.expr->sref) )
-   {
-     DPRINTF ((message (" %s and %s are same", constraintTerm_print(term1), constraintTerm_print(term2)  )  ));
-     return TRUE;
-   }
- else
-   {
-     DPRINTF ((message (" %s and %s are not same", constraintTerm_print(term1), constraintTerm_print(term2)  )  ));
-     return FALSE;
-   }     
-    
+  BADEXIT;
 }
 
 static /*@exposed@*/ sRef constraintTerm_getsRef (constraintTerm t)
@@ -547,12 +567,12 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
   
   uentry ue;
   
-  char * str;
-  char * os;
+  char *str;
+  char *os;
 
   str = mstring_create (MAX_DUMP_LINE_LENGTH);
   os = str;
-  str = fgets(os, MAX_DUMP_LINE_LENGTH, f);
+  str = fgets (os, MAX_DUMP_LINE_LENGTH, f);
 
   kind = (constraintTermType) reader_getInt(&str);
   str = fgets(os, MAX_DUMP_LINE_LENGTH, f);
@@ -583,11 +603,10 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
 
            ostr2 = str2;
            t = ctype_undump(&str2) ;
-           s = sRef_makeParam (param, t );
+           s = sRef_makeParam (param, t, stateInfo_makeLoc (g_currentloc));
            free (ostr2);
          }
-       else  //This must be an identified that we can search for
-         // in usymTab
+       else  /* This must be an identified that we can search for in usymTab */
          {
            cstring termStr = cstring_makeLiteralTemp(term);
 
@@ -608,8 +627,7 @@ void constraintTerm_dump ( /*@observer@*/ constraintTerm t,  FILE *f)
        cstring termStr;
                
        term = reader_getWord(&str);
-       //This must be an identifier that we can search for
-         // in usymTab
+       /* This must be an identifier that we can search for in usymTab */
        termStr = cstring_makeLiteralTemp(term);
        
        ue = usymtab_lookup (termStr);
This page took 0.042815 seconds and 4 git commands to generate.