X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/ae13359213220016611ceaf93109dac6849be88b..210066f9dd04de7d7d2f04d320b39a52f28b290b:/src/context.c diff --git a/src/context.c b/src/context.c index 60d5125..092eecf 100644 --- a/src/context.c +++ b/src/context.c @@ -102,6 +102,7 @@ static struct clause inclause; int numerrors; + int numbugs; filelocStack locstack; fileTable ftab; @@ -843,13 +844,13 @@ context_resetAllFlags (void) gc.flags[FLG_NULLINIT] = TRUE; gc.flags[FLG_STRINGLITTOOLONG] = TRUE; - + gc.flags[FLG_MACROCONSTDIST] = TRUE; gc.flags[FLG_LIKELYBOOL] = TRUE; gc.flags[FLG_ZEROPTR] = TRUE; gc.flags[FLG_NUMLITERAL] = TRUE; gc.flags[FLG_DUPLICATEQUALS] = TRUE; gc.flags[FLG_SKIPISOHEADERS] = TRUE; - gc.flags[FLG_SKIPPOSIXHEADERS] = TRUE; + gc.flags[FLG_SKIPPOSIXHEADERS] = FALSE; gc.flags[FLG_SYSTEMDIREXPAND] = TRUE; gc.flags[FLG_UNRECOGCOMMENTS] = TRUE; gc.flags[FLG_UNRECOGFLAGCOMMENTS] = TRUE; @@ -934,7 +935,7 @@ context_resetAllFlags (void) ** 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 @@ -1234,7 +1235,7 @@ context_setModeAux (cstring s, bool warn) FLG_CHECKSTRICTGLOBALS, FLG_IMPCHECKEDSPECGLOBALS, FLG_MACROMATCHNAME, FLG_WARNLINTCOMMENTS, FLG_INCLUDENEST, FLG_ISORESERVED, FLG_CPPNAMES, - FLG_NOPARAMS, FLG_IFEMPTY, FLG_WHILEEMPTY, FLG_REALCOMPARE, + FLG_NOPARAMS, FLG_IFEMPTY, FLG_WHILEEMPTY, FLG_REALCOMPARE, FLG_REALRELATECOMPARE, FLG_BOOLOPS, FLG_SHIFTNEGATIVE, FLG_SHIFTIMPLEMENTATION, FLG_BUFFEROVERFLOWHIGH, FLG_BUFFEROVERFLOW, @@ -1370,7 +1371,7 @@ context_setModeAux (cstring s, bool warn) FLG_FOREMPTY, FLG_WHILEEMPTY, FLG_IFEMPTY, FLG_IFBLOCK, FLG_ELSEIFCOMPLETE, - FLG_REALCOMPARE, FLG_BOOLOPS, + FLG_REALCOMPARE, FLG_BOOLOPS, FLG_REALRELATECOMPARE, FLG_SYSTEMDIRERRORS, FLG_UNUSEDSPECIAL, FLG_SHIFTNEGATIVE, @@ -1578,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); } @@ -3054,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; @*/ { @@ -3064,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; @@ -4913,111 +4927,46 @@ valueTable context_createGlobalMarkerValueTable (stateInfo info) } } - -/*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@*/ -{ - return lastStruct; -} - -/* -** Why is this stuff in context.c? -*/ - -/*@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 ; -}; - -/* 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 - but didn't delete them because they will be fixed and included later - - -*/ - -/*@-paramuse@*/ - -void context_setGlobalStructInfo (ctype ct, constraintList list) +constraintList context_getImplicitFcnConstraints (uentry ue) { -# if 0 - /* 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; + DPRINTF (("setImplicitfcnConstraints doing: %s", uentry_unparse(el))); - /* abstraction violation fix it * / - globalStructInfo.t = dmalloc(f->nelements * sizeof(struct getUe) ); - - globalStructInfo.ngetUe = f->nelements; - - i = 0; - - 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; - } - */ -# endif -} - -# if 0 -/* - -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; } -*/ -# endif - -/*@=paramuse@*/ - - -