]> andersk Git - splint.git/blobdiff - src/idDecl.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / idDecl.c
index fb66c435f1ffaeebefdaedbc44fe52cc0ff19781..d60e65e939d8aab5435714fbd429a828bff52c06 100644 (file)
@@ -1,6 +1,6 @@
 /*
-** LCLint - annotation-assisted static program checker
-** Copyright (C) 1994-2000 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
 */
 /*
 ** idDecl.c
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 
 /*@only@*/ idDecl
-  idDecl_create (/*@only@*/ cstring s, /*@only@*/ qtype t)
+  idDecl_createClauses (/*@only@*/ cstring s, /*@only@*/ qtype t, /*@only@*/ functionClauseList clauses)
 {
   idDecl d = (idDecl) dmalloc (sizeof (*d));
 
   d->id = s;
   d->typ = t;
+  d->clauses = clauses;
 
   return (d);
 }
 
+/*@only@*/ idDecl
+  idDecl_create (/*@only@*/ cstring s, /*@only@*/ qtype t)
+{
+  return idDecl_createClauses (s, t, functionClauseList_undefined);
+}
+
 void
 idDecl_free (idDecl t)
 {
   if (idDecl_isDefined (t))
     {
-      cstring_free (t->id);
+      /* don't: functionClauseList_free (t->clauses); */ /* evans 2002-01-03: splint catches this now! */
       qtype_free (t->typ);
-      sfree (t);
+      cstring_free (t->id);
+
+      /*@-compdestroy@*/ sfree (t); /*@=compdestroy@*/
     }
 }
 
@@ -55,7 +64,28 @@ idDecl_unparse (idDecl d)
 {
   if (idDecl_isDefined (d))
     {
-      return (message ("%s : %q", d->id, qtype_unparse (d->typ)));
+      if (functionClauseList_isDefined (d->clauses)) 
+       {
+         return (message ("%s : %q / %q", d->id, qtype_unparse (d->typ),
+                          functionClauseList_unparse (d->clauses)));
+       }
+      else
+       {
+         return (message ("%s : %q", d->id, qtype_unparse (d->typ)));
+       }
+    }
+  else
+    {
+      return (cstring_makeLiteral ("<undefined id>"));
+    }
+}
+
+cstring
+idDecl_unparseC (idDecl d)
+{
+  if (idDecl_isDefined (d))
+    {
+      return (message ("%q %s", qtype_unparse (d->typ), d->id));
     }
   else
     {
@@ -110,6 +140,19 @@ idDecl_getQuals (idDecl d)
     }
 }
 
+functionClauseList
+idDecl_getClauses (idDecl d)
+{
+  if (idDecl_isDefined (d))
+    {
+      return (d->clauses);
+    }
+  else
+    {
+      return functionClauseList_undefined;
+    }
+}
+
 void
 idDecl_addQual (idDecl d, qual q)
 {
@@ -132,6 +175,7 @@ idDecl_replaceCtype (/*@returned@*/ idDecl d, ctype c)
 {
   llassert (idDecl_isDefined (d));
 
+  DPRINTF (("Replace type: %s / %s", idDecl_unparse (d), ctype_unparse (c)));
   qtype_setType (d->typ, c);
   return d;
 }
@@ -167,7 +211,7 @@ idDecl_fixParamBase (/*@returned@*/ idDecl t, qtype b)
     }
 
   t->typ = q;
-  /* LCLint thinks t->typ is kept. */
+  /* Splint thinks t->typ is kept. */
   /*@-compmempass@*/ return t; /*@=compmempass@*/
 }
 
@@ -179,3 +223,49 @@ idDecl_expectFunction (/*@returned@*/ idDecl d)
   qtype_setType (d->typ, ctype_expectFunction (qtype_getType (d->typ)));
   return d;
 }
+
+/*
+** evans 2002-02-09: This is a bit of a kludge, but we 
+** need it to fix declarations like int (*p)[];
+*/
+
+void
+idDecl_notExpectingFunction (/*@returned@*/ idDecl d)
+{
+  if (idDecl_isDefined (d)) 
+    {
+      ctype ct = qtype_getType (d->typ);
+
+      if (ctype_isExpFcn (ct))
+       {
+         qtype_setType (d->typ, ctype_dontExpectFunction (ct));
+       }
+    }
+}
+
+void
+idDecl_addClauses (idDecl d, functionClauseList clauses)
+{
+  llassert (idDecl_isDefined (d));
+
+  /*
+    DRL comment out llassert:
+    
+    This breaks on sometypes of functionPointers.
+    I.e.
+    void (*signal (int sig ) @requires g >= 0 @ ) (int) @requires g >= 0 @ ;
+
+    llassert (functionClauseList_isUndefined (d->clauses));
+
+  */
+
+  if (functionClauseList_isUndefined (d->clauses) )
+    {
+      d->clauses = clauses;
+    }
+  else
+    {
+      functionClauseList_free(d->clauses);
+      d->clauses = clauses;
+    }
+}
This page took 0.045907 seconds and 4 git commands to generate.