2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 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 "splintMacros.nf"
33 # include "cgrammar.h"
35 # include "exprChecks.h"
36 # include "exprNodeSList.h"
39 static ctype
constraintExpr_getOrigType (constraintExpr p_e
);
40 static bool constraintExpr_hasTypeChange(constraintExpr p_e
) /*@*/;
42 static /*@only@*/ constraintExpr
constraintExpr_makeBinaryOpConstraintExprIntLiteral (/*@only@*/constraintExpr p_expr
, int p_literal
);
45 /*@only@*/ static constraintExpr
46 doSRefFixInvarConstraintTerm (/*@only@*/ constraintExpr p_e
,
47 sRef p_s
, ctype p_ct
);
49 /*@only@*/ static constraintExpr
50 doSRefFixConstraintParamTerm (/*@only@*/ constraintExpr p_e
, /*@temp@*/ /*@observer@*/ exprNodeList p_arglist
) /*@modifies p_e@*/;
52 static /*@only@*/ constraintExpr
53 doFixResultTerm (/*@only@*/ constraintExpr p_e
, /*@exposed@*/ exprNode p_fcnCall
)
56 static bool constraintExpr_canGetCType (constraintExpr p_e
) /*@*/;
58 static ctype
constraintExpr_getCType (constraintExpr p_e
);
60 static /*@only@*/ constraintExpr
constraintExpr_adjustMaxSetForCast (/*@only@*/ constraintExpr p_e
,
61 ctype p_tfrom
, ctype p_tto
,
64 /*@special@*/ /*@notnull@*/ static constraintExpr
constraintExpr_makeBinaryOp (void)
65 /* @allocates result->data @ @sets result->kind @ */ ;
67 void constraintExpr_free (/*@only@*/ constraintExpr expr
)
69 if (constraintExpr_isDefined(expr
) )
74 constraintExprData_freeUnaryExpr(expr
->data
);
77 constraintExprData_freeBinaryExpr(expr
->data
);
80 constraintExprData_freeTerm(expr
->data
);
91 llcontbug(message("attempted to free null pointer in constraintExpr_free"));
95 bool constraintExpr_isLit (constraintExpr expr
)
97 llassert (expr
!= NULL
);
99 if (expr
->kind
== term
)
101 constraintTerm term
= constraintExprData_termGetTerm (expr
->data
);
102 if (constraintTerm_isIntLiteral (term
) )
111 static bool isZeroBinaryOp (constraintExpr expr
)
115 llassert (expr
!= NULL
); /* evans 2001-07-18 */
117 if (!constraintExpr_isBinaryExpr (expr
) )
123 e2
= constraintExprData_binaryExprGetExpr2(expr
->data
);
125 llassert (e2
!= NULL
); /* evans 2001-07-18 */
127 if (constraintExpr_isBinaryExpr (e2
) )
130 constraintExprBinaryOpKind op
;
132 op
= constraintExprData_binaryExprGetOp (e2
->data
);
134 e1
= constraintExprData_binaryExprGetExpr1(e2
->data
);
136 if (constraintExpr_isLit(e1
) )
138 if (constraintExpr_getValue(e1
) == 0 )
147 /* change expr + (o - expr) to (expr -expr) */
149 /*@only@*/ /*@notnull@*/ static constraintExpr
removeZero (/*@only@*/ /*@returned@*/ constraintExpr expr
)
151 constraintExpr expr1
, expr2
;
155 constraintExprBinaryOpKind op
;
157 constraintExprBinaryOpKind tempOp
;
159 llassert (expr
!= NULL
); /* evans 2001-07-18 */
161 if (!isZeroBinaryOp(expr
) )
165 expr1
= constraintExprData_binaryExprGetExpr1(expr
->data
);
166 expr2
= constraintExprData_binaryExprGetExpr2(expr
->data
);
167 op
= constraintExprData_binaryExprGetOp(expr
->data
);
169 llassert( constraintExpr_isBinaryExpr(expr2
) );
171 temp
= constraintExprData_binaryExprGetExpr2 (expr2
->data
);
172 temp
= constraintExpr_copy (temp
);
174 tempOp
= constraintExprData_binaryExprGetOp (expr2
->data
);
176 if (op
== BINARYOP_PLUS
)
178 else if (op
== BINARYOP_MINUS
)
180 if (tempOp
== BINARYOP_PLUS
)
182 else if (tempOp
== BINARYOP_MINUS
)
190 expr
->data
= constraintExprData_binaryExprSetExpr2(expr
->data
, temp
);
191 expr
->data
= constraintExprData_binaryExprSetOp(expr
->data
, op
);
197 /*@only@*//*@notnull@*/ constraintExpr
constraintExpr_propagateConstants (/*@only@*/ constraintExpr expr
,
198 /*@out@*/ bool * propagate
,
199 /*@out@*/ int *literal
)
201 constraintExpr expr1
;
202 constraintExpr expr2
;
203 bool propagate1
, propagate2
;
204 int literal1
, literal2
;
205 constraintExprBinaryOpKind op
;
217 llassert (expr
!= NULL
);
219 /* we simplify unaryExpr elsewhere */
220 if (expr
->kind
!= binaryexpr
)
223 op
= constraintExprData_binaryExprGetOp (expr
->data
);
225 DPRINTF((message("constraintExpr_propagateConstants: binaryexpr: %s", constraintExpr_unparse(expr
) ) ) );
227 expr
= removeZero(expr
);
229 expr1
= constraintExprData_binaryExprGetExpr1(expr
->data
);
230 expr2
= constraintExprData_binaryExprGetExpr2(expr
->data
);
232 expr1
= constraintExpr_copy(expr1
);
233 expr2
= constraintExpr_copy(expr2
);
235 expr1
= constraintExpr_propagateConstants (expr1
, &propagate1
, &literal1
);
236 expr2
= constraintExpr_propagateConstants (expr2
, &propagate2
, &literal2
);
238 expr1
= removeZero(expr1
);
239 expr2
= removeZero(expr2
);
242 *propagate
= propagate1
|| propagate2
;
244 if (op
== BINARYOP_PLUS
)
245 *literal
= literal1
+ literal2
;
246 else if (op
== BINARYOP_MINUS
)
247 *literal
= literal1
- literal2
;
251 if ( constraintExpr_isLit (expr1
) && constraintExpr_isLit (expr2
) )
254 t1
= constraintExpr_getValue (expr1
);
255 t2
= constraintExpr_getValue (expr2
);
256 llassert(*propagate
== FALSE
);
259 constraintExpr_free (expr
);
260 constraintExpr_free (expr1
);
261 constraintExpr_free (expr2
);
263 if (op
== BINARYOP_PLUS
)
264 return (constraintExpr_makeIntLiteral ((t1
+t2
) ));
265 else if (op
== BINARYOP_MINUS
)
266 return (constraintExpr_makeIntLiteral ((t1
-t2
) ));
272 if (constraintExpr_isLit (expr1
) )
276 *literal
+= constraintExpr_getValue (expr1
);
278 if (op
== BINARYOP_PLUS
)
280 constraintExpr_free(expr1
);
281 constraintExpr_free(expr
);
284 else if (op
== BINARYOP_MINUS
)
289 /* this is an ugly kludge to deal with not
290 having a unary minus operation...*/
292 temp
= constraintExpr_makeIntLiteral (0);
293 temp
= constraintExpr_makeSubtractExpr (temp
, expr2
);
295 constraintExpr_free(expr1
);
296 constraintExpr_free(expr
);
298 llassert (constraintExpr_isDefined(temp
) );
303 BADBRANCH
; /* evans 2001-07-18 */
307 if (constraintExpr_isLit (expr2
) )
311 if ( op
== BINARYOP_PLUS
)
312 *literal
+= constraintExpr_getValue (expr2
);
313 else if (op
== BINARYOP_MINUS
)
314 *literal
-= constraintExpr_getValue (expr2
);
319 constraintExpr_free(expr2
);
320 constraintExpr_free(expr
);
324 DPRINTF((message("constraintExpr_propagateConstants returning: %s", constraintExpr_unparse(expr
) ) ) );
326 expr
->data
= constraintExprData_binaryExprSetExpr1 (expr
->data
, expr1
);
327 expr
->data
= constraintExprData_binaryExprSetExpr2 (expr
->data
, expr2
);
329 expr
= removeZero(expr
);
333 /*@notnull@*/ /*@only@*/ static constraintExpr
constraintExpr_combineConstants (/*@only@*/ constraintExpr expr
) /*@modifies expr@*/
338 DPRINTF ((message ("Before combine %s", constraintExpr_unparse(expr
) ) ) );
339 expr
= constraintExpr_propagateConstants (expr
, &propagate
, &literal
);
348 ret
= constraintExpr_makeBinaryOpConstraintExprIntLiteral (expr
, literal
);
352 DPRINTF ((message ("After combine %s", constraintExpr_unparse(expr
) ) ) );
354 llassert(constraintExpr_isDefined(expr
) );
359 static /*@notnull@*/ constraintExpr
constraintExpr_alloc (void) /*@post:isnull result->data@*/
362 ret
= dmalloc (sizeof (*ret
) );
366 ret
->origType
= ctype_undefined
;
370 /*@only@*/ static constraintExprData
copyExprData (/*@observer@*/ constraintExprData data
, constraintExprKind kind
)
372 constraintExprData ret
;
373 llassert(constraintExprData_isDefined(data
));
378 ret
= constraintExprData_copyBinaryExpr(data
);
381 ret
= constraintExprData_copyUnaryExpr(data
);
384 ret
= constraintExprData_copyTerm(data
);
392 constraintExpr
constraintExpr_copy (constraintExpr expr
)
395 ret
= constraintExpr_alloc ();
398 /*drl 03/02/2003 this shouldn't be used to copy a null
399 expression but handle things cleanly if it is*/
400 llassert (!constraintExpr_isUndefined(expr
) );
402 if (constraintExpr_isUndefined(expr
) )
404 return constraintExpr_undefined
;
407 ret
->kind
= expr
->kind
;
409 ret
->data
= copyExprData (expr
->data
, expr
->kind
);
411 ret
->origType
= expr
->origType
;
416 /*@only@*/ static constraintExpr
oldconstraintExpr_makeTermExprNode ( /*@dependent@*/ exprNode e
)
420 ret
= constraintExpr_alloc();
422 ret
->data
= dmalloc (sizeof *(ret
->data
) );
423 t
= constraintTerm_makeExprNode (e
);
424 ret
->data
= constraintExprData_termSetTerm (ret
->data
, t
);
426 ret
->origType
= ctype_undefined
;
431 /*@access exprNode@*/
432 constraintExpr
constraintExpr_makeExprNode (exprNode e
)
435 constraintExpr ret
, ce1
, ce2
;
440 if (exprNode_isUndefined (e
))
442 return constraintExpr_undefined
;
450 t
= exprData_getSingle (data
);
451 while (exprNode_isInParens (t
) )
453 t
= exprData_getUopNode (t
->edata
);
455 s
= exprNode_getSref (t
);
456 if (sRef_isFixedArray(s
) )
460 size
= (int) sRef_getArraySize(s
);
461 ret
= constraintExpr_makeIntLiteral (size
);
463 else if (exprNode_isStringLiteral (t
))
465 cstring str
= multiVal_forceString (exprNode_getValue(t
));
466 ret
= constraintExpr_makeIntLiteral (size_toLong (cstring_length (str
) + 1));
470 DPRINTF ((message ("could not determine the size of %s", exprNode_unparse (e
) ) ) );
471 ret
= oldconstraintExpr_makeTermExprNode (e
);
476 DPRINTF ((message ("Examining operation %s", exprNode_unparse (e
) ) ) );
477 t1
= exprData_getOpA (data
);
478 t2
= exprData_getOpB (data
);
479 tok
= exprData_getOpTok (data
);
481 if (lltok_isPlus_Op (tok
) || lltok_isMinus_Op (tok
) )
483 ce1
= constraintExpr_makeExprNode (t1
);
484 ce2
= constraintExpr_makeExprNode (t2
);
485 ret
= constraintExpr_parseMakeBinaryOp (ce1
, tok
, ce2
);
489 /* define this block to activate the cheesy heuristic
490 for handling sizeof expressions*/
497 We handle expressions containing sizeof with the rule
498 (sizeof type ) * Expr = Expr
500 This is the total wronge way to do this but...
501 it may be better than nothing
506 else if (lltok_isMult(tok
) )
508 if ((t1
->kind
== XPR_SIZEOF
) || (t1
->kind
== XPR_SIZEOFT
) )
510 ret
= constraintExpr_makeExprNode(t2
);
512 else if ((t2
->kind
== XPR_SIZEOF
) || (t2
->kind
== XPR_SIZEOFT
) )
514 ret
= constraintExpr_makeExprNode(t1
);
518 ret
= oldconstraintExpr_makeTermExprNode (e
);
524 ret
= oldconstraintExpr_makeTermExprNode (e
);
528 t
= exprData_getUopNode (data
);
529 ret
= constraintExpr_makeExprNode (t
);
533 t
= exprData_getUopNode (data
);
534 tok
= exprData_getUopTok (data
);
535 if (lltok_isIncOp (tok
))
538 temp
= constraintExpr_makeExprNode(t
);
539 ret
= constraintExpr_makeIncConstraintExpr(temp
);
541 else if (lltok_isDecOp (tok
))
544 temp
= constraintExpr_makeExprNode(t
);
545 ret
= constraintExpr_makeDecConstraintExpr(temp
);
548 ret
= oldconstraintExpr_makeTermExprNode (e
);
552 t
= exprData_getUopNode (data
);
553 ret
= constraintExpr_makeExprNode (t
);
556 t
= exprData_getCastNode (data
);
557 ret
= constraintExpr_makeExprNode (t
);
560 t
= exprData_getPairA (data
);
561 ret
= constraintExpr_makeExprNode(t
);
564 ret
= oldconstraintExpr_makeTermExprNode (e
);
570 /*@noaccess exprNode@*/
575 /*@only@*/ constraintExpr
constraintExpr_makeTermExprNode (/*@exposed@*/ exprNode e
)
577 return oldconstraintExpr_makeTermExprNode(e
);
580 static constraintExpr
constraintExpr_makeTerm (/*@only@*/ constraintTerm t
)
584 ret
= constraintExpr_alloc();
586 ret
->data
= dmalloc (sizeof *(ret
->data
) );
587 ret
->data
->term
= NULL
;
588 ret
->data
= constraintExprData_termSetTerm (ret
->data
, t
);
590 ret
->origType
= ctype_undefined
;
595 constraintExpr
constraintExpr_makeTermsRef (/*@temp@*/ sRef s
)
599 ret
= constraintExpr_alloc();
601 ret
->data
= dmalloc (sizeof *(ret
->data
) );
602 t
= constraintTerm_makesRef (s
);
603 ret
->data
= constraintExprData_termSetTerm (ret
->data
, t
);
606 ret
->origType
= ctype_undefined
;
611 /*@special@*/ /*@notnull@*/ static constraintExpr
makeUnaryOpGeneric (void) /*@allocates result->data@*/ /*@defines result->kind@*/
614 ret
= constraintExpr_alloc();
615 ret
->kind
= unaryExpr
;
616 ret
->data
= dmalloc (sizeof *(ret
->data
));
617 ret
->data
->unaryOp
.expr
= constraintExpr_undefined
;
621 /*@notnull@*/ /*@only@*/ static constraintExpr
constraintExpr_makeUnaryOpConstraintExpr (/*@only@*/ constraintExpr cexpr
)
624 ret
= makeUnaryOpGeneric();
628 ret
->data
= constraintExprData_unaryExprSetExpr (ret
->data
, cexpr
);
629 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, UNARYOP_UNDEFINED
);
638 /*@only@*/ /*@notnull@*/ static constraintExpr
639 constraintExpr_makeUnaryOp (/*@only@*/ constraintExpr cexpr
, constraintExprUnaryOpKind Op
)
642 ret
= makeUnaryOpGeneric();
644 ret
->data
= constraintExprData_unaryExprSetExpr (ret
->data
, cexpr
);
645 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, Op
);
648 ret
->origType
= ctype_undefined
;
653 /*@only@*/ /*@notnull@*/
654 static constraintExpr
constraintExpr_makeUnaryOpExprNode (/*@exposed@*/ exprNode expr
)
658 sub
= constraintExpr_makeExprNode (expr
);
659 ret
= constraintExpr_makeUnaryOpConstraintExpr(sub
);
664 /*@only@*/ /*@notnull@*/
665 static constraintExpr
constraintExpr_makeMaxSetConstraintExpr (/*@only@*/ constraintExpr c
)
668 ret
= constraintExpr_makeUnaryOp (c
, MAXSET
);
673 /*@only@*/ /*@notnull@*/
674 static constraintExpr
constraintExpr_makeSRefUnaryOp (/*@temp@*/ /*@observer@*/ sRef s
, constraintExprUnaryOpKind op
)
679 t
= constraintExpr_makeTermsRef (s
);
680 ret
= constraintExpr_makeUnaryOpConstraintExpr (t
);
681 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, op
);
687 constraintExpr
constraintExpr_makeSRefMaxRead( sRef s
)
689 return (constraintExpr_makeSRefUnaryOp (s
, MAXREAD
) );
693 constraintExpr
constraintExpr_makeSRefMaxset ( sRef s
)
695 return (constraintExpr_makeSRefUnaryOp (s
, MAXSET
) );
699 constraintExpr
constraintExpr_parseMakeUnaryOp (lltok op
, constraintExpr cexpr
)
702 ret
= constraintExpr_makeUnaryOpConstraintExpr ( cexpr
);
704 switch (lltok_getTok (op
))
707 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, MAXSET
);
710 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, MAXREAD
);
713 llfatalbug (message ("Unhandled operation in constraint: %s", lltok_unparse (op
)));
719 constraintExpr
constraintExpr_makeMaxSetExpr (/*@exposed@*/ exprNode expr
)
722 ret
= constraintExpr_makeExprNode (expr
);
724 ret
= constraintExpr_makeMaxSetConstraintExpr (ret
);
726 llassert (ret
!= NULL
);
731 constraintExpr
constraintExpr_makeMaxReadExpr (exprNode expr
)
734 ret
= constraintExpr_makeUnaryOpExprNode(expr
);
735 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, MAXREAD
);
741 /*@unused@*/ static constraintExpr
constraintExpr_makeMinSetExpr (/*@exposed@*/ exprNode expr
)
744 ret
= constraintExpr_makeUnaryOpExprNode(expr
);
745 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, MINSET
);
750 /*@unused@*/ static constraintExpr
constraintExpr_makeMinReadExpr (/*@exposed@*/ exprNode expr
)
753 ret
= constraintExpr_makeUnaryOpExprNode(expr
);
754 ret
->data
= constraintExprData_unaryExprSetOp (ret
->data
, MINREAD
);
760 constraintExpr
constraintExpr_makeValueExpr (/*@exposed@*/ exprNode expr
)
763 ret
= constraintExpr_makeExprNode (expr
);
767 /*@only@*/ /*@notnull@*/
768 constraintExpr
constraintExpr_makeIntLiteral (long i
)
772 ret
= constraintExpr_alloc();
774 ret
->data
= dmalloc (sizeof *(ret
->data
) );
775 t
= constraintTerm_makeIntLiteral (i
);
776 ret
->data
= constraintExprData_termSetTerm (ret
->data
, t
);
779 ret
->origType
= ctype_undefined
;
785 constraintExpr constraintExpr_makeValueInt (int i)
787 return constraintExpr_makeIntLiteral (i);
791 /*@only@*/ /*@notnull@*/
792 /*@special@*/ static constraintExpr
constraintExpr_makeBinaryOp (void)
793 /*@allocates result->data @*/ /*@sets result->kind @*/
796 ret
= constraintExpr_alloc();
797 ret
->kind
= binaryexpr
;
798 ret
->data
= dmalloc ( sizeof *(ret
->data
) );
800 ret
->data
->binaryOp
.expr1
= constraintExpr_undefined
;
801 ret
->data
->binaryOp
.expr2
= constraintExpr_undefined
;
807 static /*@notnull@*/ /*@only@*/ constraintExpr
constraintExpr_makeBinaryOpConstraintExpr (/*@only@*/constraintExpr expr1
, /*@only@*/ constraintExpr expr2
)
812 ret
= constraintExpr_makeBinaryOp();
813 ret
->data
= constraintExprData_binaryExprSetExpr1 (ret
->data
, expr1
);
814 ret
->data
= constraintExprData_binaryExprSetExpr2 (ret
->data
, expr2
);
815 ret
->data
= constraintExprData_binaryExprSetOp (ret
->data
, BINARYOP_UNDEFINED
);
818 ret
->origType
= ctype_undefined
;
824 constraintExpr
constraintExpr_parseMakeBinaryOp (/*@only@*/ constraintExpr expr1
, lltok op
,/*@only@*/ constraintExpr expr2
)
827 ret
= constraintExpr_makeBinaryOpConstraintExpr (expr1
, expr2
);
829 if (lltok_getTok (op
) == TPLUS
)
831 ret
->data
= constraintExprData_binaryExprSetOp(ret
->data
, BINARYOP_PLUS
);
833 else if (lltok_getTok (op
) == TMINUS
)
835 ret
->data
= constraintExprData_binaryExprSetOp(ret
->data
, BINARYOP_MINUS
);
847 /*@unused@*/ static constraintExpr
constraintExpr_makeBinaryOpExprNode (/*@exposed@*/ exprNode expr1
, /*@exposed@*/ exprNode expr2
)
850 constraintExpr sub1
, sub2
;
851 sub1
= constraintExpr_makeTermExprNode (expr1
);
852 sub2
= constraintExpr_makeTermExprNode (expr2
);
853 ret
= constraintExpr_makeBinaryOpConstraintExpr(sub1
, sub2
);
858 static /*@notnull@*/ /*@only@*/
859 constraintExpr
constraintExpr_makeBinaryOpConstraintExprIntLiteral (/*@only@*/ constraintExpr expr
, int literal
)
862 constraintExpr constExpr
;
864 constExpr
= constraintExpr_makeIntLiteral (literal
);
865 ret
= constraintExpr_makeBinaryOpConstraintExpr (expr
, constExpr
);
866 ret
->data
= constraintExprData_binaryExprSetOp(ret
->data
, BINARYOP_PLUS
);
871 constraintExpr
constraintExpr_makeDecConstraintExpr (/*@only@*/constraintExpr expr
)
876 inc
= constraintExpr_makeIntLiteral (1);
877 ret
= constraintExpr_makeBinaryOpConstraintExpr (expr
, inc
);
878 ret
->data
= constraintExprData_binaryExprSetOp(ret
->data
, BINARYOP_MINUS
);
883 /*@only@*/ constraintExpr
constraintExpr_makeSubtractExpr (/*@only@*/ constraintExpr expr
, /*@only@*/ constraintExpr addent
)
887 DPRINTF ((message ("Making subtract expression") ) );
889 ret
= constraintExpr_makeBinaryOpConstraintExpr (expr
, addent
);
890 ret
->data
= constraintExprData_binaryExprSetOp (ret
->data
, BINARYOP_MINUS
);
895 constraintExpr
constraintExpr_makeAddExpr (/*@only@*/
896 constraintExpr expr
, /*@only@*/
897 constraintExpr addent
)
901 DPRINTF ((message ("Doing addTerm simplification") ) );
903 ret
= constraintExpr_makeBinaryOpConstraintExpr (expr
, addent
);
904 ret
->data
= constraintExprData_binaryExprSetOp (ret
->data
, BINARYOP_PLUS
);
910 constraintExpr
constraintExpr_makeIncConstraintExpr (/*@only@*/ constraintExpr expr
)
915 inc
= constraintExpr_makeIntLiteral (1);
916 ret
= constraintExpr_makeBinaryOpConstraintExpr (expr
, inc
);
917 ret
->data
= constraintExprData_binaryExprSetOp(ret
->data
, BINARYOP_PLUS
);
922 static cstring
constraintExprUnaryOpKind_print (constraintExprUnaryOpKind op
)
927 return message("maxSet");
929 return message("minSet");
931 return message("maxRead");
933 return message("minRead");
936 return message ("<(Unary OP OTHER>");
942 static cstring
constraintExprBinaryOpKind_print (constraintExprBinaryOpKind op
)
954 return message ("<binary OP Unknown>");
958 bool constraintExpr_similar (constraintExpr expr1
, constraintExpr expr2
)
960 constraintExprKind kind
;
962 llassert (expr1
!= NULL
);
963 llassert (expr2
!= NULL
);
964 if (expr1
->kind
!= expr2
->kind
)
972 return constraintTerm_similar (constraintExprData_termGetTerm(expr1
->data
),
973 constraintExprData_termGetTerm(expr2
->data
) );
974 /*@notreached@*/ break;
977 if (constraintExprData_unaryExprGetOp (expr1
->data
) != constraintExprData_unaryExprGetOp (expr2
->data
) )
980 return (constraintExpr_similar (
981 constraintExprData_unaryExprGetExpr (expr1
->data
),
982 constraintExprData_unaryExprGetExpr (expr2
->data
)
986 if (constraintExprData_binaryExprGetOp (expr1
->data
) != constraintExprData_binaryExprGetOp (expr2
->data
) )
989 if (! constraintExpr_similar (constraintExprData_binaryExprGetExpr1 (expr1
->data
),
990 constraintExprData_binaryExprGetExpr1 (expr2
->data
)) )
993 if (! constraintExpr_similar (constraintExprData_binaryExprGetExpr2 (expr1
->data
),
994 constraintExprData_binaryExprGetExpr2 (expr2
->data
)) )
1009 bool constraintExpr_same (constraintExpr expr1
, constraintExpr expr2
)
1011 constraintExprKind kind
;
1013 llassert (expr1
!= NULL
);
1014 llassert (expr2
!= NULL
);
1015 if (expr1
->kind
!= expr2
->kind
)
1023 return constraintTerm_similar (constraintExprData_termGetTerm(expr1
->data
),
1024 constraintExprData_termGetTerm(expr2
->data
) );
1025 /*@notreached@*/ break;
1028 if (constraintExprData_unaryExprGetOp (expr1
->data
) != constraintExprData_unaryExprGetOp (expr2
->data
) )
1031 return (constraintExpr_same (
1032 constraintExprData_unaryExprGetExpr (expr1
->data
),
1033 constraintExprData_unaryExprGetExpr (expr2
->data
)
1038 if (constraintExprData_binaryExprGetOp (expr1
->data
) != constraintExprData_binaryExprGetOp (expr2
->data
) )
1041 if (! constraintExpr_same (constraintExprData_binaryExprGetExpr1 (expr1
->data
),
1042 constraintExprData_binaryExprGetExpr1 (expr2
->data
)) )
1045 if (! constraintExpr_same (constraintExprData_binaryExprGetExpr2 (expr1
->data
),
1046 constraintExprData_binaryExprGetExpr2 (expr2
->data
)) )
1050 /*@notreached@*/ break;
1062 constraintExpr_search (/*@observer@*/ constraintExpr c
,
1063 /*@observer@*/ constraintExpr old
)
1066 constraintExprKind kind
;
1067 constraintExpr temp
;
1069 if (constraintExpr_similar (c
, old
))
1071 DPRINTF (("Found %q", constraintExpr_unparse (old
)));
1075 llassert (constraintExpr_isDefined (c
) && constraintExpr_isDefined(old
) );
1077 if ( !(constraintExpr_isDefined (c
) && constraintExpr_isDefined(old
) ) )
1087 temp
= constraintExprData_unaryExprGetExpr (c
->data
);
1088 ret
= ret
|| constraintExpr_search (temp
, old
);
1092 temp
= constraintExprData_binaryExprGetExpr1 (c
->data
);
1093 ret
= ret
|| constraintExpr_search(temp
, old
);
1095 temp
= constraintExprData_binaryExprGetExpr2 (c
->data
);
1096 ret
= ret
|| constraintExpr_search(temp
, old
);
1106 /*@only@*/ constraintExpr
1107 constraintExpr_searchandreplace (/*@only@*/ /*@unique@*/ constraintExpr c
, /*@temp@*/ constraintExpr old
,
1108 /*@temp@*/ constraintExpr newExpr
)
1110 constraintExprKind kind
;
1111 constraintExpr temp
;
1114 llassert (constraintExpr_isDefined (newExpr
) && (constraintExpr_isDefined (old
) && constraintExpr_isDefined(c
) ) );
1116 if (constraintExpr_similar (c
, old
))
1118 ctype newType
= ctype_unknown
;
1119 ctype cType
= ctype_unknown
;
1121 ret
= constraintExpr_copy (newExpr
);
1122 llassert(constraintExpr_isDefined(ret
) );
1123 /*drl if newExpr != NULL then ret will != NULL*/
1125 DPRINTF (("Replacing %s with %s in %s",
1126 constraintExpr_unparse (old
), constraintExpr_unparse (newExpr
),
1127 constraintExpr_unparse (c
)));
1129 if (constraintExpr_canGetCType (c
) && constraintExpr_canGetCType (newExpr
))
1131 cType
= constraintExpr_getCType(c
);
1132 newType
= constraintExpr_getCType (newExpr
);
1134 if (ctype_match (cType
,newType
))
1136 DPRINTF (("constraintExpr_searchandreplace: replacing "
1137 " %s with type %s with %s with type %s",
1138 constraintExpr_unparse (c
), ctype_unparse(cType
),
1139 constraintExpr_unparse (newExpr
), ctype_unparse(newType
)));
1142 ret
->origType
= cType
;
1143 DPRINTF (("Type: %s", ctype_unparse (constraintExpr_getCType (ret
))));
1147 if (constraintExpr_hasMaxSet (c
))
1149 if (constraintExpr_hasTypeChange (c
))
1151 fileloc loc
= constraintExpr_loc (c
);
1152 DPRINTF (("constraintExpr_searchandreplace: encountered "
1153 "MaxSet with changed type %s ",
1154 constraintExpr_unparse (c
)));
1156 if (c
->kind
== unaryExpr
)
1158 constraintExpr ce
= constraintExprData_unaryExprGetExpr (c
->data
);
1159 DPRINTF (("Its a unary! %s / %s",
1160 ctype_unparse (constraintExpr_getCType (ce
)),
1161 ctype_unparse (constraintExpr_getOrigType (ce
))));
1162 ret
= constraintExpr_adjustMaxSetForCast (ret
, constraintExpr_getCType (ce
),
1163 constraintExpr_getOrigType (ce
),
1168 /* fix this with a conversation */
1169 DPRINTF (("Types: %s / %s", ctype_unparse (newType
), ctype_unparse (cType
)));
1170 ret
= constraintExpr_adjustMaxSetForCast (ret
, constraintExpr_getCType (c
),
1171 constraintExpr_getOrigType(c
),
1177 constraintExpr_free (c
);
1178 DPRINTF (("ret: %s", constraintExpr_unparse (ret
)));
1189 DPRINTF (("Making unary expression!"));
1190 temp
= constraintExprData_unaryExprGetExpr (c
->data
);
1191 temp
= constraintExpr_copy (temp
);
1192 temp
= constraintExpr_searchandreplace (temp
, old
, newExpr
);
1193 c
->data
= constraintExprData_unaryExprSetExpr (c
->data
, temp
);
1196 DPRINTF (("Making binary expression!"));
1197 temp
= constraintExprData_binaryExprGetExpr1 (c
->data
);
1198 temp
= constraintExpr_copy (temp
);
1199 temp
= constraintExpr_searchandreplace (temp
, old
, newExpr
);
1200 c
->data
= constraintExprData_binaryExprSetExpr1 (c
->data
, temp
);
1202 temp
= constraintExprData_binaryExprGetExpr2 (c
->data
);
1203 temp
= constraintExpr_copy (temp
);
1204 temp
= constraintExpr_searchandreplace (temp
, old
, newExpr
);
1205 c
->data
= constraintExprData_binaryExprSetExpr2 (c
->data
, temp
);
1211 DPRINTF (("ret: %s", constraintExpr_unparse (c
)));
1215 /*@notnull@*/ static constraintExpr
constraintExpr_simplifyChildren (/*@returned@*/ /*@notnull@*/ constraintExpr c
)
1217 constraintExprKind kind
;
1218 constraintExpr temp
;
1227 temp
= constraintExprData_unaryExprGetExpr (c
->data
);
1228 temp
= constraintExpr_copy(temp
);
1229 temp
= constraintExpr_simplify (temp
);
1230 c
->data
= constraintExprData_unaryExprSetExpr (c
->data
, temp
);
1233 DPRINTF((message("constraintExpr_simplfiyChildren: simplify binary expression: %s",constraintExpr_unparse(c
) ) ) );
1234 temp
= constraintExprData_binaryExprGetExpr1 (c
->data
);
1235 temp
= constraintExpr_copy(temp
);
1236 temp
= constraintExpr_simplify (temp
);
1238 c
->data
= constraintExprData_binaryExprSetExpr1 (c
->data
, temp
);
1240 temp
= constraintExprData_binaryExprGetExpr2 (c
->data
);
1241 temp
= constraintExpr_copy(temp
);
1242 temp
= constraintExpr_simplify (temp
);
1244 c
->data
= constraintExprData_binaryExprSetExpr2 (c
->data
, temp
);
1254 constraintExpr
constraintExpr_setFileloc (/*@returned@*/ constraintExpr c
, fileloc loc
) /*@modifies c @*/
1257 constraintExpr temp
;
1259 llassert(c
!= NULL
);
1264 t
= constraintExprData_termGetTerm (c
->data
);
1265 t
= constraintTerm_copy(t
);
1266 t
= constraintTerm_setFileloc (t
, loc
);
1267 c
->data
= constraintExprData_termSetTerm (c
->data
, t
);
1271 temp
= constraintExprData_binaryExprGetExpr1 (c
->data
);
1272 temp
= constraintExpr_copy(temp
);
1273 temp
= constraintExpr_setFileloc (temp
, loc
);
1274 c
->data
= constraintExprData_binaryExprSetExpr1 (c
->data
, temp
);
1276 temp
= constraintExprData_binaryExprGetExpr2 (c
->data
);
1277 temp
= constraintExpr_copy(temp
);
1278 temp
= constraintExpr_setFileloc (temp
, loc
);
1279 c
->data
= constraintExprData_binaryExprSetExpr2 (c
->data
, temp
);
1282 temp
= constraintExprData_unaryExprGetExpr (c
->data
);
1283 temp
= constraintExpr_copy(temp
);
1284 temp
= constraintExpr_setFileloc (temp
, loc
);
1285 c
->data
= constraintExprData_unaryExprSetExpr (c
->data
, temp
);
1291 static /*@only@*/ constraintExpr
constraintExpr_simplifybinaryExpr (/*@only@*/ /*@notnull@*/ constraintExpr c
)
1293 constraintExpr e1
, e2
;
1294 constraintExprBinaryOpKind op
;
1296 e1
= constraintExprData_binaryExprGetExpr1 (c
->data
);
1297 e2
= constraintExprData_binaryExprGetExpr2 (c
->data
);
1299 if (constraintExpr_canGetValue (e1
) && constraintExpr_canGetValue(e2
) )
1303 i
= constraintExpr_getValue(e1
) + constraintExpr_getValue (e2
);
1304 constraintExpr_free(c
);
1305 c
= constraintExpr_makeIntLiteral (i
);
1309 op
= constraintExprData_binaryExprGetOp (c
->data
);
1310 if (op
== BINARYOP_MINUS
)
1311 if (constraintExpr_similar(e1
, e2
) )
1313 constraintExpr_free(c
);
1314 c
= constraintExpr_makeIntLiteral (0);
1322 this thing takes the lexpr and expr of a constraint and modifies lexpr
1323 and returns a (possiblly new) value for expr
1325 /* if lexpr is a binary express say x + y, we set lexpr to x and return a value for expr such as expr_old - y */
1327 /* the approach is a little Kludgy but seems to work. I should probably use something cleaner at some point ... */
1330 /*@only@*/ constraintExpr
constraintExpr_solveBinaryExpr (constraintExpr lexpr
, /*@only@*/ constraintExpr expr
)
1332 constraintExpr expr1
, expr2
;
1333 constraintExprBinaryOpKind op
;
1335 llassert(constraintExpr_isDefined (lexpr
) && constraintExpr_isDefined (expr
) );
1337 if (lexpr
->kind
!= binaryexpr
)
1340 expr2
= constraintExprData_binaryExprGetExpr2 (lexpr
->data
);
1341 expr1
= constraintExprData_binaryExprGetExpr1 (lexpr
->data
);
1343 op
= constraintExprData_binaryExprGetOp (lexpr
->data
);
1345 expr1
= constraintExpr_copy(expr1
);
1346 expr2
= constraintExpr_copy(expr2
);
1348 llassert(constraintExpr_isDefined (expr1
) && constraintExpr_isDefined (expr2
) );
1350 /* drl possible problem : warning make sure this works */
1352 lexpr
->kind
= expr1
->kind
;
1353 sfree (lexpr
->data
);
1355 lexpr
->data
= copyExprData (expr1
->data
, expr1
->kind
);
1356 constraintExpr_free(expr1
);
1358 if (op
== BINARYOP_PLUS
)
1359 expr
= constraintExpr_makeSubtractExpr (expr
, expr2
);
1360 else if (op
== BINARYOP_MINUS
)
1361 expr
= constraintExpr_makeAddExpr (expr
, expr2
);
1369 #warning this needs to be checked
1370 expr = constraintExpr_solveBinaryExpr (expr1, expr);
1372 expr = constraintExpr_solveBinaryExpr (expr2, expr);
1377 static /*@only@*/ constraintExpr
constraintExpr_simplifyunaryExpr (/*@only@*/ constraintExpr c
)
1381 llassert(constraintExpr_isDefined (c
) );
1382 llassert (c
->kind
== unaryExpr
);
1384 DPRINTF ((message ("Doing constraintExpr_simplifyunaryExpr:%s", constraintExpr_unparse (c
) ) ) );
1386 if ((constraintExprData_unaryExprGetOp (c
->data
) != MAXSET
) &&
1387 (constraintExprData_unaryExprGetOp (c
->data
) != MAXREAD
) )
1392 exp
= constraintExprData_unaryExprGetExpr (c
->data
);
1393 exp
= constraintExpr_copy(exp
);
1395 llassert(constraintExpr_isDefined (exp
) );
1397 if (exp
->kind
== term
)
1399 constraintTerm cterm
;
1401 cterm
= constraintExprData_termGetTerm (exp
->data
);
1403 if (constraintTerm_isStringLiteral(cterm
) )
1406 val
= constraintTerm_getStringLiteral (cterm
);
1407 if (constraintExprData_unaryExprGetOp (c
->data
) == MAXSET
)
1409 constraintExpr temp
;
1411 temp
= constraintExpr_makeIntLiteral ((int)strlen (cstring_toCharsSafe(val
) ) );
1413 constraintExpr_free(c
);
1414 constraintExpr_free(exp
);
1419 if (constraintExprData_unaryExprGetOp (c
->data
) == MAXREAD
)
1421 constraintExpr temp
;
1423 temp
= constraintExpr_makeIntLiteral ((int)strlen (cstring_toCharsSafe(val
) ) );
1425 constraintExpr_free(c
);
1426 constraintExpr_free(exp
);
1433 /* slight Kludge to handle var [] = { , , };
1434 ** type syntax I don't think this is sound but it should be good
1435 ** enough. The C standard is very confusing about initialization
1439 if (constraintTerm_isInitBlock(cterm
) )
1441 constraintExpr temp
;
1444 len
= constraintTerm_getInitBlockLength(cterm
);
1446 /* -- drl 12/08/2003 : decrementing to fix off by one error */
1450 temp
= constraintExpr_makeIntLiteral (len
);
1452 constraintExpr_free(c
);
1453 DPRINTF(( message("Changed to %q", constraintExpr_print(temp
)
1455 constraintExpr_free(exp
);
1459 constraintExpr_free(exp
);
1463 if (exp
->kind
!= binaryexpr
)
1465 constraintExpr_free(exp
);
1469 if (constraintExprData_binaryExprGetOp (exp
->data
) == BINARYOP_PLUS
)
1472 /* if (constraintExpr_canGetValue (constraintExprData_binaryExprGetExpr2 (exp->data) ) ) */
1475 constraintExpr temp
, temp2
;
1477 DPRINTF ((message ("Doing fancy simplification") ) );
1479 temp
= constraintExprData_binaryExprGetExpr2 (exp
->data
);
1481 temp2
= constraintExprData_binaryExprGetExpr1 (exp
->data
);
1483 temp2
= constraintExpr_copy(temp2
);
1484 c
->data
= constraintExprData_unaryExprSetExpr (c
->data
, temp2
);
1487 temp
= constraintExpr_copy (temp
);
1489 c
= constraintExpr_makeSubtractExpr (c
, temp
);
1491 DPRINTF ((message ("Done fancy simplification:%s", constraintExpr_unparse (c
) ) ) );
1495 DPRINTF ((message ("constraintExpr_simplifyUnaryExpr: Done simplification:%s", constraintExpr_unparse (c
) ) ) );
1497 constraintExpr_free(exp
);
1502 /*@only@*/ constraintExpr
constraintExpr_simplify (/*@only@*/ constraintExpr c
)
1504 constraintExprKind kind
;
1508 DPRINTF ((message ("Doing constraintExpr_simplify:%s", constraintExpr_unparse (c
) ) ) );
1512 llassert ( constraintExpr_isDefined (c
) );
1513 if (constraintExpr_isUndefined (c
) )
1515 return constraintExpr_undefined
;
1518 ret
= constraintExpr_copy(c
);
1519 llassert(constraintExpr_isDefined (ret
) );
1521 constraintExpr_free(c
);
1523 ret
= constraintExpr_simplifyChildren (ret
);
1525 ret
= constraintExpr_combineConstants (ret
);
1527 ret
= constraintExpr_simplifyChildren (ret
);
1535 t
= constraintExprData_termGetTerm (ret
->data
);
1536 t
= constraintTerm_copy(t
);
1537 t
= constraintTerm_simplify (t
);
1538 ret
->data
= constraintExprData_termSetTerm (ret
->data
, t
);
1541 ret
= constraintExpr_simplifyunaryExpr (ret
);
1544 ret
= constraintExpr_simplifybinaryExpr (ret
);
1550 DPRINTF ((message ("constraintExpr_simplify returning :%s", constraintExpr_unparse (ret
) ) ) );
1556 cstring
constraintExpr_unparse (/*@temp@*/ constraintExpr ex
) /*@*/
1559 constraintExprKind kind
;
1561 llassert (ex
!= NULL
);
1568 if (context_getFlag (FLG_PARENCONSTRAINT
) )
1570 st
= message ("(%q) ", constraintTerm_unparse (constraintExprData_termGetTerm (ex
->data
)));
1574 st
= message ("%q", constraintTerm_unparse (constraintExprData_termGetTerm (ex
->data
)));
1578 st
= message ("%q(%q)",
1579 constraintExprUnaryOpKind_print (constraintExprData_unaryExprGetOp (ex
->data
) ),
1580 constraintExpr_unparse (constraintExprData_unaryExprGetExpr (ex
->data
) )
1584 if (context_getFlag (FLG_PARENCONSTRAINT
) )
1586 st
= message ("(%q) %q (%q)",
1587 constraintExpr_unparse (constraintExprData_binaryExprGetExpr1 (ex
->data
) ),
1588 constraintExprBinaryOpKind_print (constraintExprData_binaryExprGetOp (ex
->data
)),
1589 constraintExpr_unparse (constraintExprData_binaryExprGetExpr2 (ex
->data
) )
1594 st
= message ("%q %q %q",
1595 constraintExpr_unparse (constraintExprData_binaryExprGetExpr1 (ex
->data
)),
1596 constraintExprBinaryOpKind_print (constraintExprData_binaryExprGetOp (ex
->data
)),
1597 constraintExpr_unparse (constraintExprData_binaryExprGetExpr2 (ex
->data
))
1604 st
= message ("error");
1608 DPRINTF((message ("constraintExpr_unparse: '%s'",st
) ) );
1612 constraintExpr
constraintExpr_doSRefFixBaseParam (/*@returned@*/ constraintExpr expr
, exprNodeList arglist
)
1614 constraintTerm Term
;
1615 constraintExprKind kind
;
1616 constraintExpr expr1
, expr2
;
1617 constraintExprData data
;
1618 llassert (expr
!= NULL
);
1627 Term
= constraintExprData_termGetTerm(data
);
1628 Term
= constraintTerm_copy(Term
);
1630 Term
= constraintTerm_doSRefFixBaseParam (Term
, arglist
);
1631 data
= constraintExprData_termSetTerm(data
, Term
);
1634 expr1
= constraintExprData_unaryExprGetExpr (data
);
1635 expr1
= constraintExpr_copy(expr1
);
1637 expr1
= constraintExpr_doSRefFixBaseParam (expr1
, arglist
);
1638 data
= constraintExprData_unaryExprSetExpr (data
, expr1
);
1641 expr1
= constraintExprData_binaryExprGetExpr1 (data
);
1642 expr2
= constraintExprData_binaryExprGetExpr2 (data
);
1644 expr1
= constraintExpr_copy(expr1
);
1645 expr2
= constraintExpr_copy(expr2
);
1647 expr1
= constraintExpr_doSRefFixBaseParam (expr1
, arglist
);
1648 data
= constraintExprData_binaryExprSetExpr1 (data
, expr1
);
1649 expr2
= constraintExpr_doSRefFixBaseParam (expr2
, arglist
);
1650 data
= constraintExprData_binaryExprSetExpr2 (data
, expr2
);
1661 / *@only@* / constraintExpr constraintExpr_doSRefFixInvarConstraint (/ *@only@* / constraintExpr expr, sRef s, ctype ct)
1663 constraintExprKind kind;
1664 constraintExpr expr1, expr2;
1665 constraintExprData data;
1666 llassert (expr != NULL);
1675 expr = doSRefFixInvarConstraintTerm (expr, s, ct);
1678 expr1 = constraintExprData_unaryExprGetExpr (data);
1679 expr1 = constraintExpr_copy(expr1);
1680 expr1 = constraintExpr_doSRefFixInvarConstraint (expr1, s, ct);
1681 data = constraintExprData_unaryExprSetExpr (data, expr1);
1684 expr1 = constraintExprData_binaryExprGetExpr1 (data);
1685 expr2 = constraintExprData_binaryExprGetExpr2 (data);
1687 expr1 = constraintExpr_copy(expr1);
1688 expr2 = constraintExpr_copy(expr2);
1690 expr1 = constraintExpr_doSRefFixInvarConstraint (expr1, s, ct);
1691 data = constraintExprData_binaryExprSetExpr1 (data, expr1);
1692 expr2 = constraintExpr_doSRefFixInvarConstraint (expr2, s, ct);
1693 data = constraintExprData_binaryExprSetExpr2 (data, expr2);
1704 /*@only@*/ constraintExpr
constraintExpr_doSRefFixConstraintParam (/*@only@*/ constraintExpr expr
, exprNodeList arglist
) /*@modifies expr@*/
1706 constraintExprKind kind
;
1707 constraintExpr expr1
, expr2
;
1708 constraintExprData data
;
1709 llassert (expr
!= NULL
);
1718 expr
= doSRefFixConstraintParamTerm (expr
, arglist
);
1721 expr1
= constraintExprData_unaryExprGetExpr (data
);
1722 expr1
= constraintExpr_copy(expr1
);
1723 expr1
= constraintExpr_doSRefFixConstraintParam (expr1
, arglist
);
1724 data
= constraintExprData_unaryExprSetExpr (data
, expr1
);
1727 expr1
= constraintExprData_binaryExprGetExpr1 (data
);
1728 expr2
= constraintExprData_binaryExprGetExpr2 (data
);
1730 expr1
= constraintExpr_copy(expr1
);
1731 expr2
= constraintExpr_copy(expr2
);
1733 expr1
= constraintExpr_doSRefFixConstraintParam (expr1
, arglist
);
1734 data
= constraintExprData_binaryExprSetExpr1 (data
, expr1
);
1735 expr2
= constraintExpr_doSRefFixConstraintParam (expr2
, arglist
);
1736 data
= constraintExprData_binaryExprSetExpr2 (data
, expr2
);
1746 /*@only@*/ constraintExpr
constraintExpr_doFixResult (/*@only@*/ constraintExpr expr
, /*@observer@*/ exprNode fcnCall
)
1748 constraintExprKind kind
;
1749 constraintExpr expr1
, expr2
;
1750 constraintExprData data
;
1751 llassert (expr
!= NULL
);
1760 expr
= doFixResultTerm (expr
, fcnCall
);
1763 expr1
= constraintExprData_unaryExprGetExpr (data
);
1764 expr1
= constraintExpr_copy(expr1
);
1766 expr1
= constraintExpr_doFixResult (expr1
, fcnCall
);
1767 data
= constraintExprData_unaryExprSetExpr (data
, expr1
);
1770 expr1
= constraintExprData_binaryExprGetExpr1 (data
);
1771 expr2
= constraintExprData_binaryExprGetExpr2 (data
);
1773 expr1
= constraintExpr_copy(expr1
);
1774 expr2
= constraintExpr_copy(expr2
);
1776 expr1
= constraintExpr_doFixResult (expr1
, fcnCall
);
1777 data
= constraintExprData_binaryExprSetExpr1 (data
, expr1
);
1778 expr2
= constraintExpr_doFixResult (expr2
, fcnCall
);
1779 data
= constraintExprData_binaryExprSetExpr2 (data
, expr2
);
1789 cstring
constraintExpr_print (constraintExpr expr
) /*@*/
1791 return constraintExpr_unparse (expr
);
1794 bool constraintExpr_hasMaxSet (constraintExpr expr
) /*@*/
1798 t
= constraintExpr_unparse(expr
);
1800 if (cstring_containsLit(t
, "maxSet") != NULL
)
1814 /*returns 1 0 -1 like strcmp
1820 int constraintExpr_compare (constraintExpr expr1
, constraintExpr expr2
)
1822 long value1
, value2
;
1824 if (constraintExpr_similar (expr1
, expr2
) )
1829 value1
= constraintExpr_getValue(expr1
);
1830 value2
= constraintExpr_getValue(expr2
);
1832 if (value1
> value2
)
1835 if (value1
== value2
)
1842 long constraintExpr_getValue (constraintExpr expr
)
1844 llassert (constraintExpr_isDefined(expr
) );
1845 llassert (expr
->kind
== term
);
1847 return (constraintTerm_getValue (constraintExprData_termGetTerm (expr
->data
)));
1850 bool constraintExpr_canGetValue (constraintExpr expr
)
1852 llassert ( constraintExpr_isDefined (expr
) );
1853 if (constraintExpr_isUndefined (expr
) )
1861 return constraintTerm_canGetValue (constraintExprData_termGetTerm (expr
->data
) );
1870 fileloc
constraintExpr_loc (constraintExpr expr
)
1874 constraintExprKind kind
;
1876 llassert ( constraintExpr_isDefined (expr
) );
1877 if (constraintExpr_isUndefined (expr
) )
1879 return fileloc_undefined
;
1888 t
= constraintExprData_termGetTerm (expr
->data
);
1889 return (constraintTerm_getFileloc (t
) );
1893 e
= constraintExprData_unaryExprGetExpr (expr
->data
);
1894 return (constraintExpr_loc (e
) );
1898 e
= constraintExprData_binaryExprGetExpr1 (expr
->data
);
1899 return (constraintExpr_loc (e
) );
1904 return (fileloc_undefined
);
1907 /*drl moved from constriantTerm.c 5/20/001*/
1908 static /*@only@*/ constraintExpr
1909 doFixResultTerm (/*@only@*/ constraintExpr e
, /*@exposed@*/ exprNode fcnCall
)
1913 constraintExprData data
;
1914 constraintExprKind kind
;
1917 llassert (constraintExpr_isDefined (e
) );
1922 llassert (kind
== term
);
1924 t
= constraintExprData_termGetTerm (data
);
1925 llassert (constraintTerm_isDefined (t
));
1929 switch (constraintTerm_getKind (t
))
1932 case CTT_INTLITERAL
:
1936 s
= constraintTerm_getSRef(t
);
1937 if (sRef_isResult (s
))
1939 ret
= constraintExpr_makeExprNode(fcnCall
);
1940 constraintExpr_free(e
);
1958 /*to be used for structure checking */
1960 / *@only@
* / static constraintExpr
1961 doSRefFixInvarConstraintTerm (/ *@only@
* / constraintExpr e
, sRef s
, ctype ct
)
1965 constraintExprData data
= e
->data
;
1967 constraintExprKind kind
= e
->kind
;
1971 llassert(kind
== term
);
1973 t
= constraintExprData_termGetTerm (data
);
1974 llassert (constraintTerm_isDefined(t
) );
1978 DPRINTF (("Fixing: %s", constraintExpr_print (e
)));
1980 switch (constraintTerm_getKind(t
))
1983 DPRINTF((message ("%q @ %q ", constraintTerm_unparse(t
),
1984 fileloc_unparse (constraintTerm_getFileloc(t
) ) ) ));
1986 case CTT_INTLITERAL
:
1987 DPRINTF((message (" %q ", constraintTerm_unparse (t
)) ));
1991 / * evans
2001-07-24: constants should use the original term
* /
1992 if (!constraintTerm_canGetValue (t
))
1995 DPRINTF ((message("Doing sRef_fixInvarConstraint for %q ",
1996 constraintTerm_unparse (t
) ) ));
1998 snew
= fixSref (ct
, s
, constraintTerm_getSRef(t
));
2000 ret
= constraintExpr_makeTermsRef(snew
);
2002 constraintExpr_free (e
);
2004 DPRINTF (( message("After Doing sRef_fixConstraintParam constraintExpr is %q ",
2005 constraintExpr_print (ret
) ) ));
2006 / *@
-branchstate@
* /
2007 } / *@
=branchstate@
* /
2019 /*drl moved from constriantTerm.c 5/20/001*/
2020 /*@only@*/ static constraintExpr
2021 doSRefFixConstraintParamTerm (/*@only@*/ constraintExpr e
, /*@observer@*/ /*@temp@*/ exprNodeList arglist
)
2025 constraintExprData data
;
2027 constraintExprKind kind
;
2032 llassert(constraintExpr_isDefined (e
) );
2040 llassert(kind
== term
);
2042 t
= constraintExprData_termGetTerm (data
);
2043 llassert (constraintTerm_isDefined(t
) );
2047 DPRINTF (("Fixing: %s", constraintExpr_print (e
)));
2049 switch (constraintTerm_getKind(t
))
2052 DPRINTF((message ("%q @ %q ", constraintTerm_unparse(t
),
2053 fileloc_unparse (constraintTerm_getFileloc(t
) ) ) ));
2055 case CTT_INTLITERAL
:
2056 DPRINTF((message (" %q ", constraintTerm_unparse (t
)) ));
2059 /* evans 2001-07-24: constants should use the original term */
2060 if (!constraintTerm_canGetValue (t
))
2062 DPRINTF ((message("Doing sRef_fixConstraintParam for %q ",
2063 constraintTerm_unparse (t
) ) ));
2064 ret
= sRef_fixConstraintParam (constraintTerm_getSRef(t
), arglist
);
2066 constraintExpr_free (e
);
2068 DPRINTF (( message("After Doing sRef_fixConstraintParam constraintExpr is %q ",
2069 constraintExpr_print (ret
) ) ));
2071 } /*@=branchstate@*/
2084 bool constraintExpr_includesTerm (constraintExpr expr
, constraintTerm term
)
2086 if (constraintTerm_hasTerm (expr
->term
, term
) )
2089 if ((expr
->expr
) != NULL
)
2091 return ( constraintExpr_includesTerm (expr
->expr
, term
) );
2098 /*drl added 6/11/01 */
2099 bool constraintExpr_isBinaryExpr (/*@observer@*/ constraintExpr c
)
2102 llassert(constraintExpr_isDefined (c
) );
2104 if ( ! (constraintExpr_isDefined (c
) ) )
2107 if (c
->kind
== binaryexpr
)
2114 /*drl added 8/08/001 */
2115 bool constraintExpr_isTerm (/*@observer@*/ constraintExpr c
) /*@*/
2117 llassert(constraintExpr_isDefined (c
) );
2119 if (c
->kind
== term
)
2126 /*@observer@*/ /*@temp@*/ constraintTerm
constraintExpr_getTerm ( /*@temp@*/ /*@observer@*/ constraintExpr c
) /*@*/
2128 constraintTerm term
;
2130 llassert(constraintExpr_isDefined (c
) );
2132 llassert(constraintExpr_isTerm(c
) );
2134 term
= constraintExprData_termGetTerm(c
->data
);
2139 static void binaryExpr_dump (/*@observer@*/ constraintExprData data
, FILE *f
)
2141 constraintExpr expr1
;
2142 constraintExprBinaryOpKind binaryOp
;
2143 constraintExpr expr2
;
2146 binaryOp
= constraintExprData_binaryExprGetOp (data
);
2148 fprintf(f
, "%d\n", (int) binaryOp
);
2150 expr1
= constraintExprData_binaryExprGetExpr1 (data
);
2151 expr2
= constraintExprData_binaryExprGetExpr2 (data
);
2155 constraintExpr_dump(expr1
, f
);
2158 constraintExpr_dump(expr2
, f
);
2162 static constraintExpr
binaryExpr_undump (FILE *f
)
2164 constraintExpr expr1
;
2165 constraintExprBinaryOpKind binaryOp
;
2166 constraintExpr expr2
;
2175 os
= mstring_create (MAX_DUMP_LINE_LENGTH
);
2177 str
= fgets(os
, MAX_DUMP_LINE_LENGTH
, f
);
2179 if (! mstring_isDefined(str
) )
2181 llfatalbug(message("Library file is corrupted") );
2184 binaryOp
= (constraintExprBinaryOpKind
) reader_getInt(&str
);
2186 str
= fgets(os
, MAX_DUMP_LINE_LENGTH
, f
);
2188 if (! mstring_isDefined(str
) )
2190 llfatalbug(message("Library file is corrupted") );
2193 reader_checkChar (&str
, 'e');
2194 reader_checkChar (&str
, '1');
2196 expr1
= constraintExpr_undump (f
);
2198 str
= fgets(os
, MAX_DUMP_LINE_LENGTH
, f
);
2200 reader_checkChar (&str
, 'e');
2201 reader_checkChar (&str
, '2');
2203 expr2
= constraintExpr_undump (f
);
2205 ret
= constraintExpr_makeBinaryOpConstraintExpr (expr1
, expr2
);
2206 ret
->data
= constraintExprData_binaryExprSetOp(ret
->data
, binaryOp
);
2214 static void unaryExpr_dump (/*@observer@*/ constraintExprData data
, FILE *f
)
2217 constraintExpr expr
;
2218 constraintExprUnaryOpKind unaryOp
;
2220 unaryOp
= constraintExprData_unaryExprGetOp (data
);
2222 fprintf(f
, "%d\n", (int) unaryOp
);
2224 expr
= constraintExprData_unaryExprGetExpr (data
);
2226 constraintExpr_dump(expr
, f
);
2229 static constraintExpr
unaryExpr_undump ( FILE *f
)
2232 constraintExpr expr
;
2233 constraintExprUnaryOpKind unaryOp
;
2239 str
= mstring_create (MAX_DUMP_LINE_LENGTH
);
2241 str
= fgets(os
, MAX_DUMP_LINE_LENGTH
, f
);
2243 if (! mstring_isDefined(str
) )
2245 llfatalbug(message("Library file is corrupted") );
2248 unaryOp
= (constraintExprUnaryOpKind
) reader_getInt(&str
);
2250 expr
= constraintExpr_undump (f
);
2252 ret
= constraintExpr_makeUnaryOp (expr
, unaryOp
);
2259 void constraintExpr_dump (/*@observer@*/ constraintExpr expr
, FILE *f
)
2261 constraintExprKind kind
;
2265 llassert(constraintExpr_isDefined(expr
) );
2267 DPRINTF((message("constraintExpr_dump:: dumping constraintExpr %s",
2268 constraintExpr_unparse(expr
)
2273 fprintf(f
,"%d\n", (int) kind
);
2278 t
= constraintExprData_termGetTerm (expr
->data
);
2279 constraintTerm_dump (t
, f
);
2282 unaryExpr_dump (expr
->data
, f
);
2285 binaryExpr_dump (expr
->data
, f
);
2290 /*@only@*/ constraintExpr
constraintExpr_undump (FILE *f
)
2292 constraintExprKind kind
;
2299 s
= mstring_create (MAX_DUMP_LINE_LENGTH
);
2303 s
= fgets(os
, MAX_DUMP_LINE_LENGTH
, f
);
2305 if (! mstring_isDefined(s
) )
2307 llfatalbug(message("Library file is corrupted") );
2310 kind
= (constraintExprKind
) reader_getInt(&s
);
2317 t
= constraintTerm_undump (f
);
2318 ret
= constraintExpr_makeTerm(t
);
2321 ret
= unaryExpr_undump (f
);
2324 ret
= binaryExpr_undump (f
);
2332 int constraintExpr_getDepth (constraintExpr ex
)
2336 constraintExprKind kind
;
2338 llassert (ex
!= NULL
);
2348 ret
= constraintExpr_getDepth (constraintExprData_unaryExprGetExpr (ex
->data
) );
2354 ret
= constraintExpr_getDepth (constraintExprData_binaryExprGetExpr1 (ex
->data
) );
2358 ret
+= constraintExpr_getDepth (constraintExprData_binaryExprGetExpr2 (ex
->data
) );
2369 bool constraintExpr_canGetCType (constraintExpr e
) /*@*/
2371 if (constraintExpr_isUndefined(e
))
2374 if (e
->kind
== term
)
2380 DPRINTF (("constraintExpr_canGetCType: can't get type for %s", constraintExpr_unparse (e
)));
2385 ctype
constraintExpr_getCType (constraintExpr e
) /*@*/
2389 llassert (constraintExpr_isDefined (e
));
2390 llassert (constraintExpr_canGetCType (e
));
2395 t
= constraintExprData_termGetTerm (e
->data
);
2396 return (constraintTerm_getCType(t
) );
2397 /* assume that a unary expression will be an int ... */
2399 return ctype_unknown
; /* was ctype_signedintegral; */
2400 /* drl for just return type of first operand */
2402 return (constraintExpr_getCType (constraintExprData_binaryExprGetExpr1 (e
->data
)));
2409 /* drl add 10-5-001 */
2411 static bool constraintExpr_hasTypeChange (constraintExpr e
)
2413 llassert(constraintExpr_isDefined(e
));
2415 if (constraintExpr_isDefined((e
)) && (e
->ct
== TRUE
))
2420 if (e
->kind
== unaryExpr
)
2422 if (constraintExprData_unaryExprGetOp (e
->data
) == MAXSET
)
2424 constraintExpr ce
= constraintExprData_unaryExprGetExpr(e
->data
);
2425 DPRINTF (("Unary type change: [%x] %s", ce
, constraintExpr_unparse (ce
)));
2426 DPRINTF (("Types: %s / %s", ctype_unparse (constraintExpr_getCType (ce
)),
2427 ctype_unparse (constraintExpr_getOrigType (ce
))));
2428 return (constraintExpr_hasTypeChange(ce
));
2435 /* drl add 10-5-001 */
2437 static ctype
constraintExpr_getOrigType (constraintExpr e
)
2439 llassert (constraintExpr_isDefined (e
));
2440 llassert (constraintExpr_hasTypeChange (e
));
2447 if (e
->kind
== unaryExpr
)
2449 if (constraintExprData_unaryExprGetOp (e
->data
) == MAXSET
)
2451 constraintExpr ce
= constraintExprData_unaryExprGetExpr (e
->data
);
2452 return (constraintExpr_getOrigType(ce
));
2460 /*drl added these around 10/18/001*/
2462 static /*@only@*/ constraintExpr
2463 constraintExpr_div (/*@only@*/ constraintExpr e
, ctype tfrom
, ctype tto
, fileloc loc
)
2465 int sizefrom
= ctype_getSize (tfrom
);
2466 int sizeto
= ctype_getSize (tto
);
2468 DPRINTF (("constraintExpr_div: %s", constraintExpr_unparse (e
)));
2469 DPRINTF (("Types: %s / %s",
2470 ctype_unparse (tfrom
),
2471 ctype_unparse (tto
)));
2473 if (sizefrom
== -1) {
2474 llbug (message ("constraintExpr_div: type size unknown: %s", ctype_unparse (tfrom
)));
2478 llbug (message ("constraintExpr_div: type size unknown: %s", ctype_unparse (tto
)));
2481 if (sizeto
== sizefrom
)
2483 DPRINTF (("Sizes match: %d / %d", sizeto
, sizefrom
));
2484 ; /* Sizes match, a-ok */
2488 float scale
= (float) sizefrom
/ (float) sizeto
;
2494 llassert (e
!= NULL
);
2495 llassert (e
->kind
== term
);
2496 ct
= constraintExprData_termGetTerm (e
->data
);
2497 DPRINTF (("constraint: %s / %s", constraintExpr_unparse (e
), constraintTerm_unparse (ct
)));
2498 llassert (constraintTerm_canGetValue (ct
));
2499 val
= constraintTerm_getValue (ct
);
2501 DPRINTF (("Scaling constraints by: %ld * %f", val
, scale
));
2503 fnewval
= ((float) val
) * scale
;
2504 newval
= (long) fnewval
;
2506 DPRINTF (("Values: %f / %ld", fnewval
, newval
));
2508 if ((fnewval
- (float) newval
) > FLT_EPSILON
)
2510 voptgenerror (FLG_ALLOCMISMATCH
,
2511 message ("Allocated memory is converted to type %s of (size %d), "
2512 "which is not divisible into original allocation of space "
2513 "for %d elements of type %s (size %d)",
2514 ctype_unparse (tto
), sizeto
,
2515 long_toInt (val
), ctype_unparse (tfrom
), sizefrom
),
2519 constraintTerm_setValue (ct
, newval
);
2522 DPRINTF (("After div: %s", constraintExpr_unparse (e
)));
2527 /*@access exprNode@*/
2528 static /*@only@*/ constraintExpr
2529 constraintTerm_simpleDivTypeExprNode (/*@only@*/ constraintExpr e
, ctype tfrom
, ctype tto
, fileloc loc
)
2532 exprNode t1
, t2
, expr
;
2536 llassert (constraintExpr_isDefined(e
) );
2538 DPRINTF (("constraintTerm_simpleDivTypeExprNode e=%s [%s => %s]", constraintExpr_print(e
),
2539 ctype_unparse(tfrom
), ctype_unparse (tto
)));
2541 t
= constraintExprData_termGetTerm (e
->data
);
2543 expr
= constraintTerm_getExprNode (t
);
2545 llassert (constraintExpr_isDefined(e
));
2546 llassert (exprNode_isDefined(expr
));
2548 if (expr
->kind
== XPR_OP
)
2552 t1
= exprData_getOpA (data
);
2553 t2
= exprData_getOpB (data
);
2554 tok
= exprData_getOpTok (data
);
2556 if (lltok_isMult (tok
))
2559 ** If the sizeof is first, flip them.
2562 llassert (exprNode_isDefined(t1
) && exprNode_isDefined(t2
));
2564 if (t2
->kind
== XPR_SIZEOF
|| t2
->kind
== XPR_SIZEOFT
)
2571 /*drl 3/2/2003 we know this from the fact that it's a
2572 multiplication operation...*/
2574 if (t1
->kind
== XPR_SIZEOF
|| t1
->kind
== XPR_SIZEOFT
)
2578 if (t1
->kind
== XPR_SIZEOFT
)
2580 multype
= qtype_getType (exprData_getType (t1
->edata
));
2584 exprNode tempE
= exprData_getSingle (t1
->edata
);
2585 multype
= exprNode_getType (tempE
);
2588 DPRINTF (("Here we go sizeof: %s / %s / %s",
2589 ctype_unparse (multype
), ctype_unparse (tfrom
), ctype_unparse (tto
)));
2590 llassert (ctype_isPointer (tfrom
));
2592 if (ctype_almostEqual (ctype_makePointer (multype
), tto
))
2594 /* this is a bit sloopy but ... */
2595 constraintExpr_free (e
);
2596 DPRINTF (("Sizeof types match okay!"));
2597 return constraintExpr_makeExprNode (t2
);
2601 int sizemul
= ctype_getSize (multype
);
2602 ctype tobase
= ctype_baseArrayPtr (tto
);
2603 int sizeto
= ctype_getSize (tobase
);
2605 DPRINTF (("Types: %s / %s / %s",
2606 ctype_unparse (tfrom
), ctype_unparse (tto
), ctype_unparse (multype
)));
2608 voptgenerror (FLG_ALLOCMISMATCH
,
2609 message ("Allocated memory is used as a different type (%s) from the sizeof type (%s)",
2610 ctype_unparse (tobase
), ctype_unparse (multype
)),
2613 if (sizemul
== sizeto
)
2615 constraintExpr_free (e
);
2616 DPRINTF (("Sizeof types match okay!"));
2617 return constraintExpr_makeExprNode (t2
);
2621 /* nothing was here */
2622 DPRINTF (("MISMATCHING TYPES!"));
2623 return (constraintExpr_div (constraintExpr_makeExprNode (t2
), multype
, tto
, loc
));
2629 DPRINTF (("NOT A SIZEOF!"));
2635 DPRINTF (("Not a mult: %s", constraintExpr_unparse (e
)));
2639 return (constraintExpr_div (e
, tfrom
, tto
, loc
));
2641 /*@noaccess exprNode@*/
2643 static /*@only@*/ constraintExpr
simpleDivType (/*@only@*/ constraintExpr e
, ctype tfrom
, ctype tto
, fileloc loc
)
2645 DPRINTF (("simpleDiv got %s", constraintExpr_unparse(e
)));
2646 DPRINTF (("Types: %s / %s",
2647 ctype_unparse (tfrom
),
2648 ctype_unparse (tto
)));
2650 llassert (constraintExpr_isDefined(e
));
2656 constraintTerm t
= constraintExprData_termGetTerm (e
->data
);
2658 DPRINTF (("Term: %s", constraintTerm_unparse (t
)));
2660 if (constraintTerm_isExprNode (t
))
2662 return constraintTerm_simpleDivTypeExprNode (e
, tfrom
, tto
, loc
);
2664 /* search for * size of ct and remove */
2666 DPRINTF (("Here: %s / %s -> %s", constraintExpr_unparse (e
), ctype_unparse (tfrom
), ctype_unparse (tto
)));
2667 return constraintExpr_div (e
, tfrom
, tto
, loc
);
2672 constraintExpr temp
;
2674 temp
= constraintExprData_binaryExprGetExpr1 (e
->data
);
2675 temp
= constraintExpr_copy(temp
);
2676 temp
= simpleDivType (temp
, tfrom
, tto
, loc
);
2678 e
->data
= constraintExprData_binaryExprSetExpr1 (e
->data
, temp
);
2680 temp
= constraintExprData_binaryExprGetExpr2 (e
->data
);
2681 temp
= constraintExpr_copy(temp
);
2682 temp
= simpleDivType (temp
, tfrom
, tto
, loc
);
2683 e
->data
= constraintExprData_binaryExprSetExpr2 (e
->data
, temp
);
2685 DPRINTF (("simpleDiv binaryexpr returning %s ", constraintExpr_unparse(e
)));
2690 return constraintExpr_div (e
, tfrom
, tto
, loc
);
2698 static /*@only@*/ constraintExpr
constraintExpr_adjustMaxSetForCast (/*@only@*/ constraintExpr e
, ctype tfrom
,
2699 ctype tto
, fileloc loc
)
2701 DPRINTF (("constraintExpr_adjustMaxSetForCast got %s [%s => %s]", constraintExpr_unparse(e
),
2702 ctype_unparse (tfrom
), ctype_unparse (tto
)));
2704 e
= constraintExpr_makeIncConstraintExpr (e
);
2705 e
= constraintExpr_simplify (e
);
2706 e
= simpleDivType (e
, tfrom
, tto
, loc
);
2707 e
= constraintExpr_makeDecConstraintExpr (e
);
2708 e
= constraintExpr_simplify (e
);
2710 DPRINTF (("constraintExpr_adjustMaxSetForCast returning %s ", constraintExpr_unparse(e
)));
2715 bool constraintExpr_isConstantOnly (constraintExpr e
)
2717 DPRINTF (("constraintExpr_isConstantOnly %s ", constraintExpr_unparse(e
)));
2718 llassert (constraintExpr_isDefined(e
));
2724 constraintTerm t
= constraintExprData_termGetTerm(e
->data
);
2726 if (constraintTerm_isConstantOnly (t
))
2738 constraintExpr temp1
= constraintExprData_binaryExprGetExpr1 (e
->data
);
2739 constraintExpr temp2
= constraintExprData_binaryExprGetExpr2 (e
->data
);
2741 if (constraintExpr_isConstantOnly(temp1
) &&
2742 constraintExpr_isConstantOnly(temp2
) )
2754 constraintExpr temp
;
2756 temp
= constraintExprData_unaryExprGetExpr (e
->data
);
2758 if (constraintExpr_isConstantOnly(temp
) )