]> andersk Git - splint.git/commitdiff
constraintExpr.c passes splintme without having to turn off warnings.
authordrl7x <drl7x>
Mon, 3 Mar 2003 01:47:27 +0000 (01:47 +0000)
committerdrl7x <drl7x>
Mon, 3 Mar 2003 01:47:27 +0000 (01:47 +0000)
src/Headers/constraintExpr.h
src/constraintExpr.c

index 09f1c4381cb88ac2a84328b575fd32956ebfa280..34def74d7da12d85754f73d5e871c2bc0638c10c 100644 (file)
@@ -52,7 +52,7 @@ int constraintExpr_compare (constraintExpr p_expr1, constraintExpr p_expr2) /*@*
 
 /* constraintExpr constraintExpr_makeValueInt (int i); */
 
-/*@only@*/ constraintExpr constraintExpr_makeIntLiteral (long p_i);
+/*@only@*/ /*@notnull@*/constraintExpr constraintExpr_makeIntLiteral (long p_i);
 
 /*@only@*/ constraintExpr constraintExpr_makeValueExpr (/*@exposed@*/ exprNode p_expr);
 
index 3d96627a0c0420ec9b7b5cfc2f28009a1689614e..df1abb5d6eb45dc6307821015d0d8dc67772415c 100644 (file)
 # include "exprChecks.h"
 # include "exprNodeSList.h"
 
-/*@-czechfcns@*/
 
-/*@access exprNode@*/ /* !!! NO! Don't do this recklessly! */
-// /*@-nullderef@*/ /* !!! DRL needs to fix this code! */
-// /*@-nullstate@*/ /* !!! DRL needs to fix this code! */
-// /*@-temptrans@*/ /* !!! DRL needs to fix this code! */
-
-/*@only@*/ /*@notnull@*/
-constraintExpr constraintExpr_makeIntLiteral (long i);
 static ctype constraintExpr_getOrigType (constraintExpr p_e);
 static bool constraintExpr_hasTypeChange(constraintExpr p_e) /*@*/;
 
@@ -301,7 +293,8 @@ static bool isZeroBinaryOp (constraintExpr expr)
          
          constraintExpr_free(expr1);
          constraintExpr_free(expr);
-         
+
+         llassert (constraintExpr_isDefined(temp) );
          return temp;
        }
       else
@@ -356,7 +349,9 @@ static bool isZeroBinaryOp (constraintExpr expr)
        }
     }
    DPRINTF ((message ("After combine %s", constraintExpr_unparse(expr) ) ) );
-  return expr;
+
+   llassert(constraintExpr_isDefined(expr) );
+   return expr;
 }
 
 /*@special@*/
@@ -432,6 +427,7 @@ constraintExpr constraintExpr_copy (constraintExpr expr)
   return ret;
 }
 
+/*@access exprNode@*/
 constraintExpr constraintExpr_makeExprNode (exprNode e)
 {
  sRef s;
@@ -566,6 +562,11 @@ constraintExpr constraintExpr_makeExprNode (exprNode e)
   return ret;
 }
 
