2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2002 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
29 /* #define DEBUGPRINT 1 */
31 # include <ctype.h> /* for isdigit */
32 # include "splintMacros.nf"
34 # include "cgrammar.h"
35 # include "cgrammar_tokens.h"
37 # include "exprChecks.h"
38 # include "exprNodeSList.h"
42 /*@access exprNode@*/ /* !!! NO! Don't do this recklessly! */
43 /*@-nullderef@*/ /* !!! DRL needs to fix this code! */
44 /*@-nullstate@*/ /* !!! DRL needs to fix this code! */
45 /*@-temptrans@*/ /* !!! DRL needs to fix this code! */
47 static /*@only@*/ cstring constraint_printDetailedPostCondition (/*@observer@*/ /*@temp@*/ constraint p_c);
50 static /*@notnull@*/ /*@special@*/ constraint constraint_makeNew (void)
51 /*@post:isnull result->or, result->orig, result->generatingExpr, result->fcnPre @*/
52 /*@defines result->or, result->generatingExpr, result->orig, result->fcnPre @*/;
55 advanceField (char **s)
57 reader_checkChar (s, '@');
61 static constraint makeConstraintParse2 (constraintExpr l, lltok relOp, exprNode cconstant)
66 ret = constraint_makeNew ();
67 llassert (constraintExpr_isDefined (l));
69 ret->lexpr = constraintExpr_copy (l);
72 if (relOp.tok == GE_OP)
74 else if (relOp.tok == LE_OP)
76 else if (relOp.tok == EQ_OP)
79 llfatalbug (message ("Unsupported relational operator"));
82 t = cstring_toCharsSafe (exprNode_unparse (cconstant));
84 ret->expr = constraintExpr_makeIntLiteral (c);
87 DPRINTF (("GENERATED CONSTRAINT:"));
88 DPRINTF ((message ("%s", constraint_print (ret))));
93 bool constraint_same (constraint c1, constraint c2)
95 llassert (c1 != NULL);
96 llassert (c2 != NULL);
103 if (!constraintExpr_similar (c1->lexpr, c2->lexpr))
108 if (!constraintExpr_similar (c1->expr, c2->expr))
116 constraint makeConstraintParse3 (constraintExpr l, lltok relOp, constraintExpr r)
119 ret = constraint_makeNew ();
120 llassert (constraintExpr_isDefined (l));
122 ret->lexpr = constraintExpr_copy (l);
124 if (lltok_getTok (relOp) == GE_OP)
128 else if (lltok_getTok (relOp) == LE_OP)
132 else if (lltok_getTok (relOp) == EQ_OP)
137 llfatalbug ( message ("Unsupported relational operator"));
139 ret->expr = constraintExpr_copy (r);
143 ret->orig = constraint_copy (ret);
145 ret = constraint_simplify (ret);
146 /* ret->orig = ret; */
148 DPRINTF (("GENERATED CONSTRAINT:"));
149 DPRINTF ((message ("%s", constraint_print (ret))));
153 constraint constraint_copy (/*@temp@*/ /*@observer@*/ constraint c)
157 llassert (constraint_isDefined (c));
159 ret = constraint_makeNew ();
160 ret->lexpr = constraintExpr_copy (c->lexpr);
162 ret->expr = constraintExpr_copy (c->expr);
165 ret->generatingExpr = c->generatingExpr;
170 ret->orig = constraint_copy (c->orig);
175 ret->or = constraint_copy (c->or);
179 ret->fcnPre = c->fcnPre;
184 /*like copy expect it doesn't allocate memory for the constraint*/
186 void constraint_overWrite (constraint c1, constraint c2)
188 llassert (constraint_isDefined (c1));
192 DPRINTF ((message ("OverWriteing constraint %q with %q", constraint_print (c1),
193 constraint_print (c2))));
195 constraintExpr_free (c1->lexpr);
196 constraintExpr_free (c1->expr);
198 c1->lexpr = constraintExpr_copy (c2->lexpr);
200 c1->expr = constraintExpr_copy (c2->expr);
203 if (c1->orig != NULL)
204 constraint_free (c1->orig);
206 if (c2->orig != NULL)
207 c1->orig = constraint_copy (c2->orig);
211 /*@i33 make sure that the or is freed correctly*/
213 constraint_free (c1->or);
216 c1->or = constraint_copy (c2->or);
220 c1->fcnPre = c2->fcnPre;
223 c1->generatingExpr = c2->generatingExpr;
229 static /*@notnull@*/ /*@special@*/ constraint constraint_makeNew (void)
230 /*@post:isnull result->or, result->orig, result->generatingExpr, result->fcnPre @*/
231 /*@defines result->or, result->generatingExpr, result->orig, result->fcnPre @*/
234 ret = dmalloc (sizeof (*ret));
241 ret->generatingExpr = NULL;
246 constraint constraint_addGeneratingExpr (/*@returned@*/ constraint c, /*@exposed@*/ exprNode e)
249 if (c->generatingExpr == NULL)
251 c->generatingExpr = e;
252 DPRINTF ((message ("setting generatingExpr for %s to %s", constraint_print (c), exprNode_unparse (e)) ));
256 DPRINTF ((message ("Not setting generatingExpr for %s to %s", constraint_print (c), exprNode_unparse (e)) ));
261 constraint constraint_origAddGeneratingExpr (/*@returned@*/ constraint c, exprNode e)
264 if (c->orig != constraint_undefined)
266 c->orig = constraint_addGeneratingExpr (c->orig, e);
270 DPRINTF ((message ("constraint_origAddGeneratingExpr: Not setting generatingExpr for %s to %s", constraint_print (c), exprNode_unparse (e)) ));
275 constraint constraint_setFcnPre (/*@returned@*/ constraint c)
278 if (c->orig != constraint_undefined)
280 c->orig->fcnPre = TRUE;
285 DPRINTF (( message ("Warning Setting fcnPre directly")));
293 fileloc constraint_getFileloc (constraint c)
295 if (exprNode_isDefined (c->generatingExpr))
296 return (fileloc_copy (exprNode_getfileloc (c->generatingExpr)));
298 return (constraintExpr_getFileloc (c->lexpr));
303 static bool checkForMaxSet (constraint c)
305 if (constraintExpr_hasMaxSet (c->lexpr) || constraintExpr_hasMaxSet (c->expr))
311 bool constraint_hasMaxSet (constraint c)
313 if (checkForMaxSet (c))
318 if (checkForMaxSet (c->orig))
325 constraint constraint_makeReadSafeExprNode (exprNode po, exprNode ind)
327 constraint ret = constraint_makeNew ();
331 ret->lexpr = constraintExpr_makeMaxReadExpr (po);
333 ret->expr = constraintExpr_makeValueExpr (ind);
338 constraint constraint_makeWriteSafeInt ( exprNode po, int ind)
340 constraint ret = constraint_makeNew ();
343 ret->lexpr =constraintExpr_makeMaxSetExpr (po);
345 ret->expr = constraintExpr_makeIntLiteral (ind);
349 constraint constraint_makeSRefSetBufferSize (sRef s, long int size)
351 constraint ret = constraint_makeNew ();
352 ret->lexpr = constraintExpr_makeSRefMaxset (s);
354 ret->expr = constraintExpr_makeIntLiteral ((int)size);
359 constraint constraint_makeSRefWriteSafeInt (sRef s, int ind)
361 constraint ret = constraint_makeNew ();
364 ret->lexpr = constraintExpr_makeSRefMaxset ( s);
366 ret->expr = constraintExpr_makeIntLiteral (ind);
371 /* drl added 01/12/2000
373 makes the constraint: Ensures index <= MaxRead (buffer) */
375 constraint constraint_makeEnsureLteMaxRead (exprNode index, exprNode buffer)
377 constraint ret = constraint_makeNew ();
379 ret->lexpr = constraintExpr_makeValueExpr (index);
381 ret->expr = constraintExpr_makeMaxReadExpr (buffer);
386 constraint constraint_makeWriteSafeExprNode (exprNode po, exprNode ind)
388 constraint ret = constraint_makeNew ();
391 ret->lexpr =constraintExpr_makeMaxSetExpr (po);
393 ret->expr = constraintExpr_makeValueExpr (ind);
398 constraint constraint_makeReadSafeInt ( exprNode t1, int index)
400 constraint ret = constraint_makeNew ();
402 ret->lexpr = constraintExpr_makeMaxReadExpr (t1);
404 ret->expr = constraintExpr_makeIntLiteral (index);
409 constraint constraint_makeSRefReadSafeInt (sRef s, int ind)
411 constraint ret = constraint_makeNew ();
414 ret->lexpr = constraintExpr_makeSRefMaxRead (s);
416 ret->expr = constraintExpr_makeIntLiteral (ind);
421 constraint constraint_makeEnsureMaxReadAtLeast (exprNode t1, exprNode t2, fileloc sequencePoint)
425 ret = constraint_makeReadSafeExprNode (t1, t2);
426 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
432 static constraint constraint_makeEnsuresOpConstraintExpr (/*@only@*/ constraintExpr c1, /*@only@*/ constraintExpr c2, fileloc sequencePoint, arithType ar)
437 llassert (constraintExpr_isDefined (c1) && constraintExpr_isDefined (c2));
439 ret = constraint_makeNew ();
445 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
449 static constraint constraint_makeEnsuresOp (/*@dependent@*/ exprNode e1, /*@dependent@*/ exprNode e2, fileloc sequencePoint, arithType ar)
451 constraintExpr c1, c2;
455 if (! (exprNode_isDefined (e1) && exprNode_isDefined (e2)))
457 llcontbug ((message ("null exprNode, Exprnodes are %s and %s",
458 exprNode_unparse (e1), exprNode_unparse (e2))
463 c1 = constraintExpr_makeValueExpr (e);
466 c2 = constraintExpr_makeValueExpr (e);
468 ret = constraint_makeEnsuresOpConstraintExpr (c1, c2, sequencePoint, ar);
474 /* make constraint ensures e1 == e2 */
476 constraint constraint_makeEnsureEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
478 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, EQ));
481 /*make constraint ensures e1 < e2 */
482 constraint constraint_makeEnsureLessThan (exprNode e1, exprNode e2, fileloc sequencePoint)
484 constraintExpr t1, t2;
486 t1 = constraintExpr_makeValueExpr (e1);
487 t2 = constraintExpr_makeValueExpr (e2);
489 /*change this to e1 <= (e2 -1) */
491 t2 = constraintExpr_makeDecConstraintExpr (t2);
493 return ( constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, LTE));
496 constraint constraint_makeEnsureLessThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
498 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, LTE));
501 constraint constraint_makeEnsureGreaterThan (exprNode e1, exprNode e2, fileloc sequencePoint)
503 constraintExpr t1, t2;
505 t1 = constraintExpr_makeValueExpr (e1);
506 t2 = constraintExpr_makeValueExpr (e2);
509 /* change this to e1 >= (e2 + 1) */
510 t2 = constraintExpr_makeIncConstraintExpr (t2);
513 return ( constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, GTE));
516 constraint constraint_makeEnsureGreaterThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
518 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, GTE));
522 exprNode exprNode_copyConstraints (/*@returned@*/ exprNode dst, exprNode src)
524 constraintList_free (dst->ensuresConstraints);
525 constraintList_free (dst->requiresConstraints);
526 constraintList_free (dst->trueEnsuresConstraints);
527 constraintList_free (dst->falseEnsuresConstraints);
529 dst->ensuresConstraints = constraintList_copy (src->ensuresConstraints);
530 dst->requiresConstraints = constraintList_copy (src->requiresConstraints);
531 dst->trueEnsuresConstraints = constraintList_copy (src->trueEnsuresConstraints);
532 dst->falseEnsuresConstraints = constraintList_copy (src->falseEnsuresConstraints);
536 /* Makes the constraint e = e + f */
537 constraint constraint_makeAddAssign (exprNode e, exprNode f, fileloc sequencePoint)
539 constraintExpr x1, x2, y;
542 ret = constraint_makeNew ();
544 x1 = constraintExpr_makeValueExpr (e);
545 x2 = constraintExpr_copy (x1);
546 y = constraintExpr_makeValueExpr (f);
551 ret->expr = constraintExpr_makeAddExpr (x2, y);
553 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
559 /* Makes the constraint e = e - f */
560 constraint constraint_makeSubtractAssign (exprNode e, exprNode f, fileloc sequencePoint)
562 constraintExpr x1, x2, y;
565 ret = constraint_makeNew ();
567 x1 = constraintExpr_makeValueExpr (e);
568 x2 = constraintExpr_copy (x1);
569 y = constraintExpr_makeValueExpr (f);
574 ret->expr = constraintExpr_makeSubtractExpr (x2, y);
576 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
581 constraint constraint_makeMaxSetSideEffectPostDecrement (exprNode e, fileloc sequencePoint)
583 constraint ret = constraint_makeNew ();
585 ret->lexpr = constraintExpr_makeValueExpr (e);
588 ret->expr = constraintExpr_makeValueExpr (e);
589 ret->expr = constraintExpr_makeDecConstraintExpr (ret->expr);
590 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
593 constraint constraint_makeMaxSetSideEffectPostIncrement (exprNode e, fileloc sequencePoint)
595 constraint ret = constraint_makeNew ();
597 ret->lexpr = constraintExpr_makeValueExpr (e);
600 ret->expr = constraintExpr_makeValueExpr (e);
601 ret->expr = constraintExpr_makeIncConstraintExpr (ret->expr);
603 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
608 void constraint_free (/*@only@*/ constraint c)
610 llassert (constraint_isDefined (c));
613 if (constraint_isDefined (c->orig))
614 constraint_free (c->orig);
615 if ( constraint_isDefined (c->or))
616 constraint_free (c->or);
619 constraintExpr_free (c->lexpr);
620 constraintExpr_free (c->expr);
631 cstring arithType_print (arithType ar) /*@*/
633 cstring st = cstring_undefined;
637 st = cstring_makeLiteral ("<");
640 st = cstring_makeLiteral ("<=");
643 st = cstring_makeLiteral (">");
646 st = cstring_makeLiteral (">=");
649 st = cstring_makeLiteral ("==");
652 st = cstring_makeLiteral ("NONNEGATIVE");
655 st = cstring_makeLiteral ("POSITIVE");
664 void constraint_printErrorPostCondition (constraint c, fileloc loc)
667 fileloc errorLoc, temp;
669 string = constraint_printDetailedPostCondition (c);
675 temp = constraint_getFileloc (c);
678 if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES ) )
680 string = cstring_replaceChar(string, '\n', ' ');
683 if (fileloc_isDefined (temp))
686 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
691 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
695 /*drl added 8-11-001*/
696 cstring constraint_printLocation (/*@observer@*/ /*@temp@*/ constraint c) /*@*/
701 string = constraint_print (c);
703 errorLoc = constraint_getFileloc (c);
705 ret = message ("constraint: %q @ %q", string, fileloc_unparse (errorLoc));
707 fileloc_free (errorLoc);
714 void constraint_printError (constraint c, fileloc loc)
717 fileloc errorLoc, temp;
720 /*drl 11/26/2001 avoid printing tautological constraints */
721 if (constraint_isAlwaysTrue (c))
727 string = constraint_printDetailed (c);
731 temp = constraint_getFileloc (c);
733 if (fileloc_isDefined (temp))
740 DPRINTF (("constraint %s had undefined fileloc %s", constraint_print (c), fileloc_unparse (temp)));
742 errorLoc = fileloc_copy (errorLoc);
746 if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES ) )
748 string = cstring_replaceChar(string, '\n', ' ');
754 voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
758 if (constraint_hasMaxSet (c))
760 voptgenerror (FLG_BOUNDSWRITE, string, errorLoc);
764 voptgenerror (FLG_BOUNDSREAD, string, errorLoc);
768 fileloc_free(errorLoc);
771 static cstring constraint_printDeep (constraint c)
774 cstring st = cstring_undefined;
776 st = constraint_print(c);
778 if (c->orig != constraint_undefined)
780 st = cstring_appendChar (st, '\n');
781 genExpr = exprNode_unparse (c->orig->generatingExpr);
787 st = cstring_concatFree (st, message (" derived from %s precondition: %q",
788 genExpr, constraint_printDeep (c->orig)));
792 st = cstring_concatFree (st, message (" needed to satisfy precondition:\n%q",
793 constraint_printDeep (c->orig)));
798 st = cstring_concatFree (st, message ("derived from: %q",
799 constraint_printDeep (c->orig)));
807 static /*@only@*/ cstring constraint_printDetailedPostCondition (/*@observer@*/ /*@temp@*/ constraint c)
809 cstring st = cstring_undefined;
812 st = message ("Unsatisfied ensures constraint condition:\nSplint is unable to verify the constraint %q", constraint_printDeep (c));
814 genExpr = exprNode_unparse (c->generatingExpr);
816 if (context_getFlag (FLG_CONSTRAINTLOCATION))
820 temp = message ("\nOriginal Generating expression %q: %s\n",
821 fileloc_unparse ( exprNode_getfileloc (c->generatingExpr)),
823 st = cstring_concatFree (st, temp);
825 if (constraint_hasMaxSet (c))
827 temp = message ("Has MaxSet\n");
828 st = cstring_concatFree (st, temp);
834 cstring constraint_printDetailed (constraint c)
836 cstring st = cstring_undefined;
837 cstring temp = cstring_undefined;
842 st = message ("Unable to resolve constraint:\n%q", constraint_printDeep (c));
846 st = message ("Block Post condition:\nThis function block has the post condition %q", constraint_printDeep (c));
849 if (constraint_hasMaxSet (c))
851 temp = cstring_makeLiteral ("Possible out-of-bounds store:\n");
855 temp = cstring_makeLiteral ("Possible out-of-bounds read:\n");
858 genExpr = exprNode_unparse (c->generatingExpr);
860 if (context_getFlag (FLG_CONSTRAINTLOCATION))
863 temp2 = message ("%s\n", genExpr);
864 temp = cstring_concatFree (temp, temp2);
867 st = cstring_concatFree (temp,st);
872 /*@only@*/ cstring constraint_print (constraint c) /*@*/
874 cstring st = cstring_undefined;
875 cstring type = cstring_undefined;
879 if (context_getFlag (FLG_PARENCONSTRAINT))
881 type = cstring_makeLiteral ("ensures: ");
885 type = cstring_makeLiteral ("ensures");
890 if (context_getFlag (FLG_PARENCONSTRAINT))
892 type = cstring_makeLiteral ("requires: ");
896 type = cstring_makeLiteral ("requires");
900 if (context_getFlag (FLG_PARENCONSTRAINT))
902 st = message ("%q: %q %q %q",
904 constraintExpr_print (c->lexpr),
905 arithType_print (c->ar),
906 constraintExpr_print (c->expr)
911 st = message ("%q %q %q %q",
913 constraintExpr_print (c->lexpr),
914 arithType_print (c->ar),
915 constraintExpr_print (c->expr)
921 cstring constraint_printOr (constraint c) /*@*/
926 ret = cstring_undefined;
929 ret = cstring_concatFree (ret, constraint_print (temp));
933 while ( constraint_isDefined (temp))
935 ret = cstring_concatFree (ret, cstring_makeLiteral (" OR "));
936 ret = cstring_concatFree (ret, constraint_print (temp));
944 /*@only@*/ constraint constraint_doSRefFixBaseParam (/*@returned@*/ /*@only@*/ constraint precondition,
945 exprNodeList arglist)
947 precondition->lexpr = constraintExpr_doSRefFixBaseParam (precondition->lexpr,
949 precondition->expr = constraintExpr_doSRefFixBaseParam (precondition->expr,
956 constraint constraint_doFixResult (constraint postcondition, /*@dependent@*/ exprNode fcnCall)
958 postcondition = constraint_copy (postcondition);
959 postcondition->lexpr = constraintExpr_doFixResult (postcondition->lexpr, fcnCall);
960 postcondition->expr = constraintExpr_doFixResult (postcondition->expr, fcnCall);
962 return postcondition;
964 /*Commenting out temporally
966 / *@only@* /constraint constraint_doSRefFixInvarConstraint(constraint invar, sRef s, ctype ct )
969 invar = constraint_copy (invar);
970 invar->lexpr = constraintExpr_doSRefFixInvarConstraint (invar->lexpr, s, ct);
971 invar->expr = constraintExpr_doSRefFixInvarConstraint (invar->expr, s, ct);
977 /*@only@*/ constraint constraint_doSRefFixConstraintParam (constraint precondition,
978 exprNodeList arglist)
981 precondition = constraint_copy (precondition);
982 precondition->lexpr = constraintExpr_doSRefFixConstraintParam (precondition->lexpr, arglist);
983 precondition->expr = constraintExpr_doSRefFixConstraintParam (precondition->expr, arglist);
985 precondition->fcnPre = FALSE;
989 constraint constraint_preserveOrig (/*@returned@*/ constraint c) /*@modifies c @*/
992 DPRINTF ((message ("Doing constraint_preserverOrig for %q ", constraint_printDetailed (c))));
994 if (c->orig == constraint_undefined)
995 c->orig = constraint_copy (c);
997 else if (c->orig->fcnPre)
1003 /* avoid infinite loop */
1005 c->orig = constraint_copy (c);
1006 if (c->orig->orig == NULL)
1008 c->orig->orig = temp;
1013 llcontbug ((message ("Expected c->orig->orig to be null")));
1014 constraint_free (c->orig->orig);
1015 c->orig->orig = temp;
1021 DPRINTF ((message ("Not changing constraint")));
1024 DPRINTF ((message ("After Doing constraint_preserverOrig for %q ", constraint_printDetailed (c))));
1033 constraint constraint_togglePost (/*@returned@*/ constraint c)
1039 constraint constraint_togglePostOrig (/*@returned@*/ constraint c)
1041 if (c->orig != NULL)
1042 c->orig = constraint_togglePost (c->orig);
1046 bool constraint_hasOrig ( /*@observer@*/ /*@temp@*/ constraint c)
1048 if (c->orig == NULL)
1055 constraint constraint_undump (FILE *f)
1062 constraintExpr lexpr;
1063 constraintExpr expr;
1070 os = mstring_create (MAX_DUMP_LINE_LENGTH);
1072 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1074 /*@i33*/ /*this should probably be wrappered...*/
1076 fcnPre = (bool) reader_getInt (&s);
1078 post = (bool) reader_getInt (&s);
1080 ar = (arithType) reader_getInt (&s);
1082 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1084 reader_checkChar (&s, 'l');
1086 lexpr = constraintExpr_undump (f);
1088 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1090 reader_checkChar (&s, 'r');
1091 expr = constraintExpr_undump (f);
1093 c = constraint_makeNew ();
1103 c = constraint_preserveOrig (c);
1108 void constraint_dump (/*@observer@*/ constraint c, FILE *f)
1114 constraintExpr lexpr;
1115 constraintExpr expr;
1124 fprintf (f, "%d@%d@%d\n", (int) fcnPre, (int) post, (int) ar);
1126 constraintExpr_dump (lexpr, f);
1128 constraintExpr_dump (expr, f);
1132 int constraint_compare (/*@observer@*/ /*@temp@*/ const constraint * c1, /*@observer@*/ /*@temp@*/ const constraint * c2) /*@*/
1138 llassert (constraint_isDefined (*c1));
1139 llassert (constraint_isDefined (*c2));
1141 if (constraint_isUndefined (*c1))
1143 if (constraint_isUndefined (*c2))
1149 if (constraint_isUndefined (*c2))
1154 loc1 = constraint_getFileloc (*c1);
1155 loc2 = constraint_getFileloc (*c2);
1157 ret = fileloc_compare (loc1, loc2);
1159 fileloc_free (loc1);
1160 fileloc_free (loc2);
1166 bool constraint_isPost (/*@observer@*/ /*@temp@*/ constraint c)
1168 llassert (constraint_isDefined (c));
1170 if (constraint_isUndefined (c))
1177 static int constraint_getDepth (/*@observer@*/ /*@temp@*/ constraint c)
1181 l = constraintExpr_getDepth (c->lexpr);
1182 r = constraintExpr_getDepth (c->expr);
1186 DPRINTF (( message ("constraint depth returning %d for %s", l, constraint_print (c))));
1191 DPRINTF (( message ("constraint depth returning %d for %s", r, constraint_print (c))));
1197 bool constraint_tooDeep (/*@observer@*/ /*@temp@*/ constraint c)
1201 temp = constraint_getDepth (c);