2 ** LCLint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2001 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on lclint: lclint-request@cs.virginia.edu
21 ** To report a bug: lclint-bug@cs.virginia.edu
22 ** For more information: http://lclint.cs.virginia.edu
25 ** functionConstraint.c
28 # include "lclintMacros.nf"
30 # include "mtincludes.h"
32 static /*@only@*/ /*@notnull@*/ /*@special@*/ functionConstraint /*@i32 need special? @*/
33 functionConstraint_alloc (functionConstraintKind kind) /*@defines result->kind@*/
35 functionConstraint res = (functionConstraint) dmalloc (sizeof (*res));
41 extern functionConstraint functionConstraint_createBufferConstraint (constraintList buf)
43 functionConstraint res = functionConstraint_alloc (FCT_BUFFER);
44 res->constraint.buffer = buf;
48 extern functionConstraint functionConstraint_createMetaStateConstraint (metaStateConstraint msc)
50 functionConstraint res = functionConstraint_alloc (FCT_METASTATE);
51 res->constraint.metastate = msc;
55 /*@only@*/ cstring functionConstraint_unparse (functionConstraint p)
57 if (functionConstraint_isDefined (p))
62 return constraintList_unparse (p->constraint.buffer);
64 return metaStateConstraint_unparse (p->constraint.metastate);
71 return cstring_makeLiteral ("< empty constraint >");
75 extern constraintList functionConstraint_getBufferConstraint (functionConstraint node)
77 llassert (functionConstraint_isDefined (node));
78 llassert (node->kind == FCT_BUFFER);
79 return node->constraint.buffer;
82 extern metaStateConstraint functionConstraint_getMetaStateConstraint (functionConstraint node)
84 llassert (functionConstraint_isDefined (node));
85 llassert (node->kind == FCT_METASTATE);
86 return node->constraint.metastate;
89 extern bool functionConstraint_hasBufferConstraint (functionConstraint node)
91 return functionConstraint_isDefined (node) && node->kind == FCT_BUFFER;
94 extern functionConstraint functionConstraint_copy (functionConstraint node)
96 if (functionConstraint_isDefined (node))
101 return functionConstraint_createBufferConstraint (constraintList_copy (node->constraint.buffer));
103 return functionConstraint_createMetaStateConstraint (metaStateConstraint_copy (node->constraint.metastate));
110 return functionConstraint_undefined;
114 extern void functionConstraint_free (/*@only@*/ functionConstraint node)
116 if (functionConstraint_isDefined (node))
121 constraintList_free (node->constraint.buffer);
124 metaStateConstraint_free (node->constraint.metastate);