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! */
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))
117 Changed the name old name was makeConstraintParse3
119 constraint constraint_makeConstraintLltok (constraintExpr l, lltok relOp, constraintExpr r)
122 ret = constraint_makeNew ();
123 llassert (constraintExpr_isDefined (l));
125 ret->lexpr = constraintExpr_copy (l);
127 if (lltok_getTok (relOp) == GE_OP)
131 else if (lltok_getTok (relOp) == LE_OP)
135 else if (lltok_getTok (relOp) == EQ_OP)
140 llfatalbug ( message ("Unsupported relational operator"));
142 ret->expr = constraintExpr_copy (r);
146 ret->orig = constraint_copy (ret);
148 ret = constraint_simplify (ret);
149 /* ret->orig = ret; */
151 DPRINTF (("GENERATED CONSTRAINT:"));
152 DPRINTF ((message ("%s", constraint_print (ret))));
156 constraint constraint_copy (/*@temp@*/ /*@observer@*/ constraint c)
160 llassert (constraint_isDefined (c));
162 ret = constraint_makeNew ();
163 ret->lexpr = constraintExpr_copy (c->lexpr);
165 ret->expr = constraintExpr_copy (c->expr);
168 ret->generatingExpr = c->generatingExpr;
173 ret->orig = constraint_copy (c->orig);
178 ret->or = constraint_copy (c->or);
182 ret->fcnPre = c->fcnPre;
187 /*like copy expect it doesn't allocate memory for the constraint*/
189 void constraint_overWrite (constraint c1, constraint c2)
191 llassert (constraint_isDefined (c1));
195 DPRINTF ((message ("OverWriteing constraint %q with %q", constraint_print (c1),
196 constraint_print (c2))));
198 constraintExpr_free (c1->lexpr);
199 constraintExpr_free (c1->expr);
201 c1->lexpr = constraintExpr_copy (c2->lexpr);
203 c1->expr = constraintExpr_copy (c2->expr);
206 if (c1->orig != NULL)
207 constraint_free (c1->orig);
209 if (c2->orig != NULL)
210 c1->orig = constraint_copy (c2->orig);
214 /*@i33 make sure that the or is freed correctly*/
216 constraint_free (c1->or);
219 c1->or = constraint_copy (c2->or);
223 c1->fcnPre = c2->fcnPre;
226 c1->generatingExpr = c2->generatingExpr;
232 static /*@notnull@*/ /*@special@*/ constraint constraint_makeNew (void)
233 /*@post:isnull result->or, result->orig, result->generatingExpr, result->fcnPre @*/
234 /*@defines result->or, result->generatingExpr, result->orig, result->fcnPre @*/
237 ret = dmalloc (sizeof (*ret));
244 ret->generatingExpr = NULL;
249 constraint constraint_addGeneratingExpr (/*@returned@*/ constraint c, /*@exposed@*/ exprNode e)
252 if (c->generatingExpr == NULL)
254 c->generatingExpr = e;
255 DPRINTF ((message ("setting generatingExpr for %s to %s", constraint_print (c), exprNode_unparse (e)) ));
259 DPRINTF ((message ("Not setting generatingExpr for %s to %s", constraint_print (c), exprNode_unparse (e)) ));
264 constraint constraint_origAddGeneratingExpr (/*@returned@*/ constraint c, exprNode e)
267 if (c->orig != constraint_undefined)
269 c->orig = constraint_addGeneratingExpr (c->orig, e);
273 DPRINTF ((message ("constraint_origAddGeneratingExpr: Not setting generatingExpr for %s to %s", constraint_print (c), exprNode_unparse (e)) ));
278 constraint constraint_setFcnPre (/*@returned@*/ constraint c)
281 if (c->orig != constraint_undefined)
283 c->orig->fcnPre = TRUE;
288 DPRINTF (( message ("Warning Setting fcnPre directly")));
296 fileloc constraint_getFileloc (constraint c)
298 if (exprNode_isDefined (c->generatingExpr))
299 return (fileloc_copy (exprNode_getfileloc (c->generatingExpr)));
301 return (constraintExpr_getFileloc (c->lexpr));
306 static bool checkForMaxSet (constraint c)
308 if (constraintExpr_hasMaxSet (c->lexpr) || constraintExpr_hasMaxSet (c->expr))
314 bool constraint_hasMaxSet (constraint c)
316 if (checkForMaxSet (c))
321 if (checkForMaxSet (c->orig))
328 constraint constraint_makeReadSafeExprNode (exprNode po, exprNode ind)
330 constraint ret = constraint_makeNew ();
334 ret->lexpr = constraintExpr_makeMaxReadExpr (po);
336 ret->expr = constraintExpr_makeValueExpr (ind);
341 constraint constraint_makeWriteSafeInt ( exprNode po, int ind)
343 constraint ret = constraint_makeNew ();
346 ret->lexpr =constraintExpr_makeMaxSetExpr (po);
348 ret->expr = constraintExpr_makeIntLiteral (ind);
352 constraint constraint_makeSRefSetBufferSize (sRef s, long int size)
354 constraint ret = constraint_makeNew ();
355 ret->lexpr = constraintExpr_makeSRefMaxset (s);
357 ret->expr = constraintExpr_makeIntLiteral ((int)size);
362 constraint constraint_makeSRefWriteSafeInt (sRef s, int ind)
364 constraint ret = constraint_makeNew ();
367 ret->lexpr = constraintExpr_makeSRefMaxset ( s);
369 ret->expr = constraintExpr_makeIntLiteral (ind);
374 /* drl added 01/12/2000
376 makes the constraint: Ensures index <= MaxRead (buffer) */
378 constraint constraint_makeEnsureLteMaxRead (exprNode index, exprNode buffer)
380 constraint ret = constraint_makeNew ();
382 ret->lexpr = constraintExpr_makeValueExpr (index);
384 ret->expr = constraintExpr_makeMaxReadExpr (buffer);
389 constraint constraint_makeWriteSafeExprNode (exprNode po, exprNode ind)
391 constraint ret = constraint_makeNew ();
394 ret->lexpr =constraintExpr_makeMaxSetExpr (po);
396 ret->expr = constraintExpr_makeValueExpr (ind);
401 constraint constraint_makeReadSafeInt ( exprNode t1, int index)
403 constraint ret = constraint_makeNew ();
405 ret->lexpr = constraintExpr_makeMaxReadExpr (t1);
407 ret->expr = constraintExpr_makeIntLiteral (index);
412 constraint constraint_makeSRefReadSafeInt (sRef s, int ind)
414 constraint ret = constraint_makeNew ();
417 ret->lexpr = constraintExpr_makeSRefMaxRead (s);
419 ret->expr = constraintExpr_makeIntLiteral (ind);
424 constraint constraint_makeEnsureMaxReadAtLeast (exprNode t1, exprNode t2, fileloc sequencePoint)
428 ret = constraint_makeReadSafeExprNode (t1, t2);
429 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
435 static constraint constraint_makeEnsuresOpConstraintExpr (/*@only@*/ constraintExpr c1, /*@only@*/ constraintExpr c2, fileloc sequencePoint, arithType ar)
440 llassert (constraintExpr_isDefined (c1) && constraintExpr_isDefined (c2));
442 ret = constraint_makeNew ();
448 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
452 static constraint constraint_makeEnsuresOp (/*@dependent@*/ exprNode e1, /*@dependent@*/ exprNode e2, fileloc sequencePoint, arithType ar)
454 constraintExpr c1, c2;
458 if (! (exprNode_isDefined (e1) && exprNode_isDefined (e2)))
460 llcontbug ((message ("null exprNode, Exprnodes are %s and %s",
461 exprNode_unparse (e1), exprNode_unparse (e2))
466 c1 = constraintExpr_makeValueExpr (e);
469 c2 = constraintExpr_makeValueExpr (e);
471 ret = constraint_makeEnsuresOpConstraintExpr (c1, c2, sequencePoint, ar);
477 /* make constraint ensures e1 == e2 */
479 constraint constraint_makeEnsureEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
481 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, EQ));
484 /*make constraint ensures e1 < e2 */
485 constraint constraint_makeEnsureLessThan (exprNode e1, exprNode e2, fileloc sequencePoint)
487 constraintExpr t1, t2;
489 t1 = constraintExpr_makeValueExpr (e1);
490 t2 = constraintExpr_makeValueExpr (e2);
492 /*change this to e1 <= (e2 -1) */
494 t2 = constraintExpr_makeDecConstraintExpr (t2);
496 return ( constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, LTE));
499 constraint constraint_makeEnsureLessThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
501 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, LTE));
504 constraint constraint_makeEnsureGreaterThan (exprNode e1, exprNode e2, fileloc sequencePoint)
506 constraintExpr t1, t2;
508 t1 = constraintExpr_makeValueExpr (e1);
509 t2 = constraintExpr_makeValueExpr (e2);
512 /* change this to e1 >= (e2 + 1) */
513 t2 = constraintExpr_makeIncConstraintExpr (t2);
516 return ( constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, GTE));
519 constraint constraint_makeEnsureGreaterThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
521 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, GTE));
525 exprNode exprNode_copyConstraints (/*@returned@*/ exprNode dst, exprNode src)
527 constraintList_free (dst->ensuresConstraints);
528 constraintList_free (dst->requiresConstraints);
529 constraintList_free (dst->trueEnsuresConstraints);
530 constraintList_free (dst->falseEnsuresConstraints);
532 dst->ensuresConstraints = constraintList_copy (src->ensuresConstraints);
533 dst->requiresConstraints = constraintList_copy (src->requiresConstraints);
534 dst->trueEnsuresConstraints = constraintList_copy (src->trueEnsuresConstraints);
535 dst->falseEnsuresConstraints = constraintList_copy (src->falseEnsuresConstraints);
539 /* Makes the constraint e = e + f */
540 constraint constraint_makeAddAssign (exprNode e, exprNode f, fileloc sequencePoint)
542 constraintExpr x1, x2, y;
545 ret = constraint_makeNew ();
547 x1 = constraintExpr_makeValueExpr (e);
548 x2 = constraintExpr_copy (x1);
549 y = constraintExpr_makeValueExpr (f);
554 ret->expr = constraintExpr_makeAddExpr (x2, y);
556 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
562 /* Makes the constraint e = e - f */
563 constraint constraint_makeSubtractAssign (exprNode e, exprNode f, fileloc sequencePoint)
565 constraintExpr x1, x2, y;
568 ret = constraint_makeNew ();
570 x1 = constraintExpr_makeValueExpr (e);
571 x2 = constraintExpr_copy (x1);
572 y = constraintExpr_makeValueExpr (f);
577 ret->expr = constraintExpr_makeSubtractExpr (x2, y);
579 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
584 constraint constraint_makeMaxSetSideEffectPostDecrement (exprNode e, fileloc sequencePoint)
586 constraint ret = constraint_makeNew ();
588 ret->lexpr = constraintExpr_makeValueExpr (e);
591 ret->expr = constraintExpr_makeValueExpr (e);
592 ret->expr = constraintExpr_makeDecConstraintExpr (ret->expr);
593 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
596 constraint constraint_makeMaxSetSideEffectPostIncrement (exprNode e, fileloc sequencePoint)
598 constraint ret = constraint_makeNew ();
600 ret->lexpr = constraintExpr_makeValueExpr (e);
603 ret->expr = constraintExpr_makeValueExpr (e);
604 ret->expr = constraintExpr_makeIncConstraintExpr (ret->expr);
606 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
611 void constraint_free (/*@only@*/ constraint c)
613 llassert (constraint_isDefined (c));
616 if (constraint_isDefined (c->orig))
617 constraint_free (c->orig);
618 if ( constraint_isDefined (c->or))
619 constraint_free (c->or);
622 constraintExpr_free (c->lexpr);
623 constraintExpr_free (c->expr);
634 cstring arithType_print (arithType ar) /*@*/
636 cstring st = cstring_undefined;
640 st = cstring_makeLiteral ("<");
643 st = cstring_makeLiteral ("<=");
646 st = cstring_makeLiteral (">");
649 st = cstring_makeLiteral (">=");
652 st = cstring_makeLiteral ("==");
655 st = cstring_makeLiteral ("NONNEGATIVE");
658 st = cstring_makeLiteral ("POSITIVE");
667 void constraint_printErrorPostCondition (constraint c, fileloc loc)
670 fileloc errorLoc, temp;
672 string = constraint_printDetailedPostCondition (c);
678 temp = constraint_getFileloc (c);
681 if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES ) )
683 string = cstring_replaceChar(string, '\n', ' ');
686 if (fileloc_isDefined (temp))
689 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
694 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
698 /*drl added 8-11-001*/
699 cstring constraint_printLocation (/*@observer@*/ /*@temp@*/ constraint c) /*@*/
704 string = constraint_print (c);
706 errorLoc = constraint_getFileloc (c);
708 ret = message ("constraint: %q @ %q", string, fileloc_unparse (errorLoc));
710 fileloc_free (errorLoc);
717 void constraint_printError (constraint c, fileloc loc)
720 fileloc errorLoc, temp;
723 c = constraint_simplify(c);
725 /*drl 11/26/2001 avoid printing tautological constraints */
726 if (constraint_isAlwaysTrue (c))
732 string = constraint_printDetailed (c);
736 temp = constraint_getFileloc (c);
738 if (fileloc_isDefined (temp))
745 DPRINTF (("constraint %s had undefined fileloc %s", constraint_print (c), fileloc_unparse (temp)));
747 errorLoc = fileloc_copy (errorLoc);
751 if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES ) )
753 string = cstring_replaceChar(string, '\n', ' ');
759 voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
763 if (constraint_hasMaxSet (c))
765 voptgenerror (FLG_BOUNDSWRITE, string, errorLoc);
769 voptgenerror (FLG_BOUNDSREAD, string, errorLoc);
773 fileloc_free(errorLoc);
776 static cstring constraint_printDeep (constraint c)
779 cstring st = cstring_undefined;
781 st = constraint_print(c);
783 if (c->orig != constraint_undefined)
785 st = cstring_appendChar (st, '\n');
786 genExpr = exprNode_unparse (c->orig->generatingExpr);
792 st = cstring_concatFree (st, message (" derived from %s precondition: %q",
793 genExpr, constraint_printDeep (c->orig)));
797 st = cstring_concatFree (st, message (" needed to satisfy precondition:\n%q",
798 constraint_printDeep (c->orig)));
803 st = cstring_concatFree (st, message ("derived from: %q",
804 constraint_printDeep (c->orig)));
812 static /*@only@*/ cstring constraint_printDetailedPostCondition (/*@observer@*/ /*@temp@*/ constraint c)
814 cstring st = cstring_undefined;
817 st = message ("Unsatisfied ensures constraint condition:\nSplint is unable to verify the constraint %q", constraint_printDeep (c));
819 genExpr = exprNode_unparse (c->generatingExpr);
821 if (context_getFlag (FLG_CONSTRAINTLOCATION))
825 temp = message ("\nOriginal Generating expression %q: %s\n",
826 fileloc_unparse ( exprNode_getfileloc (c->generatingExpr)),
828 st = cstring_concatFree (st, temp);
830 if (constraint_hasMaxSet (c))
832 temp = message ("Has MaxSet\n");
833 st = cstring_concatFree (st, temp);
839 cstring constraint_printDetailed (constraint c)
841 cstring st = cstring_undefined;
842 cstring temp = cstring_undefined;
847 st = message ("Unable to resolve constraint:\n%q", constraint_printDeep (c));
851 st = message ("Block Post condition:\nThis function block has the post condition %q", constraint_printDeep (c));
854 if (constraint_hasMaxSet (c))
856 temp = cstring_makeLiteral ("Possible out-of-bounds store:\n");
860 temp = cstring_makeLiteral ("Possible out-of-bounds read:\n");
863 genExpr = exprNode_unparse (c->generatingExpr);
865 if (context_getFlag (FLG_CONSTRAINTLOCATION))
868 temp2 = message ("%s\n", genExpr);
869 temp = cstring_concatFree (temp, temp2);
872 st = cstring_concatFree (temp,st);
877 /*@only@*/ cstring constraint_print (constraint c) /*@*/
879 cstring st = cstring_undefined;
880 cstring type = cstring_undefined;
884 if (context_getFlag (FLG_PARENCONSTRAINT))
886 type = cstring_makeLiteral ("ensures: ");
890 type = cstring_makeLiteral ("ensures");
895 if (context_getFlag (FLG_PARENCONSTRAINT))
897 type = cstring_makeLiteral ("requires: ");
901 type = cstring_makeLiteral ("requires");
905 if (context_getFlag (FLG_PARENCONSTRAINT))
907 st = message ("%q: %q %q %q",
909 constraintExpr_print (c->lexpr),
910 arithType_print (c->ar),
911 constraintExpr_print (c->expr)
916 st = message ("%q %q %q %q",
918 constraintExpr_print (c->lexpr),
919 arithType_print (c->ar),
920 constraintExpr_print (c->expr)
926 cstring constraint_printOr (constraint c) /*@*/
931 ret = cstring_undefined;
934 ret = cstring_concatFree (ret, constraint_print (temp));
938 while ( constraint_isDefined (temp))
940 ret = cstring_concatFree (ret, cstring_makeLiteral (" OR "));
941 ret = cstring_concatFree (ret, constraint_print (temp));
949 /*@only@*/ constraint constraint_doSRefFixBaseParam (/*@returned@*/ /*@only@*/ constraint precondition,
950 exprNodeList arglist)
952 precondition->lexpr = constraintExpr_doSRefFixBaseParam (precondition->lexpr,
954 precondition->expr = constraintExpr_doSRefFixBaseParam (precondition->expr,
961 constraint constraint_doFixResult (constraint postcondition, /*@dependent@*/ exprNode fcnCall)
963 postcondition = constraint_copy (postcondition);
964 postcondition->lexpr = constraintExpr_doFixResult (postcondition->lexpr, fcnCall);
965 postcondition->expr = constraintExpr_doFixResult (postcondition->expr, fcnCall);
967 return postcondition;
969 /*Commenting out temporally
971 / *@only@* /constraint constraint_doSRefFixInvarConstraint(constraint invar, sRef s, ctype ct )
974 invar = constraint_copy (invar);
975 invar->lexpr = constraintExpr_doSRefFixInvarConstraint (invar->lexpr, s, ct);
976 invar->expr = constraintExpr_doSRefFixInvarConstraint (invar->expr, s, ct);
982 /*@only@*/ constraint constraint_doSRefFixConstraintParam (constraint precondition,
983 exprNodeList arglist)
986 precondition = constraint_copy (precondition);
987 precondition->lexpr = constraintExpr_doSRefFixConstraintParam (precondition->lexpr, arglist);
988 precondition->expr = constraintExpr_doSRefFixConstraintParam (precondition->expr, arglist);
990 precondition->fcnPre = FALSE;
994 constraint constraint_preserveOrig (/*@returned@*/ constraint c) /*@modifies c @*/
997 DPRINTF ((message ("Doing constraint_preserverOrig for %q ", constraint_printDetailed (c))));
999 if (c->orig == constraint_undefined)
1000 c->orig = constraint_copy (c);
1002 else if (c->orig->fcnPre)
1008 /* avoid infinite loop */
1010 c->orig = constraint_copy (c);
1011 if (c->orig->orig == NULL)
1013 c->orig->orig = temp;
1018 llcontbug ((message ("Expected c->orig->orig to be null")));
1019 constraint_free (c->orig->orig);
1020 c->orig->orig = temp;
1026 DPRINTF ((message ("Not changing constraint")));
1029 DPRINTF ((message ("After Doing constraint_preserverOrig for %q ", constraint_printDetailed (c))));
1038 constraint constraint_togglePost (/*@returned@*/ constraint c)
1044 constraint constraint_togglePostOrig (/*@returned@*/ constraint c)
1046 if (c->orig != NULL)
1047 c->orig = constraint_togglePost (c->orig);
1051 bool constraint_hasOrig ( /*@observer@*/ /*@temp@*/ constraint c)
1053 if (c->orig == NULL)
1060 constraint constraint_undump (FILE *f)
1067 constraintExpr lexpr;
1068 constraintExpr expr;
1075 os = mstring_create (MAX_DUMP_LINE_LENGTH);
1077 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1079 /*@i33*/ /*this should probably be wrappered...*/
1081 fcnPre = (bool) reader_getInt (&s);
1083 post = (bool) reader_getInt (&s);
1085 ar = (arithType) reader_getInt (&s);
1087 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1089 reader_checkChar (&s, 'l');
1091 lexpr = constraintExpr_undump (f);
1093 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1095 reader_checkChar (&s, 'r');
1096 expr = constraintExpr_undump (f);
1098 c = constraint_makeNew ();
1108 c = constraint_preserveOrig (c);
1113 void constraint_dump (/*@observer@*/ constraint c, FILE *f)
1119 constraintExpr lexpr;
1120 constraintExpr expr;
1129 fprintf (f, "%d@%d@%d\n", (int) fcnPre, (int) post, (int) ar);
1131 constraintExpr_dump (lexpr, f);
1133 constraintExpr_dump (expr, f);
1137 int constraint_compare (/*@observer@*/ /*@temp@*/ const constraint * c1, /*@observer@*/ /*@temp@*/ const constraint * c2) /*@*/
1143 llassert (constraint_isDefined (*c1));
1144 llassert (constraint_isDefined (*c2));
1146 if (constraint_isUndefined (*c1))
1148 if (constraint_isUndefined (*c2))
1154 if (constraint_isUndefined (*c2))
1159 loc1 = constraint_getFileloc (*c1);
1160 loc2 = constraint_getFileloc (*c2);
1162 ret = fileloc_compare (loc1, loc2);
1164 fileloc_free (loc1);
1165 fileloc_free (loc2);
1171 bool constraint_isPost (/*@observer@*/ /*@temp@*/ constraint c)
1173 llassert (constraint_isDefined (c));
1175 if (constraint_isUndefined (c))
1182 static int constraint_getDepth (/*@observer@*/ /*@temp@*/ constraint c)
1186 l = constraintExpr_getDepth (c->lexpr);
1187 r = constraintExpr_getDepth (c->expr);
1191 DPRINTF (( message ("constraint depth returning %d for %s", l, constraint_print (c))));
1196 DPRINTF (( message ("constraint depth returning %d for %s", r, constraint_print (c))));
1202 bool constraint_tooDeep (/*@observer@*/ /*@temp@*/ constraint c)
1206 temp = constraint_getDepth (c);