static bool sRef_equivalent (sRef p_s1, sRef p_s2);
static bool sRef_isDeepUnionField (sRef p_s);
static void sRef_addDeriv (/*@notnull@*/ sRef p_s, /*@notnull@*/ /*@exposed@*/ sRef p_t);
-static /*@dependent@*/ sRef sRef_makeResultType (ctype p_ct) /*@*/ ;
static bool sRef_checkModify (sRef p_s, sRefSet p_sl) /*@*/ ;
static void sRef_checkMutable (/*@unused@*/ sRef s)
static /*@only@*/ cstring sRef_unparseNoArgs (sRef p_s);
static /*@exposed@*/ sRef sRef_findDerivedPointer (sRef p_s);
+static /*@exposed@*/ sRef sRef_findDerivedArrayFetch (/*@notnull@*/ sRef, bool, int, bool) ;
static /*@exposed@*/ sRef sRef_findDerivedField (/*@notnull@*/ sRef p_rec, cstring p_f);
static /*@exposed@*/ sRef
sRef_getDeriv (/*@notnull@*/ /*@returned@*/ sRef p_set, sRef p_guide);
return;
}
+ /* This sometimes fails: (evans 2001-07-12)
+ if (sRef_isArrayFetch (t))
+ {
+ DPRINTF (("Derived fetch: %s / %s / %s",
+ sRef_unparseFull (s), sRef_unparseFull (t),
+ sRef_unparseFull (t->info->arrayfetch->arr)));
+ llassert (t->info->arrayfetch->arr == s);
+ }
+ */
+
if (sRef_isFileOrGlobalScope (s))
{
if (context_inFunctionLike ()
}
static bool oldInFunction = FALSE;
+static int nestedScope = 0;
void sRef_setGlobalScopeSafe ()
{
- oldInFunction = inFunction;
- DPRINTF (("leave function"));
+ if (nestedScope == 0)
+ {
+ oldInFunction = inFunction;
+ }
+
+ nestedScope++;
+ DPRINTF (("leave function safe"));
inFunction = FALSE;
}
void sRef_clearGlobalScopeSafe ()
{
- inFunction = oldInFunction;
- DPRINTF (("clear function: %s", bool_unparse (inFunction)));
+ nestedScope--;
+ llassert (nestedScope >= 0);
+
+ if (nestedScope == 0)
+ {
+ inFunction = oldInFunction;
+ }
+
+ DPRINTF (("clear function: %s", bool_unparse (inFunction)));
}
void sRef_enterFunctionScope ()
}
void sRef_exitFunctionScope ()
-{
-
+{
if (inFunction)
{
DPRINTF (("Exit function scope."));
case 'p':
return (sRef_makeParam (reader_getInt (c), ctype_unknown));
case 'r':
- return (sRef_makeResultType (ctype_undump (c)));
+ return (sRef_makeResult (ctype_undump (c)));
case 'a':
{
if ((**c >= '0' && **c <= '9') || **c == '-')
** Merge value table states
*/
+
+ /*@i3245@*/
+# if 0
+ /*
+ ** This doesn't do anything. And its broken too...
+ */
+
valueTable_elements (res->state, key, sv)
{
stateValue os = valueTable_lookup (other->state, key);
DPRINTF (("Val: %d / %s", val, msg));
*/
} end_valueTable_elements ;
+# endif
+
}
static sRefSet
return s;
}
-static sRef
-sRef_makeResultType (ctype ct)
-{
- sRef res = sRef_makeResult ();
-
- res->type = ct;
- return res;
-}
-
sRef
-sRef_makeResult ()
+sRef_makeResult (ctype c)
{
sRef s = sRef_newRef ();
s->kind = SK_RESULT;
- s->type = ctype_unknown;
+ s->type = c;
s->defstate = SS_UNKNOWN;
s->aliaskind = AK_UNKNOWN;
sRef_setNullStateN (s, NS_UNKNOWN);
sRef_checkMutable (s);
if (sRef_isInvalid (s)) return;
+ DPRINTF (("Set defined: %s", sRef_unparseFull (s)));
+
if (s->defstate != SS_DEFINED && fileloc_isDefined (loc))
{
s->definfo = stateInfo_updateLoc (s->definfo, loc);
s->defstate = SS_DEFINED;
+ DPRINTF (("Set defined: %s", sRef_unparseFull (s)));
+
/* e.g., if x is allocated, *x = 3 defines x */
if (s->kind == SK_PTR)
{
sRef p = s->info->ref;
-
- if (p->defstate == SS_ALLOCATED)
+ sRef arr;
+
+ if (p->defstate == SS_ALLOCATED
+ || p->defstate == SS_SPECIAL) /* evans 2001-07-12: shouldn't need this */
{
sRef_setDefinedAux (p, loc, clear);
}
+
+ /*
+ ** Defines a[0] also:
+ */
+
+ arr = sRef_findDerivedArrayFetch (p, FALSE, 0, FALSE);
+
+ if (sRef_isValid (arr))
+ {
+ sRef_setDefinedAux (arr, loc, clear);
+ }
}
else if (s->kind == SK_ARRAYFETCH)
{
{
sRef p = s->info->arrayfetch->arr;
sRef ptr = sRef_constructPointer (p);
-
+
if (sRef_isValid (ptr))
{
if (ptr->defstate == SS_ALLOCATED
- || ptr->defstate == SS_UNDEFINED)
+ || ptr->defstate == SS_UNDEFINED
+ || ptr->defstate == SS_SPECIAL) /* evans 2001-07-12: shouldn't need this */
{
sRef_setDefinedAux (ptr, loc, clear);
}
{
;
}
- else if (p->defstate == SS_ALLOCATED || p->defstate == SS_PDEFINED)
+ else if (p->defstate == SS_ALLOCATED || p->defstate == SS_PDEFINED
+ || p->defstate == SS_SPECIAL) /* evans 2001-07-12: shouldn't need this */
{
p->defstate = SS_DEFINED;
}
if (clear)
{
sRef_clearDerived (s);
- }
+ }
+ else
+ {
+ /* evans 2001-07-12: need to define the derived references */
+ sRefSet_elements (s->deriv, el)
+ {
+ el->defstate = SS_DEFINED;
+ } end_sRefSet_elements ;
+ }
+
+ DPRINTF (("Set defined: %s", sRef_unparseFull (s)));
}
static void sRef_setPartialDefined (sRef s, fileloc loc)
void sRef_setDefinedComplete (sRef s, fileloc loc)
{
+ DPRINTF (("Set defined complete: %s", sRef_unparseFull (s)));
sRef_innerAliasSetComplete (sRef_setDefined, s, loc);
}
/*@i43@*/ /* valueTable_free (s->state); */
sinfo_free (s);
- /*@i32@*/ sfree (s);
+
+ /* drl added to help locate use after release*/
+ s->expinfo = stateInfo_undefined;
+ s->aliasinfo = stateInfo_undefined;
+ s->definfo = stateInfo_undefined;
+ s->nullinfo = stateInfo_undefined;
+
+ /*@i32@*/ sfree (s);
}
}
if (sRef_isValid (s))
{
+ /* evans 2001-07-12: this is bogus, clean-up hack */
+ if (s->info->arrayfetch->arr != arr)
+ {
+ sRef res;
+ check (sRefSet_delete (arr->deriv, s));
+ res = sRef_buildArrayFetch (arr);
+ sRef_copyState (res, s);
+ return res;
+ }
+
sRef_setExKind (s, sRef_getExKind (arr), g_currentloc);
return s;
}
if (sRef_isValid (s))
{
+ /* evans 2001-07-12: this is bogus, clean-up hack */
+ if (s->info->arrayfetch->arr != arr)
+ {
+ sRef res;
+ check (sRefSet_delete (arr->deriv, s));
+ res = sRef_buildArrayFetchKnown (arr, i);
+ sRef_copyState (res, s);
+ return res;
+ }
+
sRef_setExKind (s, sRef_getExKind (arr), g_currentloc);
+
+ llassert (s->info->arrayfetch->arr == arr);
return s;
}
else
if (sRef_isValid (s))
{
+ DPRINTF (("Found array fetch: %s", sRef_unparseFull (s)));
return s;
}
else
{
sRef ret = sRef_constructPointer (t);
- /*
- ** This is necessary to prevent infinite depth
- ** in checking complete destruction.
- */
+ DPRINTF (("Constructed pointer: %s", sRef_unparseFull (ret)));
- if (isdead)
- {
- /* ret->defstate = SS_UNKNOWN; */
- return ret;
- }
- else
- {
- return ret;
- }
+ return ret;
}
}
else
/* start modification */
s->bufinfo.bufstate = BB_NULLTERMINATED;
/* end modification */
-
-
if (ctype_isUA (ct))
{
typeId uid = ctype_typeId (ct);
if (stateValue_hasLoc (val))
{
llgenindentmsg
- (message ("Meta state %qbecomes %s", sRef_unparseOpt (s),
- metaStateInfo_unparseValue (minfo, stateValue_getValue (val))),
+ (message ("Meta state %qbecomes %q", sRef_unparseOpt (s),
+ stateValue_unparseValue (val, minfo)),
stateValue_getLoc (val));
}
}
inner = s->info->ref;
aliases = usymtab_allAliases (inner);
ct = sRef_getType (inner);
-
sRefSet_realElements (aliases, current)
{
aliases = usymtab_allAliases (inner);
ct = sRef_getType (inner);
+ DPRINTF (("Array fetch: %s", sRefSet_unparse (aliases)));
+
sRefSet_realElements (aliases, current)
{
if (sRef_isValid (current))
{
current = sRef_updateSref (current);
-
+ DPRINTF (("Current: %s", sRef_unparseFull (current)));
+
if (ctype_equal (ct, sRef_getType (current)))
{
-
if (s->info->arrayfetch->indknown)
{
sRef af = sRef_makeArrayFetchKnown (current, s->info->arrayfetch->ind);
-
+ DPRINTF (("Defining: %s", sRef_unparseFull (af)));
+ llassert (af->info->arrayfetch->arr == current);
((*predf)(af, loc));
}
else
{
sRef af = sRef_makeArrayFetch (current);
-
+ llassert (af->info->arrayfetch->arr == current);
+ DPRINTF (("Defining: %s", sRef_unparseFull (af)));
((*predf)(af, loc));
}
}
+ else
+ {
+ DPRINTF (("Type mismatch: %s / %s",
+ ctype_unparse (ct),
+ ctype_unparse (sRef_getType (current))));
+ }
}
} end_sRefSet_realElements;
{
DPRINTF (("Updating state: %s: %s %d / %s", sRef_unparse (s), key, value,
fileloc_unparse (loc)));
- valueTable_update
- (s->state, key, stateValue_create (value, stateInfo_makeLoc (loc)));
+ if (valueTable_contains (s->state, key))
+ {
+ valueTable_update
+ (s->state, key, stateValue_create (value, stateInfo_makeLoc (loc)));
+ }
+ else
+ {
+ valueTable_insert
+ (s->state, cstring_copy (key), stateValue_create (value, stateInfo_makeLoc (loc)));
+ }
+
DPRINTF (("After: %s", sRef_unparseFull (s)));
}
}
stateValue val;
val = valueTable_lookup (s->state, key);
- llassert (stateValue_isDefined (val));
+ /* Okay if its not defined, just returns stateValue_undefined */
return val;
}
else
return (ctype_getArraySize (c) );
}
-
-
-
-
-
-
-
-