]> andersk Git - splint.git/blobdiff - src/uentryList.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / uentryList.c
index 9979d06ed7a6bd049632855d9b3a79162c3aeb10..eca84f0b7f097b570b9935d1da3b9191c8e4cc97 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** 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
@@ -207,7 +207,7 @@ bool uentryList_matchParams (uentryList p1, uentryList p2, bool force, bool arg)
     {
       if (!ctype_genMatch (uentry_getType (p1->elements[i]), 
                           uentry_getType (p2->elements[i]), 
-                          force, arg, FALSE))
+                          force, arg, FALSE, FALSE))
        {
          return FALSE;
        }
@@ -229,7 +229,7 @@ uentryList_unparseAbbrev (uentryList p)
   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)
        {
@@ -293,7 +293,6 @@ uentryList_lookupRealName (uentryList s, cstring name)
 
 uentryList uentryList_copy (uentryList s)
 {
-  
   if (uentryList_isDefined (s))
     {
       uentryList t = (uentryList) dmalloc (sizeof (*t));
@@ -309,14 +308,14 @@ uentryList uentryList_copy (uentryList s)
          
          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
@@ -328,7 +327,6 @@ uentryList uentryList_copy (uentryList s)
 void
 uentryList_free (uentryList s)
 {
-  
   if (!uentryList_isUndefined (s)) 
     {
       int i;
@@ -343,13 +341,26 @@ uentryList_free (uentryList s)
     }
 }
 
+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;
 }
 
@@ -517,6 +528,10 @@ uentryList_compareFields (uentryList s, uentryList t)
          
          if (uc != 0) 
            { 
+             DPRINTF (("Bad compare: %s / %s",
+                       uentry_unparseFull (s->elements [i]),
+                       uentry_unparseFull (t->elements [i])));
+
              return uc; 
            }
        }
@@ -546,6 +561,7 @@ uentryList_dumpParams (uentryList s)
   
   uentryList_elements (s, current)
     {
+      DPRINTF (("Dump param: %s", uentry_unparse (current)));
       st = message ("%q%q,", st, uentry_dumpParam (current));
   } end_uentryList_elements;
 
@@ -564,10 +580,12 @@ uentryList_dumpFields (uentryList s)
     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;
@@ -584,17 +602,17 @@ uentryList_undumpFields (char **s, fileloc loc)
     {
       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;
 }
 
@@ -621,12 +639,12 @@ uentryList_undump (char **s)
          uentry_free (ue);
        }
 
-      checkChar (s, ',');
+      reader_checkChar (s, ',');
       c = **s;
       paramno++;
     }
 
-  checkChar (s, ')');
+  reader_checkChar (s, ')');
   return pn;
 }
 
@@ -662,7 +680,7 @@ uentryList_size (uentryList s)
 {
   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;
@@ -695,6 +713,26 @@ uentryList_lookupField (uentryList f, cstring name)
     }
   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;
     }
 }
@@ -702,6 +740,8 @@ uentryList_lookupField (uentryList f, cstring name)
 /*@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);
@@ -778,7 +818,9 @@ uentryList_showFieldDifference (uentryList p1, uentryList p2)
        }
       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",
@@ -810,6 +852,12 @@ uentryList_showFieldDifference (uentryList p1, uentryList p2)
                  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)
 {
@@ -836,13 +884,16 @@ 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;
 }
-
This page took 0.04537 seconds and 4 git commands to generate.