+/*@noaccess exprNode@*/
+
+
+
+
 /*@only@*/ constraintExpr constraintExpr_makeTermExprNode (/*@exposed@*/ exprNode e)
 {
   return  oldconstraintExpr_makeTermExprNode(e);
@@ -2092,6 +2093,8 @@ bool constraintExpr_isBinaryExpr (/*@observer@*/ constraintExpr c)
 /*drl added 8/08/001 */
 bool constraintExpr_isTerm (/*@observer@*/ constraintExpr c) /*@*/
 {
+  llassert(constraintExpr_isDefined (c) );
+  
   if (c->kind == term)
     return TRUE;
 
@@ -2103,6 +2106,8 @@ bool constraintExpr_isTerm (/*@observer@*/ constraintExpr c) /*@*/
 {
   constraintTerm term;
   
+  llassert(constraintExpr_isDefined (c) );
+  
   llassert(constraintExpr_isTerm(c) );
 
   term = constraintExprData_termGetTerm(c->data);
@@ -2150,11 +2155,20 @@ static constraintExpr  binaryExpr_undump (FILE *f)
 
   str = fgets(os, MAX_DUMP_LINE_LENGTH, f);
 
+  if (! mstring_isDefined(str) )
+    {
+      llfatalbug(message("Library file is corrupted") );
+    }
   
   binaryOp = (constraintExprBinaryOpKind) reader_getInt(&str);
   
   str = fgets(os, MAX_DUMP_LINE_LENGTH, f);
 
+  if (! mstring_isDefined(str) )
+    {
+      llfatalbug(message("Library file is corrupted") );
+    }
+
   reader_checkChar (&str, 'e');
   reader_checkChar (&str, '1');
   
@@ -2205,6 +2219,11 @@ static  constraintExpr  unaryExpr_undump ( FILE *f)
   os = str;
   str = fgets(os, MAX_DUMP_LINE_LENGTH, f);
 
+  if (! mstring_isDefined(str) )
+    {
+      llfatalbug(message("Library file is corrupted") );
+    }
+
   unaryOp = (constraintExprUnaryOpKind) reader_getInt(&str);
   
   expr = constraintExpr_undump (f);
@@ -2222,6 +2241,8 @@ void  constraintExpr_dump (/*@observer@*/ constraintExpr expr,  FILE *f)
   constraintTerm t;
   
 
+  llassert(constraintExpr_isDefined(expr) );
+  
   DPRINTF((message("constraintExpr_dump:: dumping constraintExpr %s",
                   constraintExpr_unparse(expr)
                   ) ));
@@ -2260,6 +2281,11 @@ void  constraintExpr_dump (/*@observer@*/ constraintExpr expr,  FILE *f)
   
   s = fgets(os, MAX_DUMP_LINE_LENGTH, f);
 
+  if (! mstring_isDefined(s) )
+    {
+      llfatalbug(message("Library file is corrupted") );
+    }
+
   kind = (constraintExprKind) reader_getInt(&s);
 
   free (os);
@@ -2321,6 +2347,9 @@ int constraintExpr_getDepth (constraintExpr ex)
 
 bool  constraintExpr_canGetCType (constraintExpr e) /*@*/
 {
+  if (constraintExpr_isUndefined(e) )
+    return FALSE;
+  
   if (e->kind == term)
     {
       return TRUE;
@@ -2336,7 +2365,9 @@ bool  constraintExpr_canGetCType (constraintExpr e) /*@*/
 ctype constraintExpr_getCType (constraintExpr e) /*@*/
 {
   constraintTerm t;
+
+  llassert(constraintExpr_isDefined(e) );
+
   llassert(constraintExpr_canGetCType(e) );
 
   switch (e->kind)
@@ -2364,6 +2395,7 @@ ctype constraintExpr_getCType (constraintExpr e) /*@*/
 
 static bool constraintExpr_hasTypeChange(constraintExpr e)
 {
+  llassert(constraintExpr_isDefined(e) );
   if (constraintExpr_isDefined((e)) && (e->ct == TRUE) )
     {
       return TRUE;
@@ -2389,6 +2421,7 @@ static bool constraintExpr_hasTypeChange(constraintExpr e)
 static ctype constraintExpr_getOrigType (constraintExpr e)
 {
 
+  llassert(constraintExpr_isDefined(e) );
   llassert(constraintExpr_hasTypeChange(e) );
   
   
@@ -2420,6 +2453,8 @@ static /*@only@*/ constraintExpr constraintExpr_div (/*@only@*/ constraintExpr e
   return e;
 }
 
+
+/*@access exprNode@*/ 
 static /*@only@*/ constraintExpr  constraintTerm_simpleDivTypeExprNode(/*@only@*/ constraintExpr e, ctype ct)
 {
   exprData data;
@@ -2427,6 +2462,8 @@ static /*@only@*/ constraintExpr  constraintTerm_simpleDivTypeExprNode(/*@only@*
   lltok tok;
   constraintTerm t;
 
+  llassert(constraintExpr_isDefined(e) );
+  
   DPRINTF((
           message("constraintTerm_simpleDivTypeExprNode e=%s, ct=%s",
                   constraintExpr_print(e), ctype_unparse(ct)
@@ -2436,6 +2473,9 @@ static /*@only@*/ constraintExpr  constraintTerm_simpleDivTypeExprNode(/*@only@*
   t = constraintExprData_termGetTerm(e->data);
   
   expr = constraintTerm_getExprNode(t);
+
+  llassert(constraintExpr_isDefined(e) );
+  llassert(exprNode_isDefined(expr) );
   
   if (expr->kind == XPR_OP)
     {
@@ -2446,6 +2486,9 @@ static /*@only@*/ constraintExpr  constraintTerm_simpleDivTypeExprNode(/*@only@*
       tok = exprData_getOpTok (data);
       if (lltok_isMult(tok) )
        {
+         llassert(exprNode_isDefined(t1) && exprNode_isDefined(t2) );
+         /*drl 3/2/2003 we know this from the fact that it's a
+           multiplication operation...*/
          
          if  ((t1->kind == XPR_SIZEOF) || (t1->kind == XPR_SIZEOFT) )
            {
@@ -2482,7 +2525,16 @@ static /*@only@*/ constraintExpr  constraintTerm_simpleDivTypeExprNode(/*@only@*
                }
              else
                {
-                 ct2 = qtype_getType (exprData_getType(exprData_getSingle (t2->edata)->edata ) );
+                 exprNode exprTemp;
+                 exprData eDTemp;
+                 
+                 exprTemp = exprData_getSingle (t2->edata);
+
+                 llassert(exprNode_isDefined(exprTemp) );
+                 eDTemp = exprTemp->edata;
+                 
+                 ct2 = qtype_getType (exprData_getType(eDTemp ) );
+                 
                }
              if (ctype_match (ctype_makePointer(ct2),ct) )
                {
@@ -2500,6 +2552,7 @@ static /*@only@*/ constraintExpr  constraintTerm_simpleDivTypeExprNode(/*@only@*
     }
   return (constraintExpr_div (e, ct) );
 }
+/*@noaccess exprNode@*/ 
 
 static /*@only@*/ constraintExpr simpleDivType (/*@only@*/ constraintExpr e, ctype ct)
 {
@@ -2507,6 +2560,8 @@ static /*@only@*/ constraintExpr simpleDivType (/*@only@*/ constraintExpr e, cty
   DPRINTF(( (message("simpleDiv got %s ", constraintExpr_unparse(e) ) )
            ));
 
+  llassert(constraintExpr_isDefined(e) );
+  
   switch (e->kind)
     {
     case term:
@@ -2584,6 +2639,8 @@ bool  constraintExpr_isConstantOnly ( constraintExpr e )
                     constraintExpr_unparse(e) ) )
            ));
 
+  llassert(constraintExpr_isDefined(e) );
+
   switch (e->kind)
     {
     case term:
This page took 0.057256 seconds and 5 git commands to generate.