示例#1
0
bool constraint_isPost  (/*@observer@*/ /*@temp@*/ constraint c)
{
  llassert (constraint_isDefined (c));

  if (constraint_isUndefined (c))
    return FALSE;
  
  return (c->post);
}
示例#2
0
cstring  constraint_unparseDetailed (constraint c)
{
  cstring st = cstring_undefined;
  cstring temp = cstring_undefined;
  cstring genExpr;
  bool isLikely;
   
  llassert (constraint_isDefined (c));
   
  if (!c->post)
    {
      st = message ("Unable to resolve constraint:\n%q", constraint_unparseDeep (c));
    }
  else
    {
      st = message ("Block Post condition:\nThis function block has the post condition %q", constraint_unparseDeep (c));
    }

  isLikely = constraint_isConstantOnly (c);

  if (isLikely)
    {
      if (constraint_hasMaxSet (c))
	{
	  temp = cstring_makeLiteral ("Likely out-of-bounds store: ");
	}
      else
	{
	  temp = cstring_makeLiteral ("Likely out-of-bounds read: ");
	}
    }
  else
    {
      
      if (constraint_hasMaxSet (c))
	{
	  temp = cstring_makeLiteral ("Possible out-of-bounds store: ");
	}
      else
	{
	  temp = cstring_makeLiteral ("Possible out-of-bounds read: ");
	}
    }
  
  genExpr = exprNode_unparse (c->generatingExpr);
  
  if (context_getFlag (FLG_CONSTRAINTLOCATION))
    {
      cstring temp2;
      temp2 = message ("%s\n", genExpr);
      temp = cstring_concatFree (temp, temp2);
    }

  st  = cstring_concatFree (temp,st);
  
  return st;
}
示例#3
0
fileloc constraint_getFileloc (constraint c)
{
  llassert (constraint_isDefined (c) );
 
  if (exprNode_isDefined (c->generatingExpr))
    return (fileloc_copy (exprNode_loc (c->generatingExpr)));
  
  return (constraintExpr_loc (c->lexpr));
}
示例#4
0
constraint constraint_makeEnsureMaxReadAtLeast (exprNode t1, exprNode t2, fileloc sequencePoint)
{
  constraint ret = constraint_makeReadSafeExprNode (t1, t2);   
  llassert (constraint_isDefined (ret));
 
  ret->lexpr = constraintExpr_setFileloc (ret->lexpr, sequencePoint);  
  ret->post = TRUE;  

  return ret;
}
示例#5
0
constraint constraint_preserveOrig (/*@returned@*/ constraint c) /*@modifies c @*/
{
  if (constraint_isDefined (c))
    {
      DPRINTF (("Doing constraint_preserverOrig for %q", constraint_printLocation (c)));
      
      if (c->orig == constraint_undefined)
	{
	  c->orig = constraint_copy (c);
	}
      else if (c->orig->fcnPre)
	{
	  constraint temp = c->orig;
	  
	  /* avoid infinite loop */
	  c->orig = NULL;
	  c->orig = constraint_copy (c);
	  /*drl 03/2/2003 if c != NULL then the copy of c will != null*/
	  llassert (constraint_isDefined (c->orig) );
	  
	  if (c->orig->orig == NULL)
	    {
	      c->orig->orig = temp;
	      temp = NULL;
	    }
	  else
	    {
	      llcontbug ((message ("Expected c->orig->orig to be null")));
	      constraint_free (c->orig->orig);
	      c->orig->orig = temp;
	      temp = NULL;
	    }
	}
      else
	{
	  DPRINTF (("Not changing constraint"));
	}
    }

  DPRINTF ((message ("After Doing constraint_preserverOrig for %q ", constraint_unparseDetailed (c))));
  return c;
}
示例#6
0
constraint constraint_togglePostOrig (/*@returned@*/ constraint c)
{
  llassert (constraint_isDefined (c));
 
  if (c->orig != NULL)
    {
      c->orig = constraint_togglePost (c->orig);
    }

  return c;
}
示例#7
0
constraint constraint_doFixResult (constraint postcondition, /*@dependent@*/ exprNode fcnCall)
{
  postcondition = constraint_copy (postcondition);

  llassert (constraint_isDefined (postcondition) );
 
  
  postcondition->lexpr = constraintExpr_doFixResult (postcondition->lexpr, fcnCall);
  postcondition->expr = constraintExpr_doFixResult (postcondition->expr, fcnCall);

  return postcondition;
}
示例#8
0
void constraint_overWrite (constraint c1, constraint c2) 
{
  llassert (constraint_isDefined (c1) && constraint_isDefined (c2));

  llassert (c1 != c2);

  DPRINTF ((message ("OverWriteing constraint %q with %q", constraint_unparse (c1),
		   constraint_unparse (c2))));
  
  constraintExpr_free (c1->lexpr);
  constraintExpr_free (c1->expr);
  
  c1->lexpr = constraintExpr_copy (c2->lexpr);
  c1->ar = c2->ar;
  c1->expr =  constraintExpr_copy (c2->expr);
  c1->post = c2->post;

  if (c1->orig != NULL)
    constraint_free (c1->orig);

  if (c2->orig != NULL)
    c1->orig = constraint_copy (c2->orig);
  else
    c1->orig = NULL;

  if (c1->or != NULL)
    constraint_free (c1->or);

  if (c2->or != NULL)
    c1->or = constraint_copy (c2->or);
  else
    c1->or = NULL;

  c1->fcnPre = c2->fcnPre;

  /*@-assignexpose@*/
  c1->generatingExpr = c2->generatingExpr;
  /*@=assignexpose@*/
}
示例#9
0
/*@only@*/ constraint constraint_doSRefFixBaseParam (/*@returned@*/ /*@only@*/ constraint precondition,
						   exprNodeList arglist)
{
   
  llassert (constraint_isDefined (precondition) );
 
  precondition->lexpr = constraintExpr_doSRefFixBaseParam (precondition->lexpr,
							   arglist);
  precondition->expr = constraintExpr_doSRefFixBaseParam (precondition->expr,
							   arglist);

  return precondition;
}
示例#10
0
/*@only@*/ constraint constraint_doSRefFixConstraintParam (constraint precondition,
						   exprNodeList arglist)
{

  precondition = constraint_copy (precondition);

  llassert (constraint_isDefined (precondition) );
 
  precondition->lexpr = constraintExpr_doSRefFixConstraintParam (precondition->lexpr, arglist);
  precondition->expr = constraintExpr_doSRefFixConstraintParam (precondition->expr, arglist);

  precondition->fcnPre = FALSE;
  return constraint_simplify(precondition);
}
示例#11
0
constraint constraint_origAddGeneratingExpr (/*@returned@*/ constraint c, exprNode e)
{
  llassert (constraint_isDefined (c) );
 
  if (c->orig != constraint_undefined)
    {
      c->orig = constraint_addGeneratingExpr (c->orig, e);
    }
  else
    {
      DPRINTF ((message ("constraint_origAddGeneratingExpr: Not setting generatingExpr for %s to %s", constraint_unparse (c), exprNode_unparse (e)) ));
    }
  return c;
}
示例#12
0
bool constraint_hasMaxSet (constraint c)
{
  llassert (constraint_isDefined (c) );
 
  if (checkForMaxSet (c))
    return TRUE;
  
  if (c->orig != NULL)
    {
      if (checkForMaxSet (c->orig))
	return TRUE;
    }

  return FALSE;
}
示例#13
0
static bool increments (/*@observer@*/ constraint c,
			/*@observer@*/ constraintExpr var)
{
  llassert (constraint_isDefined (c) );

  if (constraint_isUndefined (c) )
    {
      return FALSE;
    }

  llassert (incVar (c));
  if (constraintExpr_similar (c->lexpr, var) )
    return TRUE;
  else
    return FALSE;
}
示例#14
0
constraint constraint_setFcnPre (/*@returned@*/ constraint c)
{

  llassert (constraint_isDefined (c) );
 
  if (c->orig != constraint_undefined)
    {
      c->orig->fcnPre = TRUE;
    }
  else
    {
      c->fcnPre = TRUE;
      DPRINTF (( message ("Warning Setting fcnPre directly")));
    }
  return c;
}
示例#15
0
constraint constraint_addGeneratingExpr (/*@returned@*/ constraint c, /*@exposed@*/ exprNode e)
{
  if (!constraint_isDefined (c)) 
    {
      return c;
    }
  
  if (c->generatingExpr == NULL)
    {
      c->generatingExpr = e;
      DPRINTF ((message ("setting generatingExpr for %s to %s", constraint_unparse (c), exprNode_unparse (e)) ));
    }
  else
    {
      DPRINTF ((message ("Not setting generatingExpr for %s to %s", constraint_unparse (c), exprNode_unparse (e)) ));
    }
  return c;
}
示例#16
0
void constraint_free (/*@only@*/ constraint c)
{
  if (constraint_isDefined (c))
    {
      constraint_free (c->orig);
      c->orig = NULL;

      constraint_free (c->or);
      c->or = NULL;

      constraintExpr_free (c->lexpr);
      c->lexpr = NULL;

      constraintExpr_free (c->expr);
      c->expr  = NULL;
      
      free (c);
    }
}
示例#17
0
static /*@only@*/ constraintList getLessThanConstraints (/*@observer@*/ constraintList c)
{
  constraintList ret;

  ret = constraintList_makeNew ();
  constraintList_elements (c, el)
    {
      llassert (constraint_isDefined (el));
      if ( constraint_isUndefined (el)  )
      	continue;
      
      if (el->ar == LT || el->ar == LTE)
	{
	  constraint temp;
	  temp = constraint_copy (el);

	  ret = constraintList_add (ret, temp);
	}
    }
示例#18
0
static int constraint_getDepth (/*@observer@*/ /*@temp@*/ constraint c)
{
  int l , r;
  
  llassert (constraint_isDefined (c) );
 
  l = constraintExpr_getDepth (c->lexpr);
  r = constraintExpr_getDepth (c->expr);

  if (l > r)
    {
      DPRINTF (( message ("constraint depth returning %d for %s", l, constraint_unparse (c))));
      return l;
    }
  else
    {
      DPRINTF (( message ("constraint depth returning %d for %s", r, constraint_unparse (c))));
      return r;
    }
}
示例#19
0
/*whether constraints consist only of
  terms which are constants*/
bool constraint_isConstantOnly (constraint c)
{
  bool l, r;
  
  llassert (constraint_isDefined (c) );
 
  l = constraintExpr_isConstantOnly(c->lexpr);
  r = constraintExpr_isConstantOnly(c->expr);

  if (l && r)
    {
      return TRUE;
    }

  else
    {
      return FALSE;
    }
  
}
示例#20
0
void constraint_dump (/*@observer@*/ constraint c,  FILE *f)
{
  bool           fcnPre;
  bool post;
  arithType       ar;
  
  constraintExpr lexpr;
  constraintExpr  expr;

  llassert (constraint_isDefined (c) );
 
  fcnPre = c->fcnPre;
  post   = c->post;
  ar     = c->ar;
  lexpr = c->lexpr;
  expr = c->expr;
  
  fprintf (f, "%d@%d@%d\n", (int) fcnPre, (int) post, (int) ar);
  fprintf (f,"l\n");
  constraintExpr_dump (lexpr, f);
  fprintf (f,"r\n");
  constraintExpr_dump (expr, f);
}
示例#21
0
void constraint_printError (constraint c, fileloc loc)
{
  cstring string;
  fileloc errorLoc, temp;

  bool isLikely;
    
  llassert (constraint_isDefined (c) );
 
  /*drl 11/26/2001 avoid printing tautological constraints */
  if (constraint_isAlwaysTrue (c))
    {
      return;
    }


  string = constraint_unparseDetailed (c);

  errorLoc = loc;

  temp = constraint_getFileloc (c);

  if (fileloc_isDefined (temp))
    {
      errorLoc = temp;
    }
  else
    {
      llassert (FALSE);
      DPRINTF (("constraint %s had undefined fileloc %s", 
		constraint_unparse (c), fileloc_unparse (temp)));
      fileloc_free (temp);
      errorLoc = fileloc_copy (errorLoc);
    }

  
  if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES))
    {
      string = cstring_replaceChar(string, '\n', ' ');
    }

  /*drl added 12/19/2002 print
    a different error fro "likely" bounds-errors*/
  
  isLikely = constraint_isConstantOnly (c);

  if (isLikely)
    {
      if (c->post)
	{
	  voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
	}
      else
	{
	  if (constraint_hasMaxSet (c))
	    {
	      voptgenerror (FLG_LIKELYBOUNDSWRITE, string, errorLoc);
	    }
	  else
	    {
	      voptgenerror (FLG_LIKELYBOUNDSREAD, string, errorLoc);
	    }
	}
    }
  else if (c->post)
    {
      voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
    }
  else
    {
      if (constraint_hasMaxSet (c))
	{
	  voptgenerror (FLG_BOUNDSWRITE, string, errorLoc);
	}
      else
	{
	  voptgenerror (FLG_BOUNDSREAD, string, errorLoc);
	}
    }

  fileloc_free(errorLoc);
}
示例#22
0
bool constraint_hasOrig ( /*@observer@*/ /*@temp@*/ constraint c)
{
  llassert (constraint_isDefined (c));
  return (c->orig != NULL);
}
示例#23
0
static bool checkForMaxSet (constraint c)
{  
  llassert (constraint_isDefined (c));
  return (constraintExpr_hasMaxSet (c->lexpr) || constraintExpr_hasMaxSet (c->expr));
}
示例#24
0
constraint constraint_togglePost (/*@returned@*/ constraint c)
{
  llassert (constraint_isDefined (c));
  c->post = !c->post;
  return c;
}