static void refTable_free (/*@only@*/ /*@null@*/ refTable p_x, int p_nentries);
static ctype usymtab_suFieldsType (uentryList p_f, bool p_isStruct) /*@globals globtab@*/ ;
+static void usymtab_freeAux (/*@only@*/ usymtab p_u)
+ /*@globals globtab, utab, filetab@*/
+ /*@modifies p_u@*/ ;
+
extern int usymtab_getCurrentDepth (void) /*@globals utab@*/
{
return utab->lexlevel;
static /*@exposed@*/ /*@dependent@*/ uentry
usymtab_lookupQuietNoAlt (usymtab p_s, cstring p_k);
-static void usymtab_printAllAux (usymtab p_s) /*@modifies g_msgstream@*/ ;
+static void usymtab_printAllAux (usymtab p_s) /*@modifies g_warningstream@*/ ;
static int usymtab_getIndex (/*@notnull@*/ usymtab p_s, cstring p_k);
static /*@exposed@*/ uentry usymtab_fetchIndex (/*@notnull@*/ usymtab p_s, int p_i);
static /*@exposed@*/ uentry
t->mustBreak = FALSE;
t->exitCode = XK_NEVERESCAPE;
-
+
+ DPRINTF (("Create usymtab [%p]", t));
return t;
}
oldtab = usymtab_undefined;
}
+void
+usymtab_destroyMod (void) /*@modifies utab, globtab, filetab@*/ /*@globals killed utab@*/
+{
+ DPRINTF (("Destroy usymtab [%p]: %d", utab, utab->nentries));
+ usymtab_freeAux (utab);
+ utab = usymtab_undefined;
+}
void
usymtab_initGlobalMarker () /*@globals globtab@*/
void
usymtab_initBool ()
{
+ DPRINTF (("Init bool!"));
+
if (context_getFlag (FLG_NOLIB))
{
ctype boolt = ctype_bool;
}
}
- DPRINTF (("Using symtab: %s", usymtab_unparseLocalAux (st)));
-
eindex = usymtab_getIndex (st, ename);
if (eindex != NOT_FOUND)
if (!(st->lexlevel > fileScope || !sRef_modInFunction ()))
{
if (uentry_isDatatype (e) || uentry_isAnyTag (e)
- || uentry_isEnumConstant (e))
+ || uentry_isEnumConstant (e)
+ || uentry_isStatic (e)) /* bug fix from Brian St. Pierre */
{
; /*
** Not a bug. Code like,
return (staticEntry ? USYMIDINVALID : eindex);
}
-# ifndef NOLCL
static void
usymtab_replaceEntryAux (/*@notnull@*/ usymtab st, /*@only@*/ uentry e)
/*@globals globtab@*/ /*@modifies st, e@*/
eindex = usymtab_addEntryAux (st, e, FALSE);
}
}
-# endif
/*@=deparrays@*/
return (uid);
}
-# ifndef NOLCL
usymId
usymtab_supExposedTypeEntry (/*@only@*/ uentry e, bool dodef)
/*@globals globtab, filetab@*/
return (uid);
}
-# endif
ctype
usymtab_supForwardTypeEntry (/*@only@*/ uentry e)
/*@modifies utab, globtab, e@*/
{
sRef old = uentry_getSref (e);
-
if (sRef_isType (old))
{
cstringTable_free (s->htable);
}
- s->htable = cstringTable_create (LLHASHSIZE);
+ s->htable = cstringTable_create (LLAHSHSIZE);
for (i = 0; i < s->nentries; i++)
{
lastekind = KINVALID;
fprintf(fout, ";; Library constraints\n");
+
+ /*drl July 27 added this so that libraries without
+ buffer constraints would be handled correctly.
+ I'm trying to do this without breaking older libraries.
+
+ Splint should still be able to handle libraries without this message.
+ */
+
+
+ fprintf(fout, "start_Buffer_Constraints\n");
+
for (i = 0; i < utab->nentries; i++)
{
uentry thisentry = utab->entries[i];
{
; /* ignore ;-comments */
}
+
+ /*drl July 27 added this so that libraries without
+ buffer constraints would be handled correctly.
+ I'm trying to do this without breaking older libraries*/
+
+ /*check for "optional" start buffer constraints message*/
+
+ if (mstring_equalPrefix (s, "start_Buffer_Constraints"))
+ {
+ (void) fgets (s, MAX_DUMP_LINE_LENGTH, f);
+ }
while (s != NULL && *s != ';')
{
{
if (sRef_hasDerived (uentry_getSref (ue)))
{
- fprintf (g_msgstream, "Derived Global: %s\n", uentry_unparse (ue));
- fprintf (g_msgstream, "sRef: %s\n", sRef_unparseFull (ue->sref));
+ fprintf (g_warningstream, "Derived Global: %s\n", uentry_unparse (ue));
+ fprintf (g_warningstream, "sRef: %s\n", sRef_unparseFull (ue->sref));
}
} end_usymtab_entries ;
{
usymtab t = usymtab_create (US_NORMAL, utab, TRUE);
+ DPRINTF (("Enter function: %s", uentry_unparse (fcn)));
+
if (utab->lexlevel != fileScope)
{
if (utab->lexlevel > fileScope)
} end_globSet_allElements;
DPRINTF (("Globs after: %s", globSet_unparse (uentry_getGlobs (fcn))));
+# ifdef DEBUGSPLINT
+ usymtab_checkAllValid ();
+# endif
}
static void
bool mustReturn = usymtab_mustEscape (utab);
usymtab stab = utab;
+ DPRINTF (("New case!"));
+
/*
** Find last case (or outer switch)
*/
stab = stab->env;
llassert (stab != GLOBAL_ENV);
}
-
- /* ??? */
-
+
while (stab->kind == US_CBRANCH)
{
stab = stab->env;
if (!guardSet_isGuarded (ttab->guards, el)
&& !sRef_isNotNull (sr))
{
+ DPRINTF (("Here! %s / %s",
+ sRef_unparseFull (sr),
+ sRef_unparseFull (el)));
sRef_setDerivNullState (sr, el, NS_DEFNULL);
- }
+ }
}
}
else
{
- }
+ ;
+ }
ue = usymtab_getRefTab (ftab, level, index);
{
sRef sr = uentry_getSref (ue);
-
if (!trueGuard) /* yikes! forgot the ! */
{
sRef_setDerivNullState (sr, el, NS_NOTNULL);
&& !sRef_isNotNull (sr))
{
sRef_setDerivNullState (sr, el, NS_DEFNULL);
- }
+ }
}
}
else
else
{
ctype ct = ctype_realType (uentry_getType (glob));
-
+
DPRINTF (("Check global destroyed: %s", uentry_unparseFull (glob)));
if (ctype_isVisiblySharable (ct))
}
else
{
+ DPRINTF (("Check transfer: %s", uentry_unparseFull (glob)));
transferChecks_globalReturn (glob);
}
}
{
usymtab t = utab->env;
+ DPRINTF (("Quiet exit scope [%p]", utab));
+
if (utab->reftable != NULL)
{
int i;
t->mustBreak = utab->mustBreak;
t->exitCode = utab->exitCode;
+ DPRINTF (("Free level [%p]", utab));
usymtab_freeLevel (utab);
utab = t;
+
+# ifdef DEBUGSPLINT
+ usymtab_checkAllValid ();
+# endif
}
/*
usymtab lctab = usymtab_undefined;
bool mustReturn = exprNode_mustEscape (expr);
- DPRINTF (("Exit scope"));
+ DPRINTF (("Exit scope [%p]", utab));
if (utab->kind == US_CBRANCH)
{
}
if (utab->kind == US_TBRANCH || utab->kind == US_FBRANCH
- || utab->kind == US_CBRANCH || utab->kind == US_SWITCH) {
-
- if (context_inMacro ()) {
- /* evs 2000-07-25 */
- /* Unparseable macro may end inside nested scope. Deal with it. */
-
- llerror (FLG_SYNTAX,
- message ("Problem parsing macro body of %s (unbalanced scopes). "
- "Attempting to recover, recommend /*@notfunction@*/ before "
- "macro definition.",
- context_inFunctionName ()));
-
- while (utab->kind == US_TBRANCH
- || utab->kind == US_FBRANCH
- || utab->kind == US_CBRANCH
- || utab->kind == US_SWITCH)
+ || utab->kind == US_CBRANCH || utab->kind == US_SWITCH)
+ {
+ if (context_inMacro ())
{
- utab = utab->env;
- llassert (utab != GLOBAL_ENV);
- }
- } else {
- llcontbug (message ("exitScope: in branch: %q", usymtab_unparseStack ()));
- /*@-branchstate@*/
- } /*@=branchstate@*/
- }
-
+ /* evs 2000-07-25 */
+ /* Unparseable macro may end inside nested scope. Deal with it. */
+
+ llerror (FLG_SYNTAX,
+ message ("Problem parsing macro body of %s (unbalanced scopes). "
+ "Attempting to recover, recommend /*@notfunction@*/ before "
+ "macro definition.",
+ context_inFunctionName ()));
+
+ while (utab->kind == US_TBRANCH
+ || utab->kind == US_FBRANCH
+ || utab->kind == US_CBRANCH
+ || utab->kind == US_SWITCH)
+ {
+ utab = utab->env;
+ llassert (utab != GLOBAL_ENV);
+ }
+ } else
+ {
+ llcontbug (message ("exitScope: in branch: %q", usymtab_unparseStack ()));
+ /*@-branchstate@*/
+ } /*@=branchstate@*/
+ }
+
/*
** check all variables in scope were used
*/
** NOTE: note for exiting paramsScope, since checkReturn should be
** called first.
*/
-
+
if (!mustReturn && (usymtab_lexicalLevel () > functionScope))
{
/*
uentryList params = context_getParams ();
globSet globs = context_getUsedGlobs ();
-
uentryList_elements (params, ue)
{
uentry_fixupSref (ue);
clearFunctionTypes ();
-
+ DPRINTF (("Fixing up globals: %s", globSet_unparse (globs)));
+
globSet_allElements (globs, el)
{
+ DPRINTF (("Fix: %s", sRef_unparseDebug (el)));
+
if (sRef_isCvar (el))
{
uentry current;
if (uentry_isVariable (current))
{
+ DPRINTF (("Fixup: %s", uentry_unparse (current)));
uentry_fixupSref (current);
}
else
{
+ DPRINTF (("Clear: %s", uentry_getSref (current)));
sRef_clearDerived (uentry_getSref (current));
}
}
+
+ sRef_clearDerived (el); /* evans 2002-03-14 - this is the likely source of many crashes! */
} end_globSet_allElements;
}
/*@i@*/ utab = ctab;
/*@-branchstate@*/ } /*@=branchstate@*/
/*@-globstate@*/
+
+
+# ifdef DEBUGSPLINT
+ usymtab_checkAllValid ();
+# endif
/*@i523@*/ }
/*@=globstate@*/
if (sRef_lexLevel (sr) == functionScope)
{
- int index;
-
- /*@access sRef@*/
- llassert (sr->info != NULL);
- llassert (sr->info->cvar != NULL);
- index = sr->info->cvar->index;
- /*@noaccess sRef@*/
+ int index = sRef_getScopeIndex (sr);
if (index < uentryList_size (context_getParams ()))
{
uentry ue;
DPRINTF (("Here: copying %s", uentry_unparse (current)));
- ue = uentry_copy (current);
+ if (uentry_isNonLocal (current))
+ {
+ ue = uentry_copy (current);
+ }
+ else
+ {
+ ue = uentry_copyNoSave (current);
+ }
+
DPRINTF (("Here: copying %s", uentry_unparse (ue)));
usymtab_addEntryQuiet (ut, ue);
DPRINTF (("Okay..."));
}
else
{
+ llassert (s != NULL); /*@i523 should not need this? */
s = s->env;
}
}
if (uentry_isPriv (ce))
llfatalbug (message ("usymtab_lookup: private: %s", k));
+ DPRINTF (("Lookup global: %s", uentry_unparseFull (ce)));
return ce;
}
/*@globals globtab@*/
{
uentry ce = usymtab_lookupAux (globtab, k);
-
+ DPRINTF (("Lookup global: %s", uentry_unparseFull (ce)));
return ce;
}
if (uentry_isUndefined (ce))
llfatalerror (message ("usymtab_lookup: not found: %s", k));
+ DPRINTF (("Lookup either: %s", uentry_unparseFull (ce)));
return ce;
}
-# ifndef NOLCL
ctype
usymtab_lookupType (cstring k)
/*@globals globtab@*/
return (uentry_getRealType (usymtab_getTypeEntry (uid)));
}
-# endif
ctype
usymtab_lookupAbstractType (cstring k) /*@globals globtab@*/
return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
}
-# ifndef NOLCL
bool
usymtab_existsEither (cstring k)
/*@globals utab@*/
return (uentry_isValid (ce));
}
-# endif
bool
usymtab_existsType (cstring k)
return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
}
-# ifndef NOLCL
bool usymtab_existsVar (cstring k)
/*@globals utab@*/
{
return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)) && (uentry_isVar (ce)));
}
-# endif
/*
** destructors
{
int i;
+ DPRINTF (("Free level [%p]", u));
aliasTable_free (u->aliases);
refTable_free (u->reftable, u->nentries);
{
for (i = 0; i < u->nentries; i++)
{
+ DPRINTF (("Free complete: %d", i));
+ DPRINTF (("Uentry: %s", uentry_unparse (u->entries[i])));
uentry_freeComplete (u->entries[i]);
+ u->entries[i] = uentry_undefined;
}
}
else
for (i = 0; i < u->nentries; i++)
{
uentry_free (u->entries[i]);
+ u->entries[i] = uentry_undefined;
}
}
&& u != filetab)
{
llassert (!cstringTable_isDefined (u->htable));
- sfree (u);
}
-/*@-mustfree@*/
-} /*@=mustfree@*/
+ sfree (u); /* evans 2002-07-12: was inside if */
+ /*:!!mustfree@*/
+} /*!@=mustfree@*/
static void
usymtab_freeAux (/*@only@*/ usymtab u)
{
dbgfree = TRUE;
usymtab_freeAux (utab);
+ utab = usymtab_undefined;
}
static int usymtab_lexicalLevel (void) /*@globals utab@*/
return (utab->lexlevel == functionScope);
}
-# ifndef NOLCL
void
usymtab_replaceEntry (uentry s)
/*@globals utab, globtab@*/
{
usymtab_replaceEntryAux (utab, s);
}
-# endif
bool
usymtab_matchForwardStruct (usymId u1, usymId u2)
usymtab_entries (copy, ue)
{
- if (uentry_isValid (ue))
+ if (uentry_isValid (ue) && !uentry_isGlobalMarker (ue))
{
filelocList uses = uentry_getUses (ue);
int size = filelocList_realSize (uses);
void usymtab_addForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al)
/*@modifies utab@*/
{
+ /* evans 2002-03-3: was sRef_isMeaningful -- but we need to keep aliases for new storage also! */
if (sRef_isMeaningful (s)
&& sRef_isMeaningful (al)
&& !(sRef_isConst (s) || sRef_isConst (al))
}
else
{
- ;
+ DPRINTF (("Not aliasing! %s / %s", sRef_unparseFull (s), sRef_unparseFull (al)));
+ DPRINTF (("meaningful: %d %d", sRef_isMeaningful (s), sRef_isMeaningful (al)));
}
}
+void usymtab_addReallyForceMustAlias (/*@exposed@*/ sRef s, /*@exposed@*/ sRef al)
+ /*@modifies utab@*/
+{
+ utab->aliases = aliasTable_addMustAlias (utab->aliases, s, al);
+}
+
void usymtab_clearAlias (sRef s)
/*@modifies utab, s@*/
{
sRefSet usymtab_allAliases (sRef s)
/*@globals utab@*/
{
- if (sRef_isMeaningful (s))
+ if (sRef_isSomewhatMeaningful (s))
{
sRefSet ret;
/*@only@*/ sRefSet usymtab_canAlias (sRef s)
/*@globals utab@*/
{
- if (sRef_isMeaningful (s))
+ if (sRef_isSomewhatMeaningful (s))
{
sRefSet res = aliasTable_canAlias (utab->aliases, s);
return res;
int depth = 0;
char *ind = mstring_copy (" ");
- fprintf (g_msgstream, "<<< [symbol table] >>>\n");
+ fprintf (g_warningstream, "<<< [symbol table] >>>\n");
while (s != GLOBAL_ENV && s->env != GLOBAL_ENV)
{
ind[depth * 3 + 1] = '\0';
}
- fprintf (g_msgstream, "level: %d (%s)\n", s->lexlevel,
+ fprintf (g_warningstream, "level: %d (%s)\n", s->lexlevel,
cstring_toCharsSafe (tname));
cstring_free (tname);
for (i = 0; i < s->nentries; i++)
{
cstring us = uentry_unparseFull (s->entries[i]);
- fprintf (g_msgstream, "%s\n", cstring_toCharsSafe (us));
+ fprintf (g_warningstream, "%s\n", cstring_toCharsSafe (us));
cstring_free (us);
}
if (s->reftable != NULL && s->nentries > 0)
{
- fprintf (g_msgstream, "\t<< Ref table >>\n");
+ fprintf (g_warningstream, "\t<< Ref table >>\n");
for (i = 0; i < s->nentries; i++)
{
- fprintf (g_msgstream, "\t%s %3d: %d, %d\n", ind, i,
+ fprintf (g_warningstream, "\t%s %3d: %d, %d\n", ind, i,
s->reftable[i]->level,
s->reftable[i]->index);
}
depth++;
s = s->env;
}
- fprintf (g_msgstream, "<<< end usymtab >>>\n");
+ fprintf (g_warningstream, "<<< end usymtab >>>\n");
mstring_free (ind);
return;
}
static void
usymtab_printAllAux (usymtab s)
- /*@modifies g_msgstream@*/
+ /*@modifies g_warningstream@*/
{
int i;
int depth = 0;
for (i = looplow; i < s->nentries; i++)
{
printf ("%s%3d %s\n", ind, i,
- cstring_toCharsSafe (uentry_unparse (s->entries[i])));
+ cstring_toCharsSafe (uentry_unparseFull (s->entries[i])));
}
}
else
for (i = 0; i < s->nentries; i++)
{
printf ("%s%3d %s\n", ind, i,
- cstring_toCharsSafe (uentry_unparse (s->entries[i])));
+ cstring_toCharsSafe (uentry_unparseFull (s->entries[i])));
}
}
static bool checkDistinctExternalName (uentry e)
/*@globals globtab@*/
- /*@modifies *g_msgstream@*/
+ /*@modifies *g_warningstream@*/
{
- int checklen = context_getValue (FLG_EXTERNALNAMELEN);
+ size_t checklen = size_fromInt (context_getValue (FLG_EXTERNALNAMELEN));
bool ignorecase = context_getFlag (FLG_EXTERNALNAMECASEINSENSITIVE);
bool gotone = FALSE;
bool extras = FALSE;
"in the first %d characters (%q)",
uentry_getName (e),
uentry_getName (oe),
- checklen,
+ size_toInt (checklen),
cstring_clip (uentry_getName (e), checklen)),
/*@=sefparams@*/
uentry_whereLast (e)))
"is ignored",
uentry_getName (e),
uentry_getName (oe),
- checklen),
+ size_toInt (checklen)),
uentry_whereLast (e)))
{
uentry_showWhereAny (oe);
"in the first %d characters (%q)",
uentry_getName (e),
uentry_getName (oe),
- checklen,
+ size_toInt (checklen),
cstring_clip (uentry_getName (e), checklen)),
/*@=sefparams@*/
uentry_whereLast (e)))
static bool checkDistinctInternalName (uentry e)
/*@globals utab@*/
- /*@modifies *g_msgstream@*/
+ /*@modifies *g_warningstream@*/
{
usymtab ttab = utab;
cstring name = uentry_rawName (e);
- int numchars = context_getValue (FLG_INTERNALNAMELEN);
+ size_t numchars = size_fromInt (context_getValue (FLG_INTERNALNAMELEN));
bool caseinsensitive = context_getFlag (FLG_INTERNALNAMECASEINSENSITIVE);
bool lookalike = context_getFlag (FLG_INTERNALNAMELOOKALIKE);
"in the first %d characters (%q)",
uentry_getName (e),
uentry_getName (oe),
- numchars,
+ size_toInt (numchars),
cstring_clip (uentry_getName (e), numchars)),
/*@=sefparams@*/
uentry_whereLast (e)))
/*@switchbreak@*/
break;
case CGE_CASE:
- if (numchars == 0
- || (cstring_length (name) <= numchars))
+ if (numchars == 0 || (cstring_length (name) <= numchars))
{
if (optgenerror
(FLG_DISTINCTINTERNALNAMES,
"in the first %d characters without case sensitivity",
uentry_getName (e),
uentry_getName (oe),
- numchars),
+ size_toInt (numchars)),
uentry_whereLast (e)))
{
uentry_showWhereAny (oe);
"in the first %d characters except by lookalike characters",
uentry_getName (e),
uentry_getName (oe),
- numchars),
+ size_toInt (numchars)),
uentry_whereLast (e)))
{
uentry_showWhereAny (oe);
return uentry_getSref (ue);
}
+
+# ifdef DEBUGSPLINT
+/*
+** For debugging only
+*/
+
+void
+usymtab_checkAllValid () /*@globals utab@*/
+{
+ usymtab tab = utab;
+
+ while (tab != GLOBAL_ENV)
+ {
+ int i;
+
+ for (i = 0; i < utab->nentries; i++)
+ {
+ uentry e = utab->entries[i];
+
+ uentry_checkValid (e);
+ }
+
+ aliasTable_checkValid (tab->aliases);
+ tab = tab->env;
+ }
+}
+# endif
+
+
+
+
+
+