]> andersk Git - splint.git/blobdiff - src/usymtab.c
Fixed parsing problem with multiple inclusions of alt typedefs.
[splint.git] / src / usymtab.c
index 52a2f287262529be444f11d86434160812477cfa..cf207a3e0234b5744c14273fc8a8cb905c085966 100644 (file)
@@ -105,6 +105,10 @@ static bool usymtab_isAltDefinitelyNull (sRef p_s) /*@globals utab@*/ ;
 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;
@@ -297,7 +301,8 @@ static /*@notnull@*/ /*@special@*/ usymtab
 
   t->mustBreak = FALSE;
   t->exitCode = XK_NEVERESCAPE;
-  
+
+  DPRINTF (("Create usymtab [%p]", t));
   return t;
 }
 
@@ -339,6 +344,14 @@ usymtab_initMod (void)
   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;
+  /*@-globstate@*/ 
+} /*@=globstate@*/
 
 void
 usymtab_initGlobalMarker () /*@globals globtab@*/
@@ -363,6 +376,8 @@ usymtab_initGlobalMarker () /*@globals globtab@*/
 void
 usymtab_initBool ()
 {
+  DPRINTF (("Init bool!"));
+
   if (context_getFlag (FLG_NOLIB))
     {
       ctype boolt = ctype_bool;
@@ -889,7 +904,8 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
          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,
@@ -1016,7 +1032,6 @@ usymtab_supEntryAux (/*@notnull@*/ usymtab st,
     return (staticEntry ? USYMIDINVALID : eindex);
 }
 
-# ifndef NOLCL
 static void
 usymtab_replaceEntryAux (/*@notnull@*/ usymtab st, /*@only@*/ uentry e)
    /*@globals globtab@*/ /*@modifies st, e@*/
@@ -1045,7 +1060,6 @@ usymtab_replaceEntryAux (/*@notnull@*/ usymtab st, /*@only@*/ uentry e)
       eindex = usymtab_addEntryAux (st, e, FALSE);
     }
 }
-# endif
 
 /*@=deparrays@*/ 
 
@@ -1263,7 +1277,6 @@ usymtab_supAbstractTypeEntry (/*@only@*/ uentry e, bool dodef)
   return (uid);
 }
 
-# ifndef NOLCL
 usymId
 usymtab_supExposedTypeEntry (/*@only@*/ uentry e, bool dodef)
   /*@globals globtab, filetab@*/
@@ -1287,7 +1300,6 @@ usymtab_supExposedTypeEntry (/*@only@*/ uentry e, bool dodef)
 
   return (uid);
 }
-# endif
 
 ctype
 usymtab_supForwardTypeEntry (/*@only@*/ uentry e)
@@ -1798,6 +1810,17 @@ void usymtab_dump (FILE *fout)
   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];
@@ -1989,6 +2012,17 @@ void usymtab_load (FILE *f)
     {
       ; /* 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 != ';')
     {
@@ -4313,6 +4347,8 @@ usymtab_quietExitScope (fileloc loc)
 {
   usymtab t = utab->env;
 
+  DPRINTF (("Quiet exit scope [%p]", utab));
+
   if (utab->reftable != NULL)
     {
       int i;
@@ -4339,6 +4375,7 @@ usymtab_quietExitScope (fileloc loc)
   t->mustBreak = utab->mustBreak;
   t->exitCode = utab->exitCode;
 
+  DPRINTF (("Free level [%p]", utab));
   usymtab_freeLevel (utab);
 
   utab = t;
@@ -4373,7 +4410,7 @@ void usymtab_exitScope (exprNode expr)
   usymtab lctab = usymtab_undefined;
   bool mustReturn = exprNode_mustEscape (expr);
 
-  DPRINTF (("Exit scope"));
+  DPRINTF (("Exit scope [%p]", utab));
 
   if (utab->kind == US_CBRANCH)
     {
@@ -4869,7 +4906,15 @@ usymtab_addRefEntry (/*@notnull@*/ usymtab s, cstring k)
              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..."));
@@ -5056,7 +5101,6 @@ uentry usymtab_lookupEither (cstring k)
   return ce;
 }
 
-# ifndef NOLCL
 ctype
 usymtab_lookupType (cstring k)
    /*@globals globtab@*/
@@ -5071,7 +5115,6 @@ usymtab_lookupType (cstring k)
   
   return (uentry_getRealType (usymtab_getTypeEntry (uid)));
 }
-# endif
 
 ctype
 usymtab_lookupAbstractType (cstring k) /*@globals globtab@*/
@@ -5206,7 +5249,6 @@ bool
   return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
 }
 
-# ifndef NOLCL
 bool
 usymtab_existsEither (cstring k)
   /*@globals utab@*/
@@ -5224,7 +5266,6 @@ bool
   
   return (uentry_isValid (ce));
 }
-# endif
 
 bool
 usymtab_existsType (cstring k)
@@ -5274,7 +5315,6 @@ usymtab_existsEnumTag (cstring k) /*@globals globtab@*/
   return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)));
 }
 
-# ifndef NOLCL
 bool usymtab_existsVar (cstring k)
    /*@globals utab@*/
 {
@@ -5282,7 +5322,6 @@ bool usymtab_existsVar (cstring k)
 
   return (!(uentry_isUndefined (ce)) && !(uentry_isPriv (ce)) && (uentry_isVar (ce)));
 }
-# endif
 
 /*
 ** destructors
@@ -5310,6 +5349,7 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
 {
   int i;
 
+  DPRINTF (("Free level [%p]", u));
   aliasTable_free (u->aliases);
 
   refTable_free (u->reftable, u->nentries);
@@ -5318,7 +5358,10 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
     {
       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
@@ -5326,6 +5369,7 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
       for (i = 0; i < u->nentries; i++)
        {
          uentry_free (u->entries[i]);
+         u->entries[i] = uentry_undefined;
        }
     }
 
@@ -5337,11 +5381,11 @@ usymtab_freeLevel (/*@notnull@*/ /*@only@*/ usymtab u)
       && 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)
@@ -5364,7 +5408,8 @@ void usymtab_free ()
 {
   dbgfree = TRUE;
   usymtab_freeAux (utab);
-}
+  utab = usymtab_undefined;
+/*@i523@*/ }
 
 static int usymtab_lexicalLevel (void) /*@globals utab@*/
 {
@@ -5386,7 +5431,6 @@ bool usymtab_inFunctionScope () /*@globals utab@*/
   return (utab->lexlevel == functionScope);
 }
 
-# ifndef NOLCL
 void
 usymtab_replaceEntry (uentry s)
   /*@globals utab, globtab@*/
@@ -5394,7 +5438,6 @@ usymtab_replaceEntry (uentry s)
 {
   usymtab_replaceEntryAux (utab, s);
 }
-# endif
 
 bool
 usymtab_matchForwardStruct (usymId u1, usymId u2)
This page took 0.0502 seconds and 4 git commands to generate.