]> andersk Git - splint.git/blobdiff - src/mtContextNode.c
noexpand always false.
[splint.git] / src / mtContextNode.c
index 9f89c870eecb1820a0f47a3abc0ceb3958834ec7..82dff5c305e05bc2b60f0a37b81cd7cc8599e628 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** 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) /*@*/ ;
@@ -43,7 +43,7 @@ static /*@observer@*/ cstring mtContextKind_unparse (mtContextKind ck)
     case MTC_NULL: return cstring_makeLiteralTemp ("null");
     }
 
-  BADBRANCH;
+  BADBRANCHRET (cstring_undefined);
 }
  
 static mtContextNode mtContextNode_create (mtContextKind context, ctype ct) 
@@ -114,8 +114,9 @@ bool mtContextNode_matchesEntry (mtContextNode context, uentry ue)
        }
       break;
     case MTC_PARAM: 
-      if (!uentry_isParam (ue))
+      if (!uentry_isAnyParam (ue))
        {
+         DPRINTF (("not param: %s", uentry_unparseFull (ue)));
          return FALSE;
        }
       break;
@@ -183,7 +184,8 @@ bool mtContextNode_matchesRef (mtContextNode context, sRef sr)
 
 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))
@@ -203,6 +205,7 @@ bool mtContextNode_matchesRefStrict (mtContextNode context, sRef s)
 bool mtContextNode_matchesType (mtContextNode context, ctype ct)
 {
   DPRINTF (("Context type..."));
+  llassert (mtContextNode_isDefined (context));
   
   if (!ctype_match (context->type, ct))
     {
@@ -213,6 +216,12 @@ bool mtContextNode_matchesType (mtContextNode context, ctype 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)));
@@ -223,6 +232,8 @@ bool mtContextNode_matchesType (mtContextNode context, ctype ct)
 
 cstring mtContextNode_unparse (mtContextNode node)
 {
+  llassert (mtContextNode_isDefined (node));
+
   if (ctype_isKnown (node->type))
     {
       return message ("%s %s", mtContextKind_unparse (node->context),
@@ -270,6 +281,65 @@ bool mtContextNode_isNull (mtContextNode n)
   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;
+    }
+}
 
 
 
This page took 2.687288 seconds and 4 git commands to generate.