/*
** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Copyright (C) 1994-2002 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA.
**
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
** For more information: http://www.splint.org
*/
/*
** uentry.c
*/
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
# include "basic.h"
# include "structNames.h"
# include "nameChecks.h"
static void uentry_checkIterArgs (uentry p_ue);
static cstring uentry_dumpAux (uentry p_v, bool p_isParam);
-static void uentry_showWhereLastKind (uentry p_spec) /*@*/ ;
+static void uentry_showWhereLastKind (uentry p_spec) /*@modifies g_msgstream@*/ ;
static void uentry_combineModifies (uentry p_ue, /*@owned@*/ sRefSet p_sr)
/*@modifies p_ue@*/ ;
uentry_makeVariableAux (cstring p_n, ctype p_t, /*@keep@*/ fileloc p_f,
/*@exposed@*/ sRef p_s, bool p_priv, vkind p_kind);
+static /*@only@*/ /*@notnull@*/ uentry
+ uentry_makeConstantAux (cstring p_n, ctype p_t,
+ /*@keep@*/ fileloc p_f, bool p_priv, bool p_macro,
+ /*@only@*/ multiVal p_m) /*@*/ ;
+
static void uentry_convertVarFunction (uentry ue) /*@modifies ue@*/
{
if (uentry_isVariable (ue)
{
functionConstraint constraint;
- DPRINTF( (message ("called uentry_getFcnPostconditions on %s",
+ DPRINTF((message ("called uentry_getFcnPostconditions on %s",
uentry_unparse (ue) ) ) );
if (uentry_isVariable (ue) && ctype_isFunction (uentry_getType (ue)))
{
- DPRINTF( (message ("called uentry_getFunctionConditions on nonfunction %s",
+ DPRINTF((message ("called uentry_getFunctionConditions on nonfunction %s",
uentry_unparse (ue) ) ) );
if (!uentry_isFunction (ue) )
{
if (!uentry_isFunction(ue))
{
- DPRINTF( (message ("called uentry_getFunctionConditions on non function %s",
+ DPRINTF((message ("called uentry_getFunctionConditions on non function %s",
uentry_unparse (ue) ) ) );
return constraintList_undefined;
}
else
{
+ DPRINTF (("Taking globs: %s", globalsClause_unparse (glc)));
uentry_setGlobals (ue, globalsClause_takeGlobs (glc));
+ DPRINTF (("Taking globs after: %s", globalsClause_unparse (glc)));
}
}
else if (functionClause_isModifies (el))
if (functionConstraint_isDefined (ue->info->fcn->preconditions))
{
- /* drl 11-29-2001
+ /* drl 11-29-2002
I changed this so it didn't appear as a Splint bug
among other things this gets triggered when there is
a function with two requires clauses. Now Splint
}
else
{
- llfatalbug ( (message("uentry_setPreconditions called with invalid uentry") ));
+ llfatalbug ((message("uentry_setPreconditions called with invalid uentry") ));
}
}
}
else
{
- llfatalbug ( (message("uentry_setPostconditions called with invalid uentry") ));
+ llfatalbug ((message("uentry_setPostconditions called with invalid uentry") ));
}
}
** constants
*/
-/*@only@*/ /*@notnull@*/
+static /*@only@*/ /*@notnull@*/
uentry uentry_makeConstantAux (cstring n, ctype t,
- /*@keep@*/ fileloc f, bool priv,
+ /*@keep@*/ fileloc f, bool priv, bool macro,
/*@only@*/ multiVal m)
{
uentry e = uentry_alloc ();
e->info = (uinfo) dmalloc (sizeof (*e->info));
e->info->uconst = (ucinfo) dmalloc (sizeof (*e->info->uconst));
e->info->uconst->access = typeIdSet_undefined;
+ e->info->uconst->macro = macro;
uentry_setSpecDef (e, f);
/*@notnull@*/ uentry uentry_makeConstant (cstring n, ctype t, fileloc f)
{
- return (uentry_makeConstantAux (n, t, f, FALSE, multiVal_unknown ()));
+ return (uentry_makeConstantAux (n, t, f, FALSE, FALSE, multiVal_unknown ()));
+}
+
+/*@notnull@*/ uentry uentry_makeConstantValue (cstring n, ctype t, fileloc f, bool priv, multiVal val)
+{
+ return (uentry_makeConstantAux (n, t, f, priv, FALSE, val));
+}
+
+/*@notnull@*/ uentry uentry_makeMacroConstant (cstring n, ctype t, fileloc f)
+{
+ return (uentry_makeConstantAux (n, t, f, FALSE, TRUE, multiVal_unknown ()));
}
/*@notnull@*/ uentry uentry_makeIdConstant (idDecl t)
llassert (uentry_isVariable (ue));
oldInfo = ue->info->var;
- llassert (ctype_isUnknown (ue->utype) || ctype_isFunction (ue->utype));
+ DPRINTF (("ue: %s", uentry_unparseFull (ue)));
+ llassert (ctype_isUnknown (ue->utype) || ctype_isFunction (ctype_realType (ue->utype)));
/*
- ** expanded macro is marked used (until I write a pre-processor)
+ ** expanded macro is marked used
*/
ue->used = ue->used || (oldInfo->kind == VKEXPMACRO);
{
case KINVALID:
case KELIPSMARKER:
- /* bug detected by lclint:
+ /* bug detected by splint:
** uentry.c:753,14: Return value type bool does not match declared type int: TRUE
*/
return 0;
e->info = (uinfo) dmalloc (sizeof (*e->info));
e->info->uconst = (ucinfo) dmalloc (sizeof (*e->info->uconst));
e->info->uconst->access = access;
-
+ e->info->uconst->macro = FALSE; /*@i523! fix this when macro info added to library */
uentry_setConstantValue (e, m);
sRef_storeState (e->sref);
{
ucinfo ret = (ucinfo) dmalloc (sizeof (*ret));
ret->access = u->access;
+ ret->macro = u->macro;
return ret;
}
uentryList oldParams = uentry_getParams (old);
uentryList newParams = uentry_getParams (unew);
ctype newType = unew->utype;
- ctype oldType = old->utype;
+ ctype oldType = ctype_realType (old->utype);
ctype oldRetType = ctype_unknown;
ctype newRetType = ctype_unknown;
if (ctype_isKnown (oldType))
{
llassert (ctype_isFunction (oldType));
-
oldRetType = ctype_getReturnType (oldType);
}
if (ctype_isKnown (newType))
{
llassert (ctype_isFunction (newType));
-
newRetType = ctype_getReturnType (newType);
}
paramno++;
/*
- ** Forgot this! detected by lclint:
+ ** Forgot this! detected by splint:
** uentry.c:1257,15: Suspected infinite loop
*/
}
unew->info->fcn->specclauses = stateClauseList_undefined;
/*@-branchstate@*/
}
- /*@=branchstate@*/ /*@i23 shouldn't need this@*/
}
+ /*@=branchstate@*/ /*@i23 shouldn't need this@*/
if (fileloc_isUndefined (old->whereDeclared))
{
{
/* no change */
}
-}
+/*@i523 @*/ }
void
uentry_mergeConstantValue (uentry ue, /*@only@*/ multiVal m)
uentry_mergeAliasStates (res, other, loc, mustReturn, flip, opt, cl);
uentry_mergeValueStates (res, other, loc, mustReturn, flip);
uentry_mergeSetStates (res, other, loc, flip, cl);
+
+ DPRINTF (("Merge ==> %s", uentry_unparseFull (res)));
}
void uentry_setUsed (uentry e, fileloc loc)
fileloc_free (tloc);
uentry_setHasNameError (ue);
- if (context_getFlag (FLG_REPEATUNRECOG))
+ if (context_getFlag (FLG_REPEATUNRECOG) || (context_inOldSytleScope() ) )
{
uentry_markOwned (ue);
}