+/*drl moved out of constraintResolve.c 07-02-001 */
+void checkArgumentList (/*@out@*/ exprNode temp, exprNodeList arglist,
+ fileloc sequencePoint)
+{
+ temp->requiresConstraints = constraintList_makeNew();
+ temp->ensuresConstraints = constraintList_makeNew();
+ temp->trueEnsuresConstraints = constraintList_makeNew();
+ temp->falseEnsuresConstraints = constraintList_makeNew();
+
+ exprNodeList_elements (arglist, el)
+ {
+ constraintList temp2;
+ exprNode_exprTraverse (el, FALSE, FALSE, sequencePoint);
+ temp2 = el->requiresConstraints;
+ el->requiresConstraints = exprNode_traversRequiresConstraints(el);
+ constraintList_free(temp2);
+
+ temp2 = el->ensuresConstraints;
+ el->ensuresConstraints = exprNode_traversEnsuresConstraints(el);
+ constraintList_free(temp2);
+
+ temp->requiresConstraints = constraintList_addList(temp->requiresConstraints,
+ el->requiresConstraints);
+
+ temp->ensuresConstraints = constraintList_addList(temp->ensuresConstraints,
+ el->ensuresConstraints);
+ }
+ end_exprNodeList_elements;
+
+}
+
+/*drl moved out of constraintResolve.c 07-03-001 */
+constraintList exprNode_getPostConditions (exprNode fcn, exprNodeList arglist, exprNode fcnCall)
+{
+ constraintList postconditions;
+ uentry temp;
+ DPRINTF((message ("Got call that %s (%s) ", exprNode_unparse(fcn), exprNodeList_unparse (arglist))));
+
+ temp = exprNode_getUentry (fcn);
+
+ postconditions = uentry_getFcnPostconditions (temp);
+
+ if (constraintList_isDefined (postconditions))
+ {
+ postconditions = constraintList_doSRefFixConstraintParam (postconditions, arglist);
+ postconditions = constraintList_doFixResult (postconditions, fcnCall);
+ }
+ else
+ {
+ postconditions = constraintList_makeNew();
+ }
+
+ return postconditions;
+}
+
+/*
+comment this out for now
+we'll include it in a production release when its stable...
+
+ void findStructs (exprNodeList arglist)
+{
+
+ ctype ct, rt;
+
+ DPRINTF((
+ message("doing findStructs: %s", exprNodeList_unparse(arglist))
+ ));
+
+
+ exprNodeList_elements(arglist, expr)
+ {
+ ct = exprNode_getType(expr);
+
+ rt = ctype_realType (ct);
+
+ if (ctype_isStruct (rt))
+ TPRINTF((message("Found structure %s", exprNode_unparse(expr))
+ ));
+ if (hasInvariants(ct))
+ {
+ constraintList invars;
+
+ invars = getInvariants(ct);
+
+
+ TPRINTF((message ("findStructs has invariants %s ", constraintList_print (invars))
+ ));
+
+ invars = constraintList_doSRefFixStructConstraint(invars, exprNode_getSref(expr), ct);
+
+
+ TPRINTF((message ("findStructs finded invariants to be %s ", constraintList_print (invars))
+ ));
+ }
+ }
+ end_exprNodeList_elements;
+}
+
+*/
+
+/*drl moved out of constraintResolve.c 07-02-001 */
+constraintList checkCall (/*@dependent@*/ exprNode fcn, exprNodeList arglist)
+{
+ constraintList preconditions;
+ uentry temp;
+ DPRINTF((message ("Got call that %s (%s) ", exprNode_unparse(fcn), exprNodeList_unparse (arglist))));
+
+ temp = exprNode_getUentry (fcn);
+
+ preconditions = uentry_getFcnPreconditions (temp);
+
+ if (constraintList_isDefined(preconditions))
+ {
+ preconditions = constraintList_togglePost (preconditions);
+ preconditions = constraintList_preserveCallInfo(preconditions, fcn);
+ preconditions = constraintList_doSRefFixConstraintParam (preconditions, arglist);
+ }
+ else
+ {
+ if (constraintList_isUndefined(preconditions))
+ preconditions = constraintList_makeNew();
+ }
+
+ // drl remember to remove this code before you make a pslint release.
+ /*
+ if (context_getFlag (FLG_IMPLICTCONSTRAINT) )
+ {
+
+ uentryList_elements (params, el)
+ {
+ DPRINTF((message("setImplictfcnConstraints doing: %s", uentry_unparse(el) ) ));
+
+ s = uentry_getSref(el);
+ if (sRef_isReference (s) )
+ {
+ DPRINTF((message ("%s is a pointer", sRef_unparse(s) ) ));
+ }
+ else
+ {
+ DPRINTF((message ("%s is NOT a pointer", sRef_unparse(s) ) ));
+ }
+ //drl 4/26/01
+ //chagned this from MaxSet(s) == 0 to MaxSet(s) >= 0
+ c = constraint_makeSRefWriteSafeInt (s, 0);
+
+ implicitFcnConstraints = constraintList_add(implicitFcnConstraints , c);
+
+ //drl 10/23/2002 added support for out
+ if (!uentry_isOut(el) )
+ {
+ c = constraint_makeSRefReadSafeInt (s, 0);
+
+ implicitFcnConstraints = constraintList_add(implicitFcnConstraints , c);
+ }
+
+
+ }
+
+ }
+ */
+ DPRINTF ((message("Done checkCall\n")));
+ DPRINTF ((message("Returning list %q ", constraintList_printDetailed(preconditions))));
+
+ /*
+ drl we're going to comment this out for now
+ we'll include it if we're sure it's working
+
+ findStructs(arglist);
+ */
+
+ return preconditions;
+}
+
+/*drl added this function 10.29.001
+ takes an exprNode of the form const + const
+ and sets the value
+*/
+/*drl
+ I'm a bit nervous about modifying the exprNode
+ but this is the easy way to do this
+ If I have time I'd like to cause the exprNode to get created correctly in the first place */
+/*@i223*/
+void exprNode_findValue(exprNode e)
+{
+ exprData data;
+
+ exprNode t1, t2;
+ lltok tok;
+
+ data = e->edata;
+
+ if (exprNode_hasValue(e))
+ return;
+
+ if (e->kind == XPR_OP)
+ {
+ t1 = exprData_getOpA (data);
+ t2 = exprData_getOpB (data);
+ tok = exprData_getOpTok (data);
+
+ exprNode_findValue(t1);
+ exprNode_findValue(t2);
+
+ if (!(exprNode_knownIntValue(t1) && (exprNode_knownIntValue(t2))))
+ return;
+
+ if (lltok_isPlus_Op (tok))
+ {
+ long v1, v2;
+
+ v1 = exprNode_getLongValue(t1);
+ v2 = exprNode_getLongValue(t2);
+
+ if (multiVal_isDefined(e->val))
+ multiVal_free (e->val);
+
+ e->val = multiVal_makeInt (v1 + v2);
+ }
+
+ if (lltok_isMinus_Op (tok))
+ {
+ long v1, v2;
+
+ v1 = exprNode_getLongValue(t1);
+ v2 = exprNode_getLongValue(t2);
+
+ if (multiVal_isDefined(e->val))
+ {
+ multiVal_free (e->val);
+ }
+
+ e->val = multiVal_makeInt (v1 - v2);
+ }
+
+ /*drl I should really do * and / at some point */
+
+ }
+
+}
+