/*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2000 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2003 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 more information: http://lclint.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
*/
/*
** uentryList.c (from slist_template.c)
*/
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
# include "basic.h"
/*@only@*/ /*@notnull@*/ uentryList
{
if (!ctype_genMatch (uentry_getType (p1->elements[i]),
uentry_getType (p2->elements[i]),
- force, arg, FALSE))
+ force, arg, FALSE, FALSE))
{
return FALSE;
}
if (uentryList_size (p) == 0)
return cstring_makeLiteral ("void");
- for (i = 0; i < p->nelements && i < PRINTBREADTH; i++)
+ for (i = 0; i < p->nelements && i < uentryList_abbrevBreadth; i++)
{
if (first)
{
uentryList uentryList_copy (uentryList s)
{
-
if (uentryList_isDefined (s))
{
uentryList t = (uentryList) dmalloc (sizeof (*t));
for (i = 0; i < s->nelements; i++)
{
- t->elements[i] = uentry_copy (s->elements[i]);
- }
+ t->elements[i] = uentry_copy (s->elements[i]);
+ }
}
else
{
t->elements = NULL;
}
-
+
return t;
}
else
void
uentryList_free (uentryList s)
{
-
if (!uentryList_isUndefined (s))
{
int i;
}
}
+void
+uentryList_freeShallow (uentryList s)
+{
+ if (!uentryList_isUndefined (s))
+ {
+ /*@-mustfree@*/ /* free shallow does not free the element */
+ sfree (s->elements);
+ /*@=mustfree@*/
+ sfree (s);
+ }
+}
+
bool
uentryList_isVoid (uentryList cl)
{
if (cl != NULL && cl->nelements == 1)
{
- return (ctype_isVoid (uentry_getType (cl->elements[0])));
+ return (ctype_isVoid (ctype_realType (uentry_getType (cl->elements[0]))));
}
+
return FALSE;
}
if (uc != 0)
{
+ DPRINTF (("Bad compare: %s / %s",
+ uentry_unparseFull (s->elements [i]),
+ uentry_unparseFull (t->elements [i])));
+
return uc;
}
}
uentryList_elements (s, current)
{
+ DPRINTF (("Dump param: %s", uentry_unparse (current)));
st = message ("%q%q,", st, uentry_dumpParam (current));
} end_uentryList_elements;
if (!uentry_isVariable (current))
{
llassert (uentry_isFunction (current));
+ DPRINTF (("Dump field: %s", uentry_unparse (current)));
st = message ("%q!%q,", st, uentry_dump (current));
}
else
{
+ DPRINTF (("Dump field: %s", uentry_unparse (current)));
st = message ("%q%q,", st, uentry_dump (current));
}
} end_uentryList_elements;
{
if (**s == '!')
{
- checkChar (s, '!');
+ reader_checkChar (s, '!');
ul = uentryList_add (ul, uentry_undump (ekind_function, loc, s));
}
else
{
ul = uentryList_add (ul, uentry_undump (ekind_variable, loc, s));
}
- checkChar (s, ',');
+ reader_checkChar (s, ',');
}
- checkChar (s, '}');
+ reader_checkChar (s, '}');
return ul;
}
uentry_free (ue);
}
- checkChar (s, ',');
+ reader_checkChar (s, ',');
c = **s;
paramno++;
}
- checkChar (s, ')');
+ reader_checkChar (s, ')');
return pn;
}
{
if (uentryList_isUndefined (s)) return 0;
- if (s->nelements == 1 && ctype_isVoid (uentry_getType (s->elements[0])))
+ if (uentryList_isVoid (s))
return 0;
return s->nelements;
}
else
{
+ uentryList_elements (f, el)
+ {
+ if (uentry_isUnnamedVariable (el))
+ {
+ ctype ct = uentry_getType (el);
+
+ if (ctype_isStruct (ct) || ctype_isUnion (ct))
+ {
+ uentryList fields = ctype_getFields (ct);
+ uentry ue = uentryList_lookupField (fields, name);
+
+ if (uentry_isValid (ue))
+ {
+ return ue;
+ }
+ }
+ }
+ }
+ end_uentryList_elements ;
+
return uentry_undefined;
}
}
/*@only@*/ uentryList
uentryList_mergeFields (/*@only@*/ uentryList f1, /*@only@*/ uentryList f2)
{
+ DPRINTF (("Merge: %s + %s", uentryList_unparse (f1), uentryList_unparse (f2)));
+
if (uentryList_isUndefined (f1))
{
return (f2);
}
else
{
- if (!ctype_match (uentry_getType (cp1), uentry_getType (cp2)))
+ /* evs 2000-07-25 was ctype_match, should match uentryList_matchFields */
+
+ if (!ctype_almostEqual (uentry_getType (cp1), uentry_getType (cp2)))
{
llgenindentmsg
(message ("Field %s %rdeclared as %s, %s as %s",
uentryList_unparse (p1), uentryList_unparse (p2)));
}
+bool
+uentryList_equivFields (uentryList p1, uentryList p2)
+{
+ return (uentryList_compareFields (p1, p2) == 0);
+}
+
bool
uentryList_matchFields (uentryList p1, uentryList p2)
{
cp1 = p1->elements[index];
cp2 = p2->elements[index];
+ /*
+ ** Should compare uentry's --- need to fix report errors too.
+ */
+
if (!(cstring_equal (uentry_rawName (cp1), uentry_rawName (cp2))
&& (ctype_almostEqual (uentry_getType (cp1), uentry_getType (cp2)))))
- { /* was ctype_match! */
+ {
return FALSE;
}
}
return TRUE;
}
-