7 # include <ctype.h> /* for isdigit */
8 # include "lclintMacros.nf"
10 # include "cgrammar.h"
11 # include "cgrammar_tokens.h"
13 # include "exprChecks.h"
14 # include "exprNodeSList.h"
18 /*@access exprNode @*/
21 static /*@only@*/ cstring constraint_printDetailedPostCondition (/*@observer@*/ /*@temp@*/ constraint p_c);
24 static /*@notnull@*/ /*@special@*/ constraint constraint_makeNew (void)
25 /*@post:isnull result->or, result->orig, result->generatingExpr, result->fcnPre @*/
26 /*@defines result->or, result->generatingExpr, result->orig, result->fcnPre @*/;
28 /* constraint makeConstraintParse (sRef x, lltok relOp, exprNode cconstant) */
34 /* ret = constraint_makeNew(); */
35 /* llassert (sRef_isValid(x) ); */
36 /* if (!sRef_isValid(x)) */
40 /* ret->lexpr = constraintExpr_makeTermsRef (x); */
41 /* #warning fix abstraction */
43 /* if (relOp.tok == GE_OP) */
45 /* else if (relOp.tok == LE_OP) */
47 /* else if (relOp.tok == EQ_OP) */
50 /* llfatalbug(message ("Unsupported relational operator") ); */
53 /* t = cstring_toCharsSafe (exprNode_unparse(cconstant)); */
55 /* ret->expr = constraintExpr_makeIntLiteral (c); */
57 /* ret->post = TRUE; */
58 /* // ret->orig = ret; */
59 /* DPRINTF(("GENERATED CONSTRAINT:")); */
60 /* DPRINTF( (message ("%s", constraint_print(ret) ) ) ); */
66 advanceField (char **s)
68 reader_checkChar (s, '@');
72 static constraint makeConstraintParse2 (constraintExpr l, lltok relOp, exprNode cconstant)
77 ret = constraint_makeNew ();
78 llassert (constraintExpr_isDefined(l) );
80 ret->lexpr = constraintExpr_copy (l);
83 if (relOp.tok == GE_OP)
85 else if (relOp.tok == LE_OP)
87 else if (relOp.tok == EQ_OP)
90 llfatalbug(message("Unsupported relational operator") );
93 t = cstring_toCharsSafe (exprNode_unparse(cconstant));
95 ret->expr = constraintExpr_makeIntLiteral (c);
99 DPRINTF(("GENERATED CONSTRAINT:"));
100 DPRINTF( (message ("%s", constraint_print(ret) ) ) );
105 bool constraint_same (constraint c1, constraint c2)
107 llassert (c1 != NULL);
108 llassert (c2 != NULL);
110 if (c1->ar != c2->ar)
115 if (!constraintExpr_similar (c1->lexpr, c2->lexpr) )
120 if (!constraintExpr_similar (c1->expr, c2->expr) )
128 constraint makeConstraintParse3 (constraintExpr l, lltok relOp, constraintExpr r)
131 ret = constraint_makeNew();
132 llassert (constraintExpr_isDefined(l) );
134 ret->lexpr = constraintExpr_copy (l);
136 if (relOp.tok == GE_OP)
138 else if (relOp.tok == LE_OP)
140 else if (relOp.tok == EQ_OP)
143 llfatalbug( message("Unsupported relational operator") );
145 ret->expr = constraintExpr_copy (r);
149 ret->orig = constraint_copy(ret);
151 ret = constraint_simplify (ret);
154 DPRINTF(("GENERATED CONSTRAINT:"));
155 DPRINTF( (message ("%s", constraint_print(ret) ) ) );
159 constraint constraint_copy (/*@temp@*/ /*@observer@*/ constraint c)
163 llassert (constraint_isDefined(c) );
164 // DPRINTF((message("Copying constraint %q", constraint_print) ));
166 ret = constraint_makeNew();
167 ret->lexpr = constraintExpr_copy (c->lexpr);
169 ret->expr = constraintExpr_copy (c->expr);
172 ret->generatingExpr = c->generatingExpr;
177 ret->orig = constraint_copy (c->orig);
182 ret->or = constraint_copy (c->or);
186 ret->fcnPre = c->fcnPre;
191 /*like copy expect it doesn't allocate memory for the constraint*/
193 void constraint_overWrite (constraint c1, constraint c2)
195 llassert (constraint_isDefined(c1) );
199 DPRINTF((message("OverWriteing constraint %q with %q", constraint_print(c1),
200 constraint_print(c2) ) ));
202 constraintExpr_free(c1->lexpr);
203 constraintExpr_free(c1->expr);
205 c1->lexpr = constraintExpr_copy (c2->lexpr);
207 c1->expr = constraintExpr_copy (c2->expr);
210 if (c1->orig != NULL)
211 constraint_free (c1->orig);
213 if (c2->orig != NULL)
214 c1->orig = constraint_copy (c2->orig);
218 /*@i33 make sure that the or is freed correctly*/
220 constraint_free (c1->or);
223 c1->or = constraint_copy (c2->or);
227 c1->fcnPre = c2->fcnPre;
230 c1->generatingExpr = c2->generatingExpr;
236 static /*@notnull@*/ /*@special@*/ constraint constraint_makeNew (void)
237 /*@post:isnull result->or, result->orig, result->generatingExpr, result->fcnPre @*/
238 /*@defines result->or, result->generatingExpr, result->orig, result->fcnPre @*/
241 ret = dmalloc(sizeof (*ret) );
248 ret->generatingExpr = NULL;
253 constraint constraint_addGeneratingExpr (/*@returned@*/ constraint c, /*@exposed@*/ exprNode e)
256 if (c->generatingExpr == NULL)
258 c->generatingExpr = e;
259 DPRINTF ((message ("setting generatingExpr for %s to %s", constraint_print(c), exprNode_unparse(e) ) ));
263 DPRINTF ((message ("Not setting generatingExpr for %s to %s", constraint_print(c), exprNode_unparse(e) ) ));
268 constraint constraint_origAddGeneratingExpr (/*@returned@*/ constraint c, exprNode e)
271 if (c->orig != constraint_undefined)
273 c->orig = constraint_addGeneratingExpr(c->orig, e);
277 DPRINTF ((message ("constraint_origAddGeneratingExpr: Not setting generatingExpr for %s to %s", constraint_print(c), exprNode_unparse(e) ) ));
282 constraint constraint_setFcnPre (/*@returned@*/ constraint c )
285 if (c->orig != constraint_undefined)
287 c->orig->fcnPre = TRUE;
292 // DPRINTF(( message("Warning Setting fcnPre directly") ));
300 fileloc constraint_getFileloc (constraint c)
302 if (exprNode_isDefined(c->generatingExpr) )
303 return (fileloc_copy (exprNode_getfileloc (c->generatingExpr) ) );
305 return (constraintExpr_getFileloc (c->lexpr) );
310 static bool checkForMaxSet (constraint c)
312 if (constraintExpr_hasMaxSet(c->lexpr) || constraintExpr_hasMaxSet(c->expr) )
318 bool constraint_hasMaxSet(constraint c)
320 if (checkForMaxSet(c) )
325 if (checkForMaxSet(c->orig) )
332 constraint constraint_makeReadSafeExprNode ( exprNode po, exprNode ind)
334 constraint ret = constraint_makeNew();
335 // constraintTerm term;
338 ret->lexpr = constraintExpr_makeMaxReadExpr(po);
340 ret->expr = constraintExpr_makeValueExpr (ind);
345 constraint constraint_makeWriteSafeInt ( exprNode po, int ind)
347 constraint ret = constraint_makeNew();
350 ret->lexpr =constraintExpr_makeMaxSetExpr(po);
352 ret->expr = constraintExpr_makeIntLiteral (ind);
356 constraint constraint_makeSRefSetBufferSize (sRef s, long int size)
358 constraint ret = constraint_makeNew();
359 ret->lexpr = constraintExpr_makeSRefMaxset (s);
361 ret->expr = constraintExpr_makeIntLiteral ((int)size);
366 constraint constraint_makeSRefWriteSafeInt (sRef s, int ind)
368 constraint ret = constraint_makeNew();
371 ret->lexpr = constraintExpr_makeSRefMaxset ( s );
373 ret->expr = constraintExpr_makeIntLiteral (ind);
378 /* drl added 01/12/2000
380 makes the constraint: Ensures index <= MaxRead(buffer) */
382 constraint constraint_makeEnsureLteMaxRead(exprNode index, exprNode buffer)
384 constraint ret = constraint_makeNew();
386 ret->lexpr = constraintExpr_makeValueExpr (index);
388 ret->expr = constraintExpr_makeMaxReadExpr(buffer);
393 constraint constraint_makeWriteSafeExprNode (exprNode po, exprNode ind)
395 constraint ret = constraint_makeNew();
398 ret->lexpr =constraintExpr_makeMaxSetExpr(po);
400 ret->expr = constraintExpr_makeValueExpr (ind);
405 constraint constraint_makeReadSafeInt ( exprNode t1, int index)
407 constraint ret = constraint_makeNew();
409 ret->lexpr = constraintExpr_makeMaxReadExpr(t1);
411 ret->expr = constraintExpr_makeIntLiteral (index);
416 constraint constraint_makeSRefReadSafeInt (sRef s, int ind)
418 constraint ret = constraint_makeNew();
421 ret->lexpr = constraintExpr_makeSRefMaxRead (s );
423 ret->expr = constraintExpr_makeIntLiteral (ind);
428 constraint constraint_makeEnsureMaxReadAtLeast (exprNode t1, exprNode t2, fileloc sequencePoint)
432 ret = constraint_makeReadSafeExprNode(t1, t2);
434 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
438 // fileloc_incColumn (ret->lexpr->term->loc);
442 static constraint constraint_makeEnsuresOpConstraintExpr (/*@only@*/ constraintExpr c1, /*@only@*/ constraintExpr c2, fileloc sequencePoint, arithType ar)
447 llassert(constraintExpr_isDefined(c1) && constraintExpr_isDefined(c2) );
448 // llassert(sequencePoint);
450 ret = constraint_makeNew();
456 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
460 static constraint constraint_makeEnsuresOp (/*@dependent@*/ exprNode e1, /*@dependent@*/ exprNode e2, fileloc sequencePoint, arithType ar)
462 constraintExpr c1, c2;
466 if (! (exprNode_isDefined(e1) && exprNode_isDefined(e2) ) )
468 llcontbug((message("null exprNode, Exprnodes are %s and %s",
469 exprNode_unparse(e1), exprNode_unparse(e2) )
473 // llassert (sequencePoint);
476 c1 = constraintExpr_makeValueExpr (e);
479 c2 = constraintExpr_makeValueExpr (e);
481 ret = constraint_makeEnsuresOpConstraintExpr (c1, c2, sequencePoint, ar);
487 /* make constraint ensures e1 == e2 */
489 constraint constraint_makeEnsureEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
491 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, EQ) );
494 /*make constraint ensures e1 < e2 */
495 constraint constraint_makeEnsureLessThan (exprNode e1, exprNode e2, fileloc sequencePoint)
497 constraintExpr t1, t2;
499 t1 = constraintExpr_makeValueExpr (e1);
500 t2 = constraintExpr_makeValueExpr (e2);
502 /*change this to e1 <= (e2 -1) */
504 t2 = constraintExpr_makeDecConstraintExpr (t2);
506 return ( constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, LTE) );
509 constraint constraint_makeEnsureLessThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
511 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, LTE) );
514 constraint constraint_makeEnsureGreaterThan (exprNode e1, exprNode e2, fileloc sequencePoint)
516 constraintExpr t1, t2;
518 t1 = constraintExpr_makeValueExpr (e1);
519 t2 = constraintExpr_makeValueExpr (e2);
522 /* change this to e1 >= (e2 + 1) */
523 t2 = constraintExpr_makeIncConstraintExpr (t2);
526 return ( constraint_makeEnsuresOpConstraintExpr (t1, t2, sequencePoint, GTE) );
529 constraint constraint_makeEnsureGreaterThanEqual (exprNode e1, exprNode e2, fileloc sequencePoint)
531 return ( constraint_makeEnsuresOp (e1, e2, sequencePoint, GTE) );
535 exprNode exprNode_copyConstraints (/*@returned@*/ exprNode dst, exprNode src)
537 constraintList_free(dst->ensuresConstraints);
538 constraintList_free(dst->requiresConstraints);
539 constraintList_free(dst->trueEnsuresConstraints);
540 constraintList_free(dst->falseEnsuresConstraints);
542 dst->ensuresConstraints = constraintList_copy (src->ensuresConstraints );
543 dst->requiresConstraints = constraintList_copy (src->requiresConstraints );
544 dst->trueEnsuresConstraints = constraintList_copy (src->trueEnsuresConstraints );
545 dst->falseEnsuresConstraints = constraintList_copy (src->falseEnsuresConstraints );
549 /* Makes the constraint e = e + f */
550 constraint constraint_makeAddAssign (exprNode e, exprNode f, fileloc sequencePoint)
552 constraintExpr x1, x2, y;
555 ret = constraint_makeNew();
557 x1 = constraintExpr_makeValueExpr (e);
558 x2 = constraintExpr_copy(x1);
559 y = constraintExpr_makeValueExpr (f);
564 ret->expr = constraintExpr_makeAddExpr (x2, y);
566 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
572 /* Makes the constraint e = e - f */
573 constraint constraint_makeSubtractAssign (exprNode e, exprNode f, fileloc sequencePoint)
575 constraintExpr x1, x2, y;
578 ret = constraint_makeNew();
580 x1 = constraintExpr_makeValueExpr (e);
581 x2 = constraintExpr_copy(x1);
582 y = constraintExpr_makeValueExpr (f);
587 ret->expr = constraintExpr_makeSubtractExpr (x2, y);
589 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
594 constraint constraint_makeMaxSetSideEffectPostDecrement (exprNode e, fileloc sequencePoint)
596 constraint ret = constraint_makeNew();
597 //constraintTerm term;
599 // e = exprNode_fakeCopy(e);
600 ret->lexpr = constraintExpr_makeValueExpr (e);
603 ret->expr = constraintExpr_makeValueExpr (e);
604 ret->expr = constraintExpr_makeDecConstraintExpr (ret->expr);
606 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
607 // fileloc_incColumn ( ret->lexpr->term->loc);
608 // fileloc_incColumn ( ret->lexpr->term->loc);
611 constraint constraint_makeMaxSetSideEffectPostIncrement (exprNode e, fileloc sequencePoint)
613 constraint ret = constraint_makeNew();
614 //constraintTerm term;
616 // e = exprNode_fakeCopy(e);
617 ret->lexpr = constraintExpr_makeValueExpr (e);
620 ret->expr = constraintExpr_makeValueExpr (e);
621 ret->expr = constraintExpr_makeIncConstraintExpr (ret->expr);
623 ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);
624 // fileloc_incColumn ( ret->lexpr->term->loc);
625 // fileloc_incColumn ( ret->lexpr->term->loc);
630 void constraint_free (/*@only@*/ constraint c)
632 llassert(constraint_isDefined (c) );
635 if (constraint_isDefined(c->orig) )
636 constraint_free (c->orig);
637 if ( constraint_isDefined(c->or) )
638 constraint_free (c->or);
641 constraintExpr_free(c->lexpr);
642 constraintExpr_free(c->expr);
654 // constraint constraint_makeMaxReadSideEffectPostIncrement (exprNode e, fileloc sequencePoint)
656 // constraint ret = constraint_makeNew();
657 // //constraintTerm term;
659 // e = exprNode_fakeCopy(e);
660 // ret->lexpr = constraintExpr_makeMaxReadExpr(e);
663 // ret->expr = constraintExpr_makeIncConstraintExpr (e);
664 // ret->lexpr = constraintExpr_setFileLoc (ret->lexpr, sequencePoint);
669 cstring arithType_print (arithType ar) /*@*/
671 cstring st = cstring_undefined;
675 st = cstring_makeLiteral ("<");
678 st = cstring_makeLiteral ("<=");
681 st = cstring_makeLiteral (">");
684 st = cstring_makeLiteral (">=");
687 st = cstring_makeLiteral ("==");
690 st = cstring_makeLiteral ("NONNEGATIVE");
693 st = cstring_makeLiteral ("POSITIVE");
702 void constraint_printErrorPostCondition (constraint c, fileloc loc)
705 fileloc errorLoc, temp;
707 string = constraint_printDetailedPostCondition (c);
713 temp = constraint_getFileloc(c);
715 if (fileloc_isDefined(temp) )
718 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
723 voptgenerror ( FLG_CHECKPOST, string, errorLoc);
727 /*drl added 8-11-001*/
728 cstring constraint_printLocation (/*@observer@*/ /*@temp@*/ constraint c) /*@*/
733 string = constraint_print(c);
735 errorLoc = constraint_getFileloc(c);
737 ret = message ("constraint: %q @ %q", string, fileloc_unparse(errorLoc) );
739 fileloc_free(errorLoc);
746 void constraint_printError (constraint c, fileloc loc)
749 fileloc errorLoc, temp;
751 string = constraint_printDetailed (c);
755 temp = constraint_getFileloc(c);
757 if (fileloc_isDefined(temp) )
764 DPRINTF (("constraint %s had undefined fileloc %s", constraint_print(c), fileloc_unparse(temp)));
766 errorLoc = fileloc_copy(errorLoc);
771 voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
775 if (constraint_hasMaxSet (c) )
776 voptgenerror (FLG_ARRAYBOUNDS, string, errorLoc);
778 voptgenerror (FLG_ARRAYBOUNDSREAD, string, errorLoc);
781 fileloc_free(errorLoc);
786 static cstring constraint_printDeep (constraint c)
789 cstring st = cstring_undefined;
791 st = constraint_print(c);
794 if (c->orig != constraint_undefined)
796 st = cstring_appendChar(st, '\n');
797 genExpr = exprNode_unparse(c->orig->generatingExpr);
801 st = cstring_concatFree(st, (message(" derived from %s precondition: %q", genExpr, constraint_printDeep(c->orig) )
804 st = cstring_concatFree(st,(message(" needed to satisfy precondition:\n%q",
805 constraint_printDeep(c->orig) )
811 st = cstring_concatFree(st,(message("derived from: %q",
812 constraint_printDeep(c->orig) )
822 static /*@only@*/ cstring constraint_printDetailedPostCondition (/*@observer@*/ /*@temp@*/ constraint c)
824 cstring st = cstring_undefined;
827 st = message ("Unsatisfied ensures constraint condition:\nLCLint is unable to verify the constraint %q", constraint_printDeep (c) );
829 genExpr = exprNode_unparse (c->generatingExpr);
831 if (context_getFlag (FLG_CONSTRAINTLOCATION) )
834 // llassert (c->generatingExpr);
835 temp = message ("\nOriginal Generating expression %q: %s\n", fileloc_unparse( exprNode_getfileloc (c->generatingExpr) ),
837 st = cstring_concatFree (st, temp);
839 if (constraint_hasMaxSet(c) )
841 temp = message ("Has MaxSet\n");
842 st = cstring_concatFree (st, temp);
848 cstring constraint_printDetailed (constraint c)
850 cstring st = cstring_undefined;
851 cstring temp = cstring_undefined;
856 st = message ("Unable to resolve constraint:\n%q", constraint_printDeep (c) );
860 st = message ("Block Post condition:\nThis function block has the post condition %q", constraint_printDeep (c) );
863 if (constraint_hasMaxSet(c) )
865 temp = cstring_makeLiteral("Possible out-of-bounds store:\n");
869 temp = cstring_makeLiteral("Possible out-of-bounds read:\n");
872 genExpr = exprNode_unparse (c->generatingExpr);
874 if (context_getFlag (FLG_CONSTRAINTLOCATION) )
877 temp2 = message ("%s\n", genExpr );
878 temp = cstring_concatFree (temp, temp2);
881 st = cstring_concatFree(temp,st);
886 /*@only@*/ cstring constraint_print (constraint c) /*@*/
888 cstring st = cstring_undefined;
889 cstring type = cstring_undefined;
893 if (context_getFlag (FLG_PARENCONSTRAINT) )
895 type = cstring_makeLiteral ("ensures: ");
899 type = cstring_makeLiteral ("ensures");
904 if (context_getFlag (FLG_PARENCONSTRAINT) )
906 type = cstring_makeLiteral ("requires: ");
910 type = cstring_makeLiteral ("requires");
914 if (context_getFlag (FLG_PARENCONSTRAINT) )
916 st = message ("%q: %q %q %q",
918 constraintExpr_print (c->lexpr),
919 arithType_print(c->ar),
920 constraintExpr_print(c->expr)
925 st = message ("%q %q %q %q",
927 constraintExpr_print (c->lexpr),
928 arithType_print(c->ar),
929 constraintExpr_print(c->expr)
935 cstring constraint_printOr (constraint c) /*@*/
940 ret = cstring_undefined;
943 ret = cstring_concatFree (ret, constraint_print(temp) );
947 while ( constraint_isDefined(temp) )
949 ret = cstring_concatFree (ret, cstring_makeLiteral (" OR ") );
950 ret = cstring_concatFree (ret, constraint_print(temp) );
958 /*@only@*/ constraint constraint_doSRefFixBaseParam (/*@returned@*/ /*@only@*/ constraint precondition,
959 exprNodeList arglist)
961 precondition->lexpr = constraintExpr_doSRefFixBaseParam (precondition->lexpr,
963 precondition->expr = constraintExpr_doSRefFixBaseParam (precondition->expr,
970 constraint constraint_doFixResult (constraint postcondition, /*@dependent@*/ exprNode fcnCall)
972 postcondition = constraint_copy (postcondition);
973 postcondition->lexpr = constraintExpr_doFixResult (postcondition->lexpr, fcnCall);
974 postcondition->expr = constraintExpr_doFixResult (postcondition->expr, fcnCall);
976 return postcondition;
979 /*@only@*/ constraint constraint_doSRefFixConstraintParam (constraint precondition,
980 exprNodeList arglist)
983 precondition = constraint_copy (precondition);
984 precondition->lexpr = constraintExpr_doSRefFixConstraintParam (precondition->lexpr, arglist);
985 precondition->expr = constraintExpr_doSRefFixConstraintParam (precondition->expr, arglist);
987 precondition->fcnPre = FALSE;
991 // bool constraint_hasTerm (constraint c, constraintTerm term)
993 // DPRINTF((message ("Constraint %s", constraint_print (c) ) ) );
995 // if (constraintExpr_includesTerm (c->lexpr, term) )
998 // if (constraintExpr_includesTerm (c->expr, term) )
1004 constraint constraint_preserveOrig (/*@returned@*/ constraint c) /*@modifies c @*/
1007 DPRINTF( (message("Doing constraint_preserverOrig for %q ", constraint_printDetailed(c) ) ));
1009 if (c->orig == constraint_undefined)
1010 c->orig = constraint_copy (c);
1012 else if (c->orig->fcnPre)
1018 /* avoid infinite loop */
1020 c->orig = constraint_copy (c);
1021 if (c->orig->orig == NULL)
1023 c->orig->orig = temp;
1028 llcontbug((message("Expected c->orig->orig to be null" ) ));
1029 constraint_free(c->orig->orig);
1030 c->orig->orig = temp;
1036 DPRINTF( (message("Not changing constraint") ));
1039 DPRINTF( (message("After Doing constraint_preserverOrig for %q ", constraint_printDetailed(c) ) ));
1048 constraint constraint_togglePost (/*@returned@*/ constraint c)
1054 constraint constraint_togglePostOrig (/*@returned@*/ constraint c)
1056 if (c->orig != NULL)
1057 c->orig = constraint_togglePost(c->orig);
1061 bool constraint_hasOrig( /*@observer@*/ /*@temp@*/ constraint c)
1063 if (c->orig == NULL)
1070 constraint constraint_undump (FILE *f)
1077 constraintExpr lexpr;
1078 constraintExpr expr;
1085 s = mstring_create (MAX_DUMP_LINE_LENGTH);
1089 s = fgets(os, MAX_DUMP_LINE_LENGTH, f);
1091 /*@i33*/ /*this should probably be wrappered...*/
1093 fcnPre = (bool) reader_getInt (&s);
1095 post = (bool) reader_getInt (&s);
1097 ar = (arithType) reader_getInt (&s);
1099 s = fgets(os, MAX_DUMP_LINE_LENGTH, f);
1101 reader_checkChar (&s, 'l');
1103 lexpr = constraintExpr_undump (f);
1105 s = fgets(os, MAX_DUMP_LINE_LENGTH, f);
1107 reader_checkChar (&s, 'r');
1108 expr = constraintExpr_undump (f);
1110 c = constraint_makeNew();
1120 c = constraint_preserveOrig(c);
1125 void constraint_dump (/*@observer@*/ constraint c, FILE *f)
1131 constraintExpr lexpr;
1132 constraintExpr expr;
1141 fprintf(f, "%d@%d@%d\n", (int) fcnPre, (int) post, (int) ar);
1143 constraintExpr_dump (lexpr, f);
1145 constraintExpr_dump (expr, f);
1149 int constraint_compare (/*@observer@*/ /*@temp@*/ const constraint * c1, /*@observer@*/ /*@temp@*/ const constraint * c2) /*@*/
1155 llassert(constraint_isDefined(*c1) );
1156 llassert(constraint_isDefined(*c2) );
1158 if (constraint_isUndefined(*c1) )
1160 if (constraint_isUndefined(*c2) )
1166 if (constraint_isUndefined(*c2) )
1171 loc1 = constraint_getFileloc(*c1);
1172 loc2 = constraint_getFileloc(*c2);
1174 ret = fileloc_compare(loc1, loc2);
1183 bool constraint_isPost (/*@observer@*/ /*@temp@*/ constraint c)
1185 llassert(constraint_isDefined(c) );
1187 if (constraint_isUndefined(c) )
1194 static int constraint_getDepth(/*@observer@*/ /*@temp@*/ constraint c)
1198 l = constraintExpr_getDepth(c->lexpr);
1199 r = constraintExpr_getDepth(c->expr);
1203 DPRINTF(( message("constraint depth returning %d for %s", l, constraint_print(c) ) ));
1208 DPRINTF(( message("constraint depth returning %d for %s", r, constraint_print(c) ) ));
1214 bool constraint_tooDeep (/*@observer@*/ /*@temp@*/ constraint c)
1218 temp = constraint_getDepth(c);