]> andersk Git - splint.git/blobdiff - src/usymtab.c
Fixed problem with NULL being changed.
[splint.git] / src / usymtab.c
index bdb71f9e080f5933548ba434b3c82afc3491b17d..1d26d49de9f168f7d634709a2b73acf6e7ee21f4 100644 (file)
@@ -2047,12 +2047,11 @@ void usymtab_load (FILE *f)
     {
       constraintList preconditions;
       constraintList postconditions;
-
-      cstring name = cstring_fromChars(reader_getWord(&s) );
+      cstring name = cstring_fromChars (reader_getWord (&s));
       cstring temp;
-      ue = usymtab_lookup ( name );
 
-      cstring_free(name);
+      ue = usymtab_lookup (name);
+      cstring_free (name);
       
       preconditions = constraintList_undefined;
       postconditions = constraintList_undefined;
@@ -2750,6 +2749,10 @@ usymtab_popAndBranch (exprNode pred, /*@unused@*/ exprNode expr)
        }
     }
 
+  DPRINTF (("Popping and: %s / %s",
+           guardSet_unparse (utab->guards),
+           guardSet_unparse (exprNode_getGuards (pred))));
+
   utab->guards = guardSet_levelUnionFree (utab->guards, 
                                          guardSet_invert (exprNode_getGuards (pred)), 
                                          utab->lexlevel);
@@ -3815,6 +3818,10 @@ checkGlobalReturn (uentry glob, sRef orig)
                    }
                }
              
+             DPRINTF (("Here: %s / %s",
+                       uentry_unparseFull (glob),
+                       sRef_unparseFull (sr)));
+
              if (ctype_isRealPointer (uentry_getType (glob))
                  && sRef_possiblyNull (sr)
                  && !uentry_possiblyNull (glob))
@@ -5039,6 +5046,35 @@ usymtab_lookupQuietNoAlt (usymtab s, cstring k)
   return (usymtab_lookupAux (utab, k));
 }
 
+/*@dependent@*/ /*@observer@*/ uentry
+  usymtab_lookupSafeScope (cstring k, int lexlevel)
+  /*@globals utab@*/
+{
+  /*
+  ** This is necessary to deal with shadowed variables that are referenced
+  ** through aliases inside the shadowed scope.  It would be better if
+  ** lookup could take an sRef as a parameter.
+  */
+
+  usymtab tab = utab;
+
+  while (tab != GLOBAL_ENV && tab->lexlevel > lexlevel) {
+    uentry ret = usymtab_lookupAux (tab, k);
+    
+    if (uentry_isValid (ret)) {
+      sRef sr = uentry_getSref (ret);
+      
+      if (sRef_isCvar (sr) && sRef_lexLevel (sr) > lexlevel) {
+       tab = usymtab_dropEnv (tab);
+      } else {
+       return ret;
+      }
+    }
+  }
+
+  return uentry_undefined;
+}
+
 uentry
   usymtab_lookupExpose (cstring k)
   /*@globals utab@*/
This page took 1.61652 seconds and 4 git commands to generate.