# include "llmain.h"
# include "intSet.h"
# include "osd.h"
-# include "portab.h"
extern /*@external@*/ int yydebug;
extern /*@external@*/ int mtdebug;
clause inclause;
int numerrors;
+ int numbugs;
filelocStack locstack;
fileTable ftab;
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
{
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:
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,
FLG_NULLSTATE, FLG_NULLDEREF, FLG_NULLASSIGN,
FLG_NULLPASS, FLG_NULLRET,
+ FLG_ALLOCMISMATCH,
FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF, FLG_RETSTACK,
/* 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,
void context_enterAndClause (exprNode e)
{
-
+ DPRINTF (("enter and clause: %s", exprNode_unparse (e)));
usymtab_trueBranch (guardSet_copy (exprNode_getGuards (e)));
pushClause (ANDCLAUSE);
}
switch (flag)
{
- /*
- case FLG_BOOLTRUE:
- usymtab_supGlobalEntry
- (uentry_makeConstantValue (val, ctype_bool,
- fileloc_getBuiltin (), TRUE,
- multiVal_makeInt (1)));
- break;
- case FLG_BOOLFALSE:
- usymtab_supGlobalEntry
- (uentry_makeConstantValue (val, ctype_bool,
- fileloc_getBuiltin (), FALSE,
- multiVal_makeInt (0)));
- break;
- */
case FLG_MESSAGESTREAM:
case FLG_WARNINGSTREAM:
case FLG_ERRORSTREAM:
gc.numerrors = 0;
}
+void
+context_recordBug (void)
+{
+ gc.numbugs++;
+}
+
+int
+context_numBugs (void)
+{
+ return gc.numbugs;
+}
+
void context_initMod (void)
/*@globals undef gc; @*/
{
gc.instandardlib = FALSE;
gc.numerrors = 0;
+ gc.numbugs = 0;
gc.neednl = FALSE;
gc.linesprocessed = 0;
gc.speclinesprocessed = 0;
globSet_free (gc.globs_used);
metaStateTable_free (gc.stateTable);
annotationTable_free (gc.annotTable);
-
-
}
/*
/*@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);
}
}
}
}
-valueTable context_createValueTable (sRef s, stateInfo sinfo)
+valueTable context_createValueTable (sRef s, stateInfo info)
{
if (metaStateTable_size (gc.stateTable) > 0)
{
(res,
cstring_copy (metaStateInfo_getName (msi)),
stateValue_createImplicit (metaStateInfo_getDefaultValue (msi, s),
- stateInfo_copy (sinfo)));
+ stateInfo_copy (info)));
}
else
{
}
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_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@*/
-{
- 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@*/
-
-
-