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;
487 t1 = constraintExpr_makeValueExpr (e1);
488 t2 = constraintExpr_makeValueExpr (e2);
490 /*change this to e1 <= (e2 -1) */
492 t2 = constraintExpr_makeDecConstraintExpr (t2);
494 t3 = constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, LTE);
496 t3 = constraint_simplify(t3);
500 constraint constraint_makeEnsureLessThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
502 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, LTE));
505 constraint constraint_makeEnsureGreaterThan (exprNode e1, exprNode e2, fileloc sequencePoint)
507 constraintExpr t1, t2;
510 t1 = constraintExpr_makeValueExpr (e1);
511 t2 = constraintExpr_makeValueExpr (e2);
514 /* change this to e1 >= (e2 + 1) */
515 t2 = constraintExpr_makeIncConstraintExpr (t2);
517 t3 = constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, GTE);
519 t3 = constraint_simplify(t3);
524 constraint constraint_makeEnsureGreaterThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
526 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, GTE));
530 exprNode exprNode_copyConstraints (/*@returned@*/ exprNode dst, exprNode src)
532 constraintList_free (dst->ensuresConstraints);
533 constraintList_free (dst->requiresConstraints);
534 constraintList_free (dst->trueEnsuresConstraints);
535 constraintList_free (dst->falseEnsuresConstraints);
537 dst->ensuresConstraints = constraintList_copy (src->ensuresConstraints);
538 dst->requiresConstraints = constraintList_copy (src->requiresConstraints);
539 dst->trueEnsuresConstraints = constraintList_copy (src->trueEnsuresConstraints);
540 dst->falseEnsuresConstraints = constraintList_copy (src->falseEnsuresConstraints);
544 /* Makes the constraint e = e + f */
545 constraint constraint_makeAddAssign (exprNode e, exprNode f, fileloc sequencePoint)
547 constraintExpr x1, x2, y;
550 ret = constraint_makeNew ();
552 x1 = constraintExpr_makeValueExpr (e);
553 x2 = constraintExpr_copy (x1);
554 y = constraintExpr_makeValueExpr (f);
559 ret->expr = constraintExpr_makeAddExpr (x2, y);
561 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
567 /* Makes the constraint e = e - f */
568 constraint constraint_makeSubtractAssign (exprNode e, exprNode f, fileloc sequencePoint)
570 constraintExpr x1, x2, y;
573 ret = constraint_makeNew ();
575 x1 = constraintExpr_makeValueExpr (e);
576 x2 = constraintExpr_copy (x1);
577 y = constraintExpr_makeValueExpr (f);
582 ret->expr = constraintExpr_makeSubtractExpr (x2, y);
584 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
589 constraint constraint_makeMaxSetSideEffectPostDecrement (exprNode e, fileloc sequencePoint)
591 constraint ret = constraint_makeNew ();
593 ret->lexpr = constraintExpr_makeValueExpr (e);
596 ret->expr = constraintExpr_makeValueExpr (e);
597 ret->expr = constraintExpr_makeDecConstraintExpr (ret->expr);
598 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
601 constraint constraint_makeMaxSetSideEffectPostIncrement (exprNode e, fileloc sequencePoint)
603 constraint ret = constraint_makeNew ();
605 ret->lexpr = constraintExpr_makeValueExpr (e);
608 ret->expr = constraintExpr_makeValueExpr (e);
609 ret->expr = constraintExpr_makeIncConstraintExpr (ret->expr);
611 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
616 void constraint_free (/*@only@*/ constraint c)
618 llassert (constraint_isDefined (c));
621 if (constraint_isDefined (c->orig))
622 constraint_free (c->orig);
623 if ( constraint_isDefined (c->or))
624 constraint_free (c->or);
627 constraintExpr_free (c->lexpr);
628 constraintExpr_free (c->expr);
639 cstring arithType_print (arithType ar) /*@*/
641 cstring st = cstring_undefined;
645 st = cstring_makeLiteral ("<");
648 st = cstring_makeLiteral ("<=");
651 st = cstring_makeLiteral (">");
654 st = cstring_makeLiteral (">=");
657 st = cstring_makeLiteral ("==");
660 st = cstring_makeLiteral ("NONNEGATIVE");
663 st = cstring_makeLiteral ("POSITIVE");
672 void constraint_printErrorPostCondition (constraint c, fileloc loc)
675 fileloc errorLoc, temp;
677 string = constraint_printDetailedPostCondition (c);
683 temp = constraint_getFileloc (c);
686 if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES ) )
688 string = cstring_replaceChar(string, '\n', ' ');
691 if (fileloc_isDefined (temp))
694 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
699 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
703 /*drl added 8-11-001*/
704 cstring constraint_printLocation (/*@observer@*/ /*@temp@*/ constraint c) /*@*/
709 string = constraint_print (c);
711 errorLoc = constraint_getFileloc (c);
713 ret = message ("constraint: %q @ %q", string, fileloc_unparse (errorLoc));
715 fileloc_free (errorLoc);
722 void constraint_printError (constraint c, fileloc loc)
725 fileloc errorLoc, temp;
728 /*drl 11/26/2001 avoid printing tautological constraints */
729 if (constraint_isAlwaysTrue (c))
735 string = constraint_printDetailed (c);
739 temp = constraint_getFileloc (c);
741 if (fileloc_isDefined (temp))
748 DPRINTF (("constraint %s had undefined fileloc %s", constraint_print (c), fileloc_unparse (temp)));
750 errorLoc = fileloc_copy (errorLoc);
754 if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES ) )
756 string = cstring_replaceChar(string, '\n', ' ');
762 voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
766 if (constraint_hasMaxSet (c))
768 voptgenerror (FLG_BOUNDSWRITE, string, errorLoc);
772 voptgenerror (FLG_BOUNDSREAD, string, errorLoc);
776 fileloc_free(errorLoc);
779 static cstring constraint_printDeep (constraint c)
782 cstring st = cstring_undefined;
784 st = constraint_print(c);
786 if (c->orig != constraint_undefined)
788 st = cstring_appendChar (st, '\n');
789 genExpr = exprNode_unparse (c->orig->generatingExpr);
795 st = cstring_concatFree (st, message (" derived from %s precondition: %q",
796 genExpr, constraint_printDeep (c->orig)));
800 st = cstring_concatFree (st, message (" needed to satisfy precondition:\n%q",
801 constraint_printDeep (c->orig)));
806 st = cstring_concatFree (st, message ("derived from: %q",
807 constraint_printDeep (c->orig)));
815 static /*@only@*/ cstring constraint_printDetailedPostCondition (/*@observer@*/ /*@temp@*/ constraint c)
817 cstring st = cstring_undefined;
820 st = message ("Unsatisfied ensures constraint condition:\nSplint is unable to verify the constraint %q", constraint_printDeep (c));
822 genExpr = exprNode_unparse (c->generatingExpr);
824 if (context_getFlag (FLG_CONSTRAINTLOCATION))
828 temp = message ("\nOriginal Generating expression %q: %s\n",
829 fileloc_unparse ( exprNode_getfileloc (c->generatingExpr)),
831 st = cstring_concatFree (st, temp);
833 if (constraint_hasMaxSet (c))
835 temp = message ("Has MaxSet\n");
836 st = cstring_concatFree (st, temp);
842 cstring constraint_printDetailed (constraint c)
844 cstring st = cstring_undefined;
845 cstring temp = cstring_undefined;
850 st = message ("Unable to resolve constraint:\n%q", constraint_printDeep (c));
854 st = message ("Block Post condition:\nThis function block has the post condition %q", constraint_printDeep (c));
857 if (constraint_hasMaxSet (c))
859 temp = cstring_makeLiteral ("Possible out-of-bounds store:\n");
863 temp = cstring_makeLiteral ("Possible out-of-bounds read:\n");
866 genExpr = exprNode_unparse (c->generatingExpr);
868 if (context_getFlag (FLG_CONSTRAINTLOCATION))
871 temp2 = message ("%s\n", genExpr);
872 temp = cstring_concatFree (temp, temp2);
875 st = cstring_concatFree (temp,st);
880 /*@only@*/ cstring constraint_print (constraint c) /*@*/
882 cstring st = cstring_undefined;
883 cstring type = cstring_undefined;
887 if (context_getFlag (FLG_PARENCONSTRAINT))
889 type = cstring_makeLiteral ("ensures: ");
893 type = cstring_makeLiteral ("ensures");
898 if (context_getFlag (FLG_PARENCONSTRAINT))
900 type = cstring_makeLiteral ("requires: ");
904 type = cstring_makeLiteral ("requires");
908 if (context_getFlag (FLG_PARENCONSTRAINT))
910 st = message ("%q: %q %q %q",
912 constraintExpr_print (c->lexpr),
913 arithType_print (c->ar),
914 constraintExpr_print (c->expr)
919 st = message ("%q %q %q %q",
921 constraintExpr_print (c->lexpr),
922 arithType_print (c->ar),
923 constraintExpr_print (c->expr)
929 cstring constraint_printOr (constraint c) /*@*/
934 ret = cstring_undefined;
937 ret = cstring_concatFree (ret, constraint_print (temp));
941 while ( constraint_isDefined (temp))
943 ret = cstring_concatFree (ret, cstring_makeLiteral (" OR "));
944 ret = cstring_concatFree (ret, constraint_print (temp));
952 /*@only@*/ constraint constraint_doSRefFixBaseParam (/*@returned@*/ /*@only@*/ constraint precondition,
953 exprNodeList arglist)
955 precondition->lexpr = constraintExpr_doSRefFixBaseParam (precondition->lexpr,
957 precondition->expr = constraintExpr_doSRefFixBaseParam (precondition->expr,
964 constraint constraint_doFixResult (constraint postcondition, /*@dependent@*/ exprNode fcnCall)
966 postcondition = constraint_copy (postcondition);
967 postcondition->lexpr = constraintExpr_doFixResult (postcondition->lexpr, fcnCall);
968 postcondition->expr = constraintExpr_doFixResult (postcondition->expr, fcnCall);
970 return postcondition;
972 /*Commenting out temporally
974 / *@only@* /constraint constraint_doSRefFixInvarConstraint(constraint invar, sRef s, ctype ct )
977 invar = constraint_copy (invar);
978 invar->lexpr = constraintExpr_doSRefFixInvarConstraint (invar->lexpr, s, ct);
979 invar->expr = constraintExpr_doSRefFixInvarConstraint (invar->expr, s, ct);
985 /*@only@*/ constraint constraint_doSRefFixConstraintParam (constraint precondition,
986 exprNodeList arglist)
989 precondition = constraint_copy (precondition);
990 precondition->lexpr = constraintExpr_doSRefFixConstraintParam (precondition->lexpr, arglist);
991 precondition->expr = constraintExpr_doSRefFixConstraintParam (precondition->expr, arglist);
993 precondition->fcnPre = FALSE;
994 return constraint_simplify(precondition);
997 constraint constraint_preserveOrig (/*@returned@*/ constraint c) /*@modifies c @*/
1000 DPRINTF ((message ("Doing constraint_preserverOrig for %q ", constraint_printDetailed (c))));
1002 if (c->orig == constraint_undefined)
1003 c->orig = constraint_copy (c);
1005 else if (c->orig->fcnPre)
1011 /* avoid infinite loop */
1013 c->orig = constraint_copy (c);
1014 if (c->orig->orig == NULL)
1016 c->orig->orig = temp;
1021 llcontbug ((message ("Expected c->orig->orig to be null")));
1022 constraint_free (c->orig->orig);
1023 c->orig->orig = temp;
1029 DPRINTF ((message ("Not changing constraint")));
1032 DPRINTF ((message ("After Doing constraint_preserverOrig for %q ", constraint_printDetailed (c))));
1041 constraint constraint_togglePost (/*@returned@*/ constraint c)
1047 constraint constraint_togglePostOrig (/*@returned@*/ constraint c)
1049 if (c->orig != NULL)
1050 c->orig = constraint_togglePost (c->orig);
1054 bool constraint_hasOrig ( /*@observer@*/ /*@temp@*/ constraint c)
1056 if (c->orig == NULL)
1063 constraint constraint_undump (FILE *f)
1070 constraintExpr lexpr;
1071 constraintExpr expr;
1078 os = mstring_create (MAX_DUMP_LINE_LENGTH);
1080 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1082 /*@i33*/ /*this should probably be wrappered...*/
1084 fcnPre = (bool) reader_getInt (&s);
1086 post = (bool) reader_getInt (&s);
1088 ar = (arithType) reader_getInt (&s);
1090 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1092 reader_checkChar (&s, 'l');
1094 lexpr = constraintExpr_undump (f);
1096 s = fgets (os, MAX_DUMP_LINE_LENGTH, f);
1098 reader_checkChar (&s, 'r');
1099 expr = constraintExpr_undump (f);
1101 c = constraint_makeNew ();
1111 c = constraint_preserveOrig (c);
1116 void constraint_dump (/*@observer@*/ constraint c, FILE *f)
1122 constraintExpr lexpr;
1123 constraintExpr expr;
1132 fprintf (f, "%d@%d@%d\n", (int) fcnPre, (int) post, (int) ar);
1134 constraintExpr_dump (lexpr, f);
1136 constraintExpr_dump (expr, f);
1140 int constraint_compare (/*@observer@*/ /*@temp@*/ const constraint * c1, /*@observer@*/ /*@temp@*/ const constraint * c2) /*@*/
1146 llassert (constraint_isDefined (*c1));
1147 llassert (constraint_isDefined (*c2));
1149 if (constraint_isUndefined (*c1))
1151 if (constraint_isUndefined (*c2))
1157 if (constraint_isUndefined (*c2))
1162 loc1 = constraint_getFileloc (*c1);
1163 loc2 = constraint_getFileloc (*c2);
1165 ret = fileloc_compare (loc1, loc2);
1167 fileloc_free (loc1);
1168 fileloc_free (loc2);
1174 bool constraint_isPost (/*@observer@*/ /*@temp@*/ constraint c)
1176 llassert (constraint_isDefined (c));
1178 if (constraint_isUndefined (c))
1185 static int constraint_getDepth (/*@observer@*/ /*@temp@*/ constraint c)
1189 l = constraintExpr_getDepth (c->lexpr);
1190 r = constraintExpr_getDepth (c->expr);
1194 DPRINTF (( message ("constraint depth returning %d for %s", l, constraint_print (c))));
1199 DPRINTF (( message ("constraint depth returning %d for %s", r, constraint_print (c))));
1205 bool constraint_tooDeep (/*@observer@*/ /*@temp@*/ constraint c)
1209 temp = constraint_getDepth (c);