X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/d9daf826a5062af3f227a98f0525e5a38f350539..35b9a1d988c06908076e3a6eeae55b1147879607:/src/context.c diff --git a/src/context.c b/src/context.c index f2d8b97..bb24cab 100644 --- a/src/context.c +++ b/src/context.c @@ -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 @@ -36,10 +36,7 @@ # include "splintMacros.nf" # include "llbasic.h" -# ifndef NOLCL # include "usymtab_interface.h" -# endif - # include "exprChecks.h" # include "filelocStack.h" # include "llmain.h" @@ -53,7 +50,7 @@ extern /*@external@*/ int mtdebug; typedef struct { cstring file; - typeIdSet daccess ; + typeIdSet daccess; } maccesst; typedef enum { @@ -476,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) @@ -540,7 +535,6 @@ insertModuleAccess (cstring fname, typeId t) addModuleAccess (cstring_copy (fname), typeIdSet_single (t)); } -# ifndef NOLCL void context_exitLCLfile (void) { @@ -557,7 +551,6 @@ context_exitLCLfile (void) gc.kind = CX_GLOBAL; gc.facct = typeIdSet_emptySet (); } -# endif void context_dumpModuleAccess (FILE *fout) @@ -733,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: @@ -892,6 +887,7 @@ context_resetAllFlags (void) gc.flags[FLG_WARNUNIXLIB] = TRUE; 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; @@ -899,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; @@ -1034,7 +1031,7 @@ 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, @@ -1045,6 +1042,7 @@ 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, @@ -1086,7 +1084,7 @@ context_setModeAux (cstring s, bool warn) FLG_UNKNOWNTRANS, FLG_KEEPTRANS, FLG_IMMEDIATETRANS, - + FLG_NUMABSTRACTCAST, FLG_EXPORTLOCAL, FLG_USERELEASED, FLG_ALIASUNIQUE, FLG_MAYALIASUNIQUE, @@ -1116,11 +1114,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_CHARUNSIGNEDCHAR, FLG_PREDBOOLOTHERS, + FLG_NUMABSTRACTLIT, FLG_VARUNUSED, FLG_FUNCUNUSED, FLG_TYPEUNUSED, FLG_CHECKSTRICTGLOBALS, FLG_MACROMATCHNAME, @@ -1146,7 +1145,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, @@ -1242,7 +1243,9 @@ context_setModeAux (cstring s, bool warn) { flagcode modeflags[] = { - FLG_CHECKSTRICTGLOBALIAS, + FLG_ABSTRACTCOMPARE, + FLG_CHECKSTRICTGLOBALIAS, + FLG_NUMABSTRACTCAST, FLG_CHECKEDGLOBALIAS, FLG_CHECKMODGLOBALIAS, FLG_UNCHECKEDGLOBALIAS, @@ -1882,12 +1885,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 @@ -2972,7 +2972,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)))) { @@ -4140,11 +4140,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); @@ -4330,17 +4343,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 (); @@ -4361,43 +4386,53 @@ context_destroyMod (void) globSet_free (gc.globs_used); metaStateTable_free (gc.stateTable); annotationTable_free (gc.annotTable); + + } /* -** 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) { @@ -4457,12 +4492,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) { @@ -4564,12 +4597,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); @@ -4584,7 +4639,6 @@ void context_leaveImport (void) { gc.inimport = FALSE; } -# endif bool context_inMacro (void) { @@ -4613,7 +4667,6 @@ int context_getSpecLinesProcessed (void) return (gc.speclinesprocessed); } -# ifndef NOLCL void context_processedSpecLine (void) { gc.speclinesprocessed++; @@ -4622,8 +4675,8 @@ void context_processedSpecLine (void) void context_resetSpecLines (void) { gc.speclinesprocessed = 0; + } -# endif bool context_inGlobalContext (void) { @@ -4888,6 +4941,9 @@ ctype context_getLastStruct (/*@returned@*/ /*ctype s*/) /*@globals lastStruct@* return lastStruct; } +/* +** Why is this stuff in context.c? +*/ /*@unused@*/ static int sInfoNum = 0; @@ -4904,9 +4960,7 @@ struct sInfo { /*@unused@*/ struct getUe * t ; }; - -static struct sInfo globalStructInfo; - +/* unused: 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 @@ -4917,8 +4971,9 @@ static struct sInfo globalStructInfo; /*@-paramuse@*/ -void setGlobalStructInfo(ctype ct, constraintList list) +void context_setGlobalStructInfo(ctype ct, constraintList list) { +# if 0 /* int i; uentryList f; @@ -4951,8 +5006,10 @@ void setGlobalStructInfo(ctype ct, constraintList list) end_uentryList_elements; } */ +# endif } +# if 0 /* bool hasInvariants (ctype ct) /*@* / @@ -4966,8 +5023,11 @@ bool hasInvariants (ctype ct) /*@* / return FALSE; } - - */ +# endif /*@=paramuse@*/ + + + +