]> andersk Git - splint.git/blobdiff - src/context.c
Removed obsolete OS/2 test makefiles.
[splint.git] / src / context.c
index 07de91c98f02c5981eb52bc2a3b45bcb4ddb7007..0f1906b921bdf4f761bf2dbe48ac5e86f4f5b28e 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
  */
 
 # include "splintMacros.nf"
-# include "llbasic.h"
+# include "basic.h"
 
-# ifndef NOLCL
 # include "usymtab_interface.h"
-# endif
-
 # include "exprChecks.h"
 # include "filelocStack.h"
-# include "fileIdList.h"
 # include "llmain.h"
 # include "intSet.h"
 # include "osd.h"
-# include "portab.h"
 
 extern /*@external@*/ int yydebug;
 extern /*@external@*/ int mtdebug;
@@ -54,7 +49,7 @@ extern /*@external@*/ int mtdebug;
 typedef struct
 { 
   cstring file; 
-  typeIdSet daccess 
+  typeIdSet daccess; 
 } maccesst;
 
 typedef enum { 
@@ -107,6 +102,7 @@ static struct
   clause inclause;
 
   int numerrors;
+  int numbugs;
 
   filelocStack locstack;
   fileTable ftab;
@@ -147,7 +143,7 @@ static struct
   int counters[NUMVALUEFLAGS];
 
   o_cstring strings[NUMSTRINGFLAGS];
-  sRefSetList modrecs; /*@i32 ???? what is this for? */
+  sRefSetList modrecs; /* Keep track of file static symbols modified. */
 
   metaStateTable stateTable; /* User-defined state information. */
   annotationTable annotTable; /* User-defined annotations table. */
@@ -344,7 +340,7 @@ context_suppressFlagMsg (flagcode flag, fileloc fl)
       return (!context_getFlag (flag)
              || context_inSuppressRegion ()
              || context_inSuppressZone (fl)
-             || (/*@!@@#@ gc.inDerivedFile && */ context_inSuppressFlagZone (fl, flag)));
+             || (context_inSuppressFlagZone (fl, flag))); /* removed gc.inDerivedFile from this */
     }
   else
     {
@@ -477,14 +473,12 @@ context_exitMTfile (void)
   gc.kind = CX_GLOBAL;
 }
 
-# ifndef NOLCL
 void
 context_enterLCLfile (void)
 {
   gc.kind = CX_LCL;
   gc.facct = typeIdSet_emptySet ();
 }
-# endif
 
 static void
 addModuleAccess (/*@only@*/ cstring fname, typeIdSet mods)
@@ -541,7 +535,6 @@ insertModuleAccess (cstring fname, typeId t)
     addModuleAccess (cstring_copy (fname), typeIdSet_single (t));
 }
 
-# ifndef NOLCL
 void
 context_exitLCLfile (void)
 {
@@ -558,7 +551,6 @@ context_exitLCLfile (void)
   gc.kind = CX_GLOBAL;
   gc.facct = typeIdSet_emptySet ();
 }
-# endif
 
 void
 context_dumpModuleAccess (FILE *fout)
@@ -734,6 +726,8 @@ context_resetAllFlags (void)
              val = DEFAULT_LINELEN; break;
            case FLG_INDENTSPACES: 
              val = DEFAULT_INDENTSPACES; break;
+           case FLG_LOCINDENTSPACES: 
+             val = DEFAULT_LOCINDENTSPACES; break;
            case FLG_EXTERNALNAMELEN:
              val = ISO99_EXTERNALNAMELEN; break;
            case FLG_INTERNALNAMELEN:
@@ -814,9 +808,9 @@ context_resetAllFlags (void)
            case FLG_BOOLTYPE:
              val = cstring_makeLiteral (DEFAULT_BOOLTYPE); break;
            case FLG_BOOLFALSE:
-             val = cstring_makeLiteral ("FALSE"); break;
+             val = cstring_makeLiteral ("false"); break;
            case FLG_BOOLTRUE:
-             val = cstring_makeLiteral ("TRUE"); break;
+             val = cstring_makeLiteral ("true"); break;
            case FLG_MACROVARPREFIX: 
              val = cstring_makeLiteral ("m_"); break;
            case FLG_SYSTEMDIRS:
@@ -837,10 +831,9 @@ context_resetAllFlags (void)
   ** These flags are true by default.
   */
 
-  /*@i34 move this into flags.def */
+  /* eventually, move this into flags.def */
     
   gc.flags[FLG_STREAMOVERWRITE] = TRUE;
-
   gc.flags[FLG_OBVIOUSLOOPEXEC] = TRUE;
   gc.flags[FLG_MODIFIES] = TRUE;
   gc.flags[FLG_NESTCOMMENT] = TRUE;
@@ -848,6 +841,7 @@ context_resetAllFlags (void)
   gc.flags[FLG_FULLINITBLOCK] = TRUE;
   gc.flags[FLG_INITSIZE] = TRUE;
   gc.flags[FLG_INITALLELEMENTS] = TRUE;
+  gc.flags[FLG_NULLINIT] = TRUE;
 
   gc.flags[FLG_STRINGLITTOOLONG] = TRUE;
 
@@ -890,9 +884,10 @@ context_resetAllFlags (void)
   gc.flags[FLG_WARNFLAGS] = TRUE;
   gc.flags[FLG_WARNRC] = TRUE;
   gc.flags[FLG_FILEEXTENSIONS] = TRUE;
-  gc.flags[FLG_WARNUNIXLIB] = TRUE;
+  gc.flags[FLG_WARNUNIXLIB] = FALSE;
   gc.flags[FLG_WARNPOSIX] = TRUE;
   gc.flags[FLG_SHOWCOL] = TRUE;
+  gc.flags[FLG_SHOWDEEPHISTORY] = FALSE; /* TRUE; */
   gc.flags[FLG_SHOWFUNC] = TRUE;
   gc.flags[FLG_SUPCOUNTS] = TRUE;
   gc.flags[FLG_HINTS] = TRUE;
@@ -900,6 +895,7 @@ context_resetAllFlags (void)
   gc.flags[FLG_TYPE] = TRUE;
   gc.flags[FLG_INCOMPLETETYPE] = TRUE;
   gc.flags[FLG_ABSTRACT] = TRUE;
+  gc.flags[FLG_NUMABSTRACT] = TRUE;
   gc.flags[FLG_ITERBALANCE] = TRUE;
   gc.flags[FLG_ITERYIELD] = TRUE;
   gc.flags[FLG_DUPLICATECASES] = TRUE;
@@ -928,7 +924,7 @@ context_resetAllFlags (void)
    */
 
   /* commenting ou until some output issues are fixed */
-  /* gc.flags[FLG_ORCONSTRAINT] = TRUE;*/
+  gc.flags[FLG_ORCONSTRAINT] = TRUE; 
   
   gc.flags[FLG_CONSTRAINTLOCATION] = TRUE;
 
@@ -936,11 +932,12 @@ context_resetAllFlags (void)
   gc.flags[FLG_WARNSYSFILES] = TRUE;
 
   /*
-  ** On by default for Win32, but not Unix (to support MS/VC++ error message format).
+  ** On by default for Win32, but not Unix
   */
 
-# ifdef WIN32
+# if defined (WIN32) || defined (OS2)
   gc.flags[FLG_PARENFILEFORMAT] = TRUE;
+  gc.flags[FLG_CASEINSENSITIVEFILENAMES] = TRUE;
 # endif
 }
 
@@ -1034,7 +1031,8 @@ context_setModeAux (cstring s, bool warn)
       flagcode modeflags[] = 
        {
          FLG_ENUMINT, FLG_MACROMATCHNAME,
-         FLG_STRINGLITNOROOM,
+         FLG_STRINGLITNOROOM, 
+         FLG_STRINGLITNOROOMFINALNULL,
          FLG_MACROUNDEF, FLG_RELAXQUALS, 
          FLG_USEALLGLOBS, FLG_CHECKSTRICTGLOBALS,
          FLG_CHECKSTRICTGLOBALIAS,
@@ -1044,9 +1042,10 @@ context_setModeAux (cstring s, bool warn)
          FLG_UNSIGNEDCOMPARE,
          FLG_PARAMUNUSED, FLG_VARUNUSED, FLG_FUNCUNUSED, 
          FLG_TYPEUNUSED,
+         FLG_ABSTRACTCOMPARE,
          FLG_CONSTUNUSED, FLG_ENUMMEMUNUSED, FLG_FIELDUNUSED,
          FLG_PTRNUMCOMPARE, FLG_BOOLCOMPARE, FLG_UNSIGNEDCOMPARE,
-         FLG_MUTREP, FLG_NOEFFECT, FLG_IMPTYPE,
+         FLG_MUTREP, FLG_NOEFFECT, FLG_IMPTYPE, 
          FLG_RETVALOTHER, FLG_RETVALBOOL, FLG_RETVALINT,
          FLG_SPECUNDEF, FLG_INCONDEFS, FLG_INCONDEFSLIB, FLG_MISPLACEDSHAREQUAL,
          FLG_MATCHFIELDS,
@@ -1061,10 +1060,12 @@ context_setModeAux (cstring s, bool warn)
          FLG_NESTEDEXTERN, 
          FLG_NUMLITERAL,
          FLG_ZEROBOOL,
+
          /* memchecks flags */
          FLG_NULLDEREF, 
          FLG_NULLSTATE, FLG_NULLASSIGN,
          FLG_NULLPASS, FLG_NULLRET,        
+         FLG_ALLOCMISMATCH,
 
          FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF,
          FLG_RETSTACK,
@@ -1085,7 +1086,7 @@ context_setModeAux (cstring s, bool warn)
          FLG_UNKNOWNTRANS,
          FLG_KEEPTRANS,
          FLG_IMMEDIATETRANS,
-
+         FLG_NUMABSTRACTCAST,
          FLG_EXPORTLOCAL,
 
          FLG_USERELEASED, FLG_ALIASUNIQUE, FLG_MAYALIASUNIQUE,
@@ -1115,11 +1116,12 @@ context_setModeAux (cstring s, bool warn)
     {
       flagcode modeflags[] = 
        { 
-         FLG_BOOLINT, FLG_CHARINT, FLG_FLOATDOUBLE,
+         FLG_BOOLINT, FLG_CHARINT, FLG_FLOATDOUBLE, FLG_LONGINT, FLG_SHORTINT,
          FLG_ENUMINT, FLG_RELAXQUALS, FLG_FORWARDDECL, 
-         FLG_CHARINDEX, FLG_ABSTVOIDP, FLG_USEALLGLOBS, 
+         FLG_CHARINDEX, FLG_NUMABSTRACTINDEX, FLG_ABSTVOIDP, FLG_USEALLGLOBS, 
          FLG_CHARUNSIGNEDCHAR,
          FLG_PREDBOOLOTHERS, 
+         FLG_NUMABSTRACTLIT,
           FLG_VARUNUSED, FLG_FUNCUNUSED, 
          FLG_TYPEUNUSED,
           FLG_CHECKSTRICTGLOBALS, FLG_MACROMATCHNAME,
@@ -1134,6 +1136,8 @@ context_setModeAux (cstring s, bool warn)
          FLG_CHARINTLITERAL,
          FLG_ZEROBOOL,
          FLG_BUFFEROVERFLOWHIGH,
+         FLG_STRINGLITNOROOM,
+         FLG_STRINGLITNOROOMFINALNULL,
          INVALID_FLAG 
          } ;
 
@@ -1143,7 +1147,9 @@ context_setModeAux (cstring s, bool warn)
     {
       flagcode modeflags[] = 
        { 
-         FLG_EXPORTLOCAL, FLG_IMPTYPE,
+         FLG_EXPORTLOCAL, FLG_IMPTYPE, 
+         FLG_NUMABSTRACTCAST,
+         FLG_ABSTRACTCOMPARE,
          FLG_STATETRANSFER, FLG_STATEMERGE,
          FLG_CHECKSTRICTGLOBALIAS,
          FLG_CHECKEDGLOBALIAS,
@@ -1167,6 +1173,7 @@ context_setModeAux (cstring s, bool warn)
          FLG_SPECUNDEF, FLG_IMPCHECKMODINTERNALS,
          FLG_DECLUNDEF, FLG_INCONDEFS, FLG_INCONDEFSLIB, 
          FLG_MISPLACEDSHAREQUAL, FLG_REDUNDANTSHAREQUAL,
+         FLG_NUMABSTRACTPRINT,
          FLG_MATCHFIELDS, 
          FLG_MACROPARAMS,
          FLG_MACROASSIGN,
@@ -1191,6 +1198,7 @@ context_setModeAux (cstring s, bool warn)
 
          FLG_NULLSTATE, FLG_NULLDEREF, FLG_NULLASSIGN,
          FLG_NULLPASS, FLG_NULLRET,
+         FLG_ALLOCMISMATCH,
 
          FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF, FLG_RETSTACK,       
 
@@ -1239,13 +1247,16 @@ context_setModeAux (cstring s, bool warn)
     {
       flagcode modeflags[] = 
        { 
-         FLG_CHECKSTRICTGLOBALIAS,
+         FLG_ABSTRACTCOMPARE,
+         FLG_CHECKSTRICTGLOBALIAS, 
+         FLG_NUMABSTRACTCAST,
          FLG_CHECKEDGLOBALIAS,
          FLG_CHECKMODGLOBALIAS,
          FLG_UNCHECKEDGLOBALIAS,
          FLG_MODFILESYSTEM,
          FLG_MACROMATCHNAME,
          FLG_FORMATCONST,
+         FLG_NUMABSTRACTPRINT,
          FLG_STRINGLITNOROOM,
          FLG_STRINGLITNOROOMFINALNULL,
          FLG_STRINGLITSMALLER,
@@ -1304,9 +1315,14 @@ context_setModeAux (cstring s, bool warn)
          /* memchecks flags */
          FLG_NULLSTATE, FLG_NULLDEREF, FLG_NULLASSIGN,
          FLG_NULLPASS, FLG_NULLRET,
-
+         FLG_ALLOCMISMATCH,
          FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF,
 
+         /* memory checking flags */
+         FLG_BOUNDSREAD, FLG_BOUNDSWRITE,
+         FLG_LIKELYBOUNDSREAD, FLG_LIKELYBOUNDSWRITE,
+         FLG_CHECKPOST, 
+
          /* memtrans flags */
          FLG_EXPOSETRANS,
          FLG_OBSERVERTRANS,
@@ -1563,7 +1579,7 @@ context_enterUnknownMacro (/*@dependent@*/ uentry e)
 
 void context_enterAndClause (exprNode e)
 {
-  
+  DPRINTF (("enter and clause: %s", exprNode_unparse (e)));
   usymtab_trueBranch (guardSet_copy (exprNode_getGuards (e)));
   pushClause (ANDCLAUSE);
 }
@@ -1879,12 +1895,9 @@ context_enterFunction (/*@exposed@*/ uentry e)
   sRef_enterFunctionScope ();
 }
 
-bool context_inOldSytleScope(void)
+bool context_inOldStyleScope(void)
 {
-  if (gc.kind == CX_OLDSTYLESCOPE)
-    return TRUE;
-  else
-    return FALSE;
+  return (gc.kind == CX_OLDSTYLESCOPE);
 }
 
 void
@@ -2295,8 +2308,7 @@ static
 void context_exitClauseAux (exprNode pred, exprNode tbranch)
 {
   context_setJustPopped ();
-  /*@i32 was makeAlt */
-  usymtab_popTrueBranch (pred, tbranch, gc.inclause);
+  usymtab_popTrueBranch (pred, tbranch, gc.inclause); /* evans 2003-02-02?: was makeAlt */
   clauseStack_pop (gc.clauses);
   gc.inclause = topClause (gc.clauses);
 }
@@ -2955,7 +2967,7 @@ context_setString (flagcode flag, cstring val)
            
            if (cstring_lastChar (tval) != '\"')
              {
-               int n = cstring_length (tval) - 1;
+               int n = size_toInt (cstring_length (tval) - 1);
                
                while (isspace ((int) cstring_getChar (tval, size_fromInt (n))))
                  {
@@ -3006,13 +3018,15 @@ context_setString (flagcode flag, cstring val)
       {
        ; /* Okay not handle everything in this switch */
       }
-    }
-  
+      /*@-branchstate@*/
+    } /* evans 2002-03-24: splintme reports a spurious (I think) warning here...need to look into it */
+  /*@=branchstate@*/ 
+
   if (cstring_length (val) >= 1
       && cstring_firstChar (val) == '\"')
     {
       llerror_flagWarning (message
-                          ("setting %s to string beginning with \".  You probably "
+                          ("Setting %s to string beginning with \".  You probably "
                            "don't meant to have the \"'s.",
                            flagcode_unparse (flag)));
     }
@@ -3041,6 +3055,18 @@ context_resetErrors (void)
   gc.numerrors = 0;
 }
 
+void
+context_recordBug (void)
+{
+  gc.numbugs++;
+}
+
+int
+context_numBugs (void)
+{
+  return gc.numbugs;
+}
+
 void context_initMod (void)
    /*@globals undef gc; @*/
 {
@@ -3051,6 +3077,7 @@ void context_initMod (void)
 
   gc.instandardlib = FALSE;
   gc.numerrors = 0;
+  gc.numbugs = 0;
   gc.neednl = FALSE;
   gc.linesprocessed = 0;
   gc.speclinesprocessed = 0;
@@ -3107,7 +3134,6 @@ void context_initMod (void)
   end_allFlagCodes ;
   
   usymtab_initMod ();
-
   context_resetAllFlags ();
 
   assertSet (gc.flags); /* Can't use global in defines */
@@ -3688,7 +3714,9 @@ context_inFunctionName (void)
 void
 context_userSetFlag (flagcode f, bool b)
 {
-  DPRINTF (("set flag: %s", flagcode_unparse (f)));
+  DPRINTF (("set flag: %s / %s", 
+           flagcode_unparse (f),
+           bool_unparse (context_getFlag (f))));
 
   if (f == FLG_NEVERINCLUDE && b)
     {
@@ -3696,7 +3724,7 @@ context_userSetFlag (flagcode f, bool b)
        {
          llerror_flagWarning 
            (cstring_makeLiteral
-            ("setting +neverinclude after +exportheader.  "
+            ("Setting +neverinclude after +exportheader.  "
              "Turning off exportheader, since headers are not checked "
              "when +neverinclude is used."));
 
@@ -3711,7 +3739,7 @@ context_userSetFlag (flagcode f, bool b)
            {
              llerror_flagWarning
                (cstring_makeLiteral
-                ("setting +exportheader after +neverinclude.  "
+                ("Setting +exportheader after +neverinclude.  "
                  "Not setting exportheader, since headers are not checked "
                  "when +neverinclude is used."));
              gc.flags[FLG_EXPORTHEADER] = FALSE;
@@ -3730,7 +3758,7 @@ context_userSetFlag (flagcode f, bool b)
          && !flagcode_hasArgument (f))
        {
          llerror_flagWarning 
-           (message ("setting %s%s redundant with current value", 
+           (message ("Setting %s%s redundant with current value", 
                      cstring_makeLiteralTemp (b ? "+" : "-"),
                      flagcode_unparse (f)));
        }
@@ -3741,7 +3769,7 @@ context_userSetFlag (flagcode f, bool b)
       if (!context_getFlag (FLG_WARNUSE))
        {
          llerror_flagWarning
-           (message ("flag +%s is canceled by -warnuse",
+           (message ("Flag +%s is canceled by -warnuse",
                      flagcode_unparse (f)));
        }
     }
@@ -3753,7 +3781,7 @@ context_userSetFlag (flagcode f, bool b)
          && gc.library != f)
        {
          llerror_flagWarning 
-           (message ("selecting library %s after library %s was "
+           (message ("Selecting library %s after library %s was "
                      "selected (only one library may be used)",
                      flagcode_unparse (f),
                      flagcode_unparse (gc.library)));
@@ -3765,9 +3793,9 @@ context_userSetFlag (flagcode f, bool b)
            {
              llerror_flagWarning
                (cstring_makeLiteral
-                ("selecting unix library.  Unix library is "
-                 "ad hoc addition to POSIX library.  Recommend "
-                 "use +posixlib to select POSIX library instead. "
+                ("Selecting unix library.  Unix library is "
+                 "based on the Single Unix Specification, Version 2.  Not all "
+                 "Unix implementations are consistend with this specification. "
                  "Use -warnunixlib to suppress this message."));
            }
        }
@@ -3779,7 +3807,7 @@ context_userSetFlag (flagcode f, bool b)
     {
       llerror_flagWarning
        (message
-        ("setting +%s will not produce warnings with -namechecks. "
+        ("Setting +%s will not produce warnings with -namechecks. "
          "Must set +namechecks also.",
          flagcode_unparse (f)));
     }
@@ -4122,11 +4150,24 @@ context_setFlagAux (flagcode f, bool b, bool inFile,
       DOSET (FLG_ALLMACROS, b);
       DOSET (FLG_FCNMACROS, b);
       DOSET (FLG_CONSTMACROS, b);
-      break;
+      break;      
     case FLG_BOUNDS:
       DOSET (FLG_BOUNDSREAD, b);
       DOSET (FLG_BOUNDSWRITE, b);
+      DOSET (FLG_LIKELYBOUNDSREAD, b);
+      DOSET (FLG_LIKELYBOUNDSWRITE, b);
+      break;
+    case FLG_BOUNDSREAD:
+      DOSET (FLG_LIKELYBOUNDSREAD, b);
       break;
+    case FLG_BOUNDSWRITE:
+      DOSET (FLG_LIKELYBOUNDSWRITE, b);
+      break;
+    case FLG_LIKELYBOUNDS:
+      DOSET (FLG_LIKELYBOUNDSREAD, b);
+      DOSET (FLG_LIKELYBOUNDSWRITE, b);
+      break;
+      
     case FLG_CZECH:
       if (b) { DOSET (FLG_ACCESSCZECH, b); }
       DOSET (FLG_CZECHFUNCTIONS, b);
@@ -4312,17 +4353,29 @@ void
 context_destroyMod (void) 
    /*@globals killed gc@*/
 {
+  int i;
   setCodePoint ();
   ctype_destroyMod ();
+  /*
   setCodePoint ();
   usymtab_free ();
   setCodePoint ();
+  */
+
   fileTable_free (gc.ftab);
+  gc.ftab = fileTable_undefined;
+
   filelocStack_free (gc.locstack);
   setCodePoint ();
-  gc.ftab = fileTable_undefined;
 
   macrocache_free (gc.mc);
+
+  /* evans 2002-07-12: not reported because of reldef */
+  for (i = 0; i < gc.nmods; i++)
+    {
+      cstring_free (gc.moduleaccess[i].file);
+    }
+
   sfree (gc.moduleaccess);
   setCodePoint ();
 
@@ -4346,40 +4399,48 @@ context_destroyMod (void)
 }
 
 /*
-** Flag shortcuts.
+** Flag shortcuts
 */
 
 bool context_msgBoolInt (void)
 {
-  return gc.flags [FLG_BOOLINT];
+  return context_flagOn (FLG_BOOLINT, g_currentloc);
 }
 
 bool context_msgCharInt (void)
 {
-  return gc.flags [FLG_CHARINT];
+  return context_flagOn (FLG_CHARINT, g_currentloc);
 }
 
 bool context_msgEnumInt (void)
 {
-  return gc.flags [FLG_ENUMINT];
+  return context_flagOn (FLG_ENUMINT, g_currentloc);
+}
+
+bool context_msgLongInt (void)
+{
+  return context_flagOn (FLG_LONGINT, g_currentloc);
+}
+
+bool context_msgShortInt (void)
+{
+  return context_flagOn (FLG_SHORTINT, g_currentloc);
 }
 
 bool context_msgPointerArith (void) 
 {
-  return gc.flags [FLG_POINTERARITH];
+  return context_flagOn (FLG_POINTERARITH, g_currentloc);
 }
 
 bool context_msgStrictOps (void) 
 {
-  return gc.flags [FLG_STRICTOPS];
+  return context_flagOn (FLG_STRICTOPS, g_currentloc);
 }
 
-# ifndef NOLCL
 bool context_msgLh (void)           
 {
   return gc.flags [FLG_DOLH];
 }
-# endif
 
 void context_pushLoc (void) 
 {
@@ -4439,12 +4500,10 @@ int context_getExpect (void)
   return (context_getValue (FLG_EXPECT));
 }
 
-# ifndef NOLCL
 int context_getLCLExpect (void)
 {
   return (context_getValue (FLG_LCLEXPECT));
 }
-# endif
 
 int context_getLimit (void)
 {
@@ -4546,12 +4605,34 @@ cstring context_getMerge (void)
   return context_getString (FLG_MERGE);
 }
 
-# ifndef NOLCL
 bool context_inLCLLib (void)
 {   
   return (gc.kind == CX_LCLLIB);
 }
 
+
+/*drl add these 3/5/2003*/
+static bool inSizeof = FALSE;
+
+bool context_inSizeof (void)
+{
+  return (inSizeof);
+}
+
+void context_enterSizeof (void)
+{
+  DPRINTF((message("context_enterSizeof ") ) );
+  inSizeof = TRUE;
+}
+
+void context_leaveSizeof (void)
+{ 
+  DPRINTF((message("context_leaveSizeof ") ));
+  inSizeof = FALSE;
+}
+/*end function added 3/5/2003*/
+
+
 bool context_inImport (void)
 {
   return (gc.inimport);
@@ -4566,7 +4647,6 @@ void context_leaveImport (void)
 { 
   gc.inimport = FALSE;
 }
-# endif
 
 bool context_inMacro (void) 
 {
@@ -4595,7 +4675,6 @@ int context_getSpecLinesProcessed (void)
   return (gc.speclinesprocessed);
 }
 
-# ifndef NOLCL
 void context_processedSpecLine (void)
 {
   gc.speclinesprocessed++;
@@ -4604,8 +4683,8 @@ void context_processedSpecLine (void)
 void context_resetSpecLines (void)    
 {
   gc.speclinesprocessed = 0;
+
 }
-# endif
 
 bool context_inGlobalContext (void)
 {
@@ -4738,27 +4817,23 @@ metaStateInfo context_lookupMetaStateInfo (cstring key)
 
 /*@null@*/ annotationInfo context_lookupAnnotation (cstring annot) 
 {
-  annotationInfo ainfo;
-
-  ainfo = annotationTable_lookup (gc.annotTable, annot);
-
-  return ainfo;
+  return annotationTable_lookup (gc.annotTable, annot);
 }
 
-void context_addAnnotation (annotationInfo ainfo)
+void context_addAnnotation (annotationInfo info)
 {
-  if (annotationTable_contains (gc.annotTable, annotationInfo_getName (ainfo)))
+  if (annotationTable_contains (gc.annotTable, annotationInfo_getName (info)))
     {
       voptgenerror 
        (FLG_SYNTAX,
-        message ("Duplicate annotation declaration: %s", annotationInfo_getName (ainfo)),
-        annotationInfo_getLoc (ainfo));
+        message ("Duplicate annotation declaration: %s", annotationInfo_getName (info)),
+        annotationInfo_getLoc (info));
 
-      annotationInfo_free (ainfo);
+      annotationInfo_free (info);
     }
   else
     {
-      annotationTable_insert (gc.annotTable, ainfo);
+      annotationTable_insert (gc.annotTable, info);
     }
 }
 
@@ -4780,12 +4855,12 @@ void context_addMetaState (cstring mname, metaStateInfo msinfo)
     }
 }
 
-valueTable context_createValueTable (sRef s, stateInfo sinfo)
+valueTable context_createValueTable (sRef s, stateInfo info)
 {
   if (metaStateTable_size (gc.stateTable) > 0)
     {
       valueTable res = valueTable_create (metaStateTable_size (gc.stateTable));
-      /*@i32 should use smaller value... */
+      /* should use smaller value... */
       DPRINTF (("Value table for: %s", sRef_unparse (s)));
       
       metaStateTable_elements (gc.stateTable, msname, msi)
@@ -4801,7 +4876,7 @@ valueTable context_createValueTable (sRef s, stateInfo sinfo)
                (res,
                 cstring_copy (metaStateInfo_getName (msi)),
                 stateValue_createImplicit (metaStateInfo_getDefaultValue (msi, s), 
-                                           stateInfo_copy (sinfo)));
+                                           stateInfo_copy (info)));
            }
          else
            {
@@ -4810,137 +4885,88 @@ valueTable context_createValueTable (sRef s, stateInfo sinfo)
        } 
       end_metaStateTable_elements ;
       
-      stateInfo_free (sinfo);
+      stateInfo_free (info);
       DPRINTF (("Value table: %s", valueTable_unparse (res)));
       return res;
     }
   else
     {
-      stateInfo_free (sinfo);
+      stateInfo_free (info);
       return valueTable_undefined;
     }
 }
 
-valueTable context_createGlobalMarkerValueTable (stateInfo sinfo)
+valueTable context_createGlobalMarkerValueTable (stateInfo info)
 {
   if (metaStateTable_size (gc.stateTable) > 0)
     {
       valueTable res = valueTable_create (metaStateTable_size (gc.stateTable));
-      /*@i32 should use smaller value... */
+      /* should use smaller value... */
       
       metaStateTable_elements (gc.stateTable, msname, msi)
        {
-         /*@i23 only add global...*/
+         /* only add global...*/
          DPRINTF (("Create: %s", metaStateInfo_unparse (msi)));
          llassert (cstring_equal (msname, metaStateInfo_getName (msi)));
          
          valueTable_insert (res,
                             cstring_copy (metaStateInfo_getName (msi)),
                             stateValue_create (metaStateInfo_getDefaultGlobalValue (msi),
-                                               stateInfo_copy (sinfo)));
+                                               stateInfo_copy (info)));
        } 
       end_metaStateTable_elements ;
       
-      stateInfo_free (sinfo);
+      stateInfo_free (info);
       DPRINTF (("Value table: %s", valueTable_unparse (res)));
       return res;
     }
   else
     {
-      stateInfo_free (sinfo);
+      stateInfo_free (info);
       return valueTable_undefined;
     }
 }
 
-
-/*drl 12/30/01 these are some ugly functions that were added to facilitate struct annotations */
-
-
-/*drl added */
-static ctype lastStruct;
-
-ctype context_setLastStruct (/*@returned@*/ ctype s) /*@globals lastStruct@*/
-{
-  lastStruct = s;
-  return s;
-}
-
-ctype context_getLastStruct (/*@returned@*/ /*ctype s*/) /*@globals lastStruct@*/
+constraintList context_getImplicitFcnConstraints (uentry ue)
 {
-  return lastStruct;
-}
-
-
-/*@unused@*/ static int sInfoNum = 0;
-
-
-struct getUe {
-  /*@unused@*/  uentry ue;
-  /*@unused@*/ sRef s;
-};
-
-struct sInfo {
-  /*@unused@*/ ctype ct;
-  /*@unused@*/ constraintList inv;
- /*@unused@*/ int ngetUe;
- /*@unused@*/ struct getUe * t ;
-};
-
-
-static struct sInfo globalStructInfo;
-
-
-/*drl 1/6/2001: I didn't think these functions were solid enough to include in the
-  stable  release of splint.  I coomented them out so that they won't break anything
-  but didn't delete them because they will be fixed and included later
-*/
-
-/*
-void  setGlobalStructInfo(ctype ct, constraintList list)
-{
-  int i;
-  uentryList f;
+  constraintList ret = constraintList_makeNew ();
+  uentryList params = uentry_getParams (ue);
 
-  f =  ctype_getFields (ct);
-  
-  if (constraintList_isDefined(list) )
+  uentryList_elements (params, el)
     {
-      globalStructInfo.ct = ct;
-      globalStructInfo.inv = list;
-
-      globalStructInfo.ngetUe = 0;
-      
-      / *abstraction violation fix it * /
-      globalStructInfo.t   = dmalloc(f->nelements * sizeof(struct getUe) );
-
-      globalStructInfo.ngetUe = f->nelements;
-
-      i = 0;
+      DPRINTF (("setImplicitfcnConstraints doing: %s", uentry_unparse(el)));
       
-      uentryList_elements(f, ue)
+      if (uentry_isElipsisMarker (el))
        {
-         globalStructInfo.t[i].ue = ue;
-         globalStructInfo.t[i].s = uentry_getSref(ue);
-         TPRINTF(( message(" setGlobalStructInfo:: adding ue=%s and sRef=%s",
-                           uentry_unparse(ue), sRef_unparse( uentry_getSref(ue) )
-                           )
-                   ));
-         i++;
+         ;
        }
-      end_uentryList_elements;
-    }
-}
-
-*/
-
-bool hasInvariants (ctype ct) /*@*/
-{
-  if ( ctype_sameName(globalStructInfo.ct, ct) )
+      else
+       {
+         sRef s = uentry_getSref (el);
+         
+         DPRINTF (("Trying: %s", sRef_unparse (s)));
 
-    return TRUE;
+         if (ctype_isPointer (sRef_getType (s)))
+           {
+             constraint c = constraint_makeSRefWriteSafeInt (s, 0);
+             ret = constraintList_add (ret, c);
+             
+             /*drl 10/23/2002 added support for out*/
+             
+             if (!uentry_isOut(el))
+               {
+                 c = constraint_makeSRefReadSafeInt (s, 0);
+                 ret = constraintList_add (ret , c);
+               }
+           }
+         else
+           {
+             DPRINTF (("%s is NOT a pointer", sRef_unparseFull (s)));
+           }
+       }
+    } end_uentryList_elements;
 
-  else
-    
-    return FALSE;
-  
+  DPRINTF (("Returns ==> %s", constraintList_unparse (ret)));
+  return ret;
 }
+
This page took 0.971992 seconds and 4 git commands to generate.