/*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Splint - annotation-assisted static program checker
+** Copyright (C) 1994-2003 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA.
**
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
-** For more information: http://lclint.cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
+** For more information: http://www.splint.org
*/
/*
** mtContextNode.c
*/
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
# include "basic.h"
static bool mtContextNode_matchesType (mtContextNode, ctype) /*@*/ ;
case MTC_NULL: return cstring_makeLiteralTemp ("null");
}
- BADBRANCH;
+ BADBRANCHRET (cstring_undefined);
}
static mtContextNode mtContextNode_create (mtContextKind context, ctype ct)
}
break;
case MTC_PARAM:
- if (!uentry_isParam (ue))
+ if (!uentry_isAnyParam (ue))
{
+ DPRINTF (("not param: %s", uentry_unparseFull (ue)));
return FALSE;
}
break;
bool mtContextNode_matchesRefStrict (mtContextNode context, sRef s)
{
- if (mtContextNode_matchesRef (context, s))
+ if (mtContextNode_isDefined (context)
+ && mtContextNode_matchesRef (context, s))
{
if (ctype_isKnown (context->type)
&& (ctype_isUnknown (sRef_getType (s))
bool mtContextNode_matchesType (mtContextNode context, ctype ct)
{
DPRINTF (("Context type..."));
+ llassert (mtContextNode_isDefined (context));
if (!ctype_match (context->type, ct))
{
}
else
{
+ /* evans 2001-08-21 - don't match if only one type is unknown */
+ if (ctype_isUnknown (ct) && !ctype_isUnknown (context->type))
+ {
+ return FALSE;
+ }
+
DPRINTF (("Type okay: %s / %s",
ctype_unparse (context->type),
ctype_unparse (ct)));
cstring mtContextNode_unparse (mtContextNode node)
{
+ llassert (mtContextNode_isDefined (node));
+
if (ctype_isKnown (node->type))
{
return message ("%s %s", mtContextKind_unparse (node->context),
return (n->context == MTC_NULL);
}
+void mtContextNode_showRefError (mtContextNode context, sRef sr)
+{
+ ctype ct;
+
+ llassert (mtContextNode_isDefined (context));
+ llassert (!mtContextNode_matchesRef (context, sr));
+
+ DPRINTF (("Matches context: %s / %s",
+ mtContextNode_unparse (context), sRef_unparse (sr)));
+
+ switch (context->context)
+ {
+ case MTC_ANY: break; /* everything matches */
+ case MTC_RESULT:
+ if (!sRef_isResult (sr))
+ {
+ llgenindentmsgnoloc
+ (message ("Context is result, doesn't match %q", sRef_unparse (sr)));
+ return;
+ }
+ break;
+ case MTC_PARAM:
+ if (!sRef_isResult (sr))
+ {
+ llgenindentmsgnoloc
+ (message ("Context is parameter, doesn't match %q", sRef_unparse (sr)));
+ return;
+ }
+ break;
+ case MTC_LITERAL:
+ DPRINTF (("Literal: %s", sRef_unparse (sr)));
+ if (!sRef_isConst (sr))
+ {
+ llgenindentmsgnoloc
+ (message ("Context is literal, doesn't match %q", sRef_unparse (sr)));
+ return;
+ }
+ break;
+ case MTC_NULL:
+ case MTC_REFERENCE:
+ break;
+ case MTC_CLAUSE:
+ BADBRANCH;
+ }
+
+ ct = sRef_getType (sr);
+
+ if (!mtContextNode_matchesType (context, ct))
+ {
+ llgenindentmsgnoloc
+ (message ("Context type is %s, doesn't match type %s",
+ ctype_unparse (context->type),
+ ctype_unparse (ct)));
+ }
+ else
+ {
+ BADBRANCH;
+ }
+}