]> andersk Git - splint.git/blobdiff - src/warnClause.c
noexpand always false.
[splint.git] / src / warnClause.c
index f784c7a0bf57dbbb5383eb0b3f70b901ab6d646c..38ff5ba9dc36260f232c5bd5181b2cadf9836fc8 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
 */
 /*
 ** warnClause.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
-# include "mtgrammar.h"
 
 static warnClause warnClause_createAux (/*@only@*/ fileloc loc, 
                                        /*@only@*/ flagSpec flag, 
-                                       /*@only@*/ exprNode msg)
+                                       /*@only@*/ cstring msg)
 {
   warnClause res = (warnClause) dmalloc (sizeof (*res));
   
@@ -39,23 +38,44 @@ static warnClause warnClause_createAux (/*@only@*/ fileloc loc,
   res->flag = flag;
   res->msg = msg;
   
+  DPRINTF (("Creating warn clause with flag spec: [%p] %s", flag,
+           flagSpec_unparse (flag)));
   return res;
 }
 
-extern warnClause warnClause_create (lltok tok, flagSpec flag, exprNode msg) 
+extern warnClause warnClause_create (lltok tok, flagSpec flag, cstring msg) 
 {
   warnClause res;
-  DPRINTF (("Create warn message: %s/ %s ", 
-           flagSpec_unparse (flag), exprNode_unparse(msg)));
-  
-  res = warnClause_createAux (lltok_stealLoc (tok),
-                             flag, msg);
-  lltok_release (tok);
+  /*
+  ** evans 2002-03-11
+  ** was
+  **   res = warnClause_createAux (lltok_stealLoc (tok), flag, msg);
+  ** but this leads to unexplained (yet) crashes.
+  ** Reported by Walter Briscoe
+  */
+
+  res = warnClause_createAux (fileloc_copy (lltok_getLoc (tok)), flag, msg);
+  lltok_free (tok);
   return res;
 }
 
+warnClause warnClause_copy (warnClause w)
+{
+  if (warnClause_isDefined (w))
+    {
+      return warnClause_createAux (fileloc_copy (w->loc),
+                                  flagSpec_copy (w->flag),
+                                  cstring_copy (w->msg)); 
+    }
+  else
+    {
+      return warnClause_undefined;
+    }
+}
+
 extern flagSpec warnClause_getFlag (warnClause w)
 {
+  llassert (warnClause_isDefined (w));
   return w->flag;
 }
 
@@ -63,8 +83,7 @@ extern cstring warnClause_unparse (warnClause w)
 {
   if (warnClause_isDefined (w))
     {
-      return message ("<%q> %s",
-                     flagSpec_unparse (w->flag), exprNode_unparse (w->msg));
+      return message ("<%q> %s", flagSpec_unparse (w->flag), w->msg);
     }
   else
     {
@@ -74,15 +93,13 @@ extern cstring warnClause_unparse (warnClause w)
 
 extern bool warnClause_hasMessage (warnClause w)
 {
-  return warnClause_isDefined (w) && exprNode_isDefined (w->msg)
-    && cstring_isDefined (multiVal_forceString (exprNode_getValue (w->msg)));
+  return warnClause_isDefined (w) && cstring_isDefined (w->msg);
 }
 
 extern /*@observer@*/ cstring warnClause_getMessage (warnClause w)
 {
-  if (warnClause_isDefined (w) && exprNode_isDefined (w->msg)) {
-    llassert (exprNode_knownStringValue (w->msg));
-    return multiVal_forceString (exprNode_getValue (w->msg));
+  if (warnClause_isDefined (w)) {
+    return w->msg;
   } else {
     return cstring_undefined;
   }
@@ -94,8 +111,8 @@ extern void warnClause_free (warnClause w)
   if (warnClause_isDefined (w))
     {
       flagSpec_free (w->flag);
-      exprNode_free (w->msg);
       fileloc_free (w->loc);
+      cstring_free (w->msg);
       sfree (w);
     }
 }
@@ -104,7 +121,7 @@ extern void warnClause_free (warnClause w)
 warnClause_dump (warnClause wc)
 {
   cstring st = cstring_undefined;
-
+  llassert (warnClause_isDefined (wc));
   llassert (!cstring_containsChar (warnClause_getMessage (wc), '#'));
 
   if (warnClause_hasMessage (wc))
@@ -125,7 +142,6 @@ warnClause_undump (char **s)
 {
   flagSpec flag;
   cstring msg;
-  exprNode emsg;
 
   DPRINTF (("Undump: %s", *s));
   flag = flagSpec_undump (s);
@@ -145,7 +161,5 @@ warnClause_undump (char **s)
   DPRINTF (("Here: %s", *s));
   reader_checkChar (s, '#');
 
-  emsg = exprNode_rawStringLiteral (msg, fileloc_copy (g_currentloc));
-  
-  return warnClause_createAux (fileloc_copy (g_currentloc), flag, emsg);
+  return warnClause_createAux (fileloc_copy (g_currentloc), flag, msg);
 }
This page took 0.31486 seconds and 4 git commands to generate.