2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2002 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://www.splint.org
28 # include "lclintMacros.nf"
32 idDecl_createClauses (/*@only@*/ cstring s, /*@only@*/ qtype t, /*@only@*/ functionClauseList clauses)
34 idDecl d = (idDecl) dmalloc (sizeof (*d));
44 idDecl_create (/*@only@*/ cstring s, /*@only@*/ qtype t)
46 return idDecl_createClauses (s, t, functionClauseList_undefined);
50 idDecl_free (idDecl t)
52 if (idDecl_isDefined (t))
56 /*@!#@#! functionClauseList_free (t->clauses);*/
62 idDecl_unparse (idDecl d)
64 if (idDecl_isDefined (d))
66 if (functionClauseList_isDefined (d->clauses))
68 return (message ("%s : %q / %q", d->id, qtype_unparse (d->typ),
69 functionClauseList_unparse (d->clauses)));
73 return (message ("%s : %q", d->id, qtype_unparse (d->typ)));
78 return (cstring_makeLiteral ("<undefined id>"));
83 idDecl_unparseC (idDecl d)
85 if (idDecl_isDefined (d))
87 return (message ("%q %s", qtype_unparse (d->typ), d->id));
91 return (cstring_makeLiteral ("<undefined id>"));
95 /*@observer@*/ cstring
96 idDecl_observeId (idDecl d)
98 if (idDecl_isDefined (d))
104 return cstring_undefined;
109 idDecl_getTyp (idDecl d)
111 llassert (idDecl_isDefined (d));
117 idDecl_getCtype (idDecl d)
119 if (idDecl_isDefined (d))
121 return (qtype_getType (d->typ));
125 return ctype_unknown;
130 idDecl_getQuals (idDecl d)
132 if (idDecl_isDefined (d))
134 return (qtype_getQuals (d->typ));
138 return qualList_undefined;
143 idDecl_getClauses (idDecl d)
145 if (idDecl_isDefined (d))
151 return functionClauseList_undefined;
156 idDecl_addQual (idDecl d, qual q)
158 llassert (idDecl_isDefined (d));
160 (void) qtype_addQual (d->typ, q);
164 idDecl_setTyp (idDecl d, qtype c)
166 llassert (idDecl_isDefined (d));
173 idDecl_replaceCtype (/*@returned@*/ idDecl d, ctype c)
175 llassert (idDecl_isDefined (d));
177 qtype_setType (d->typ, c);
182 idDecl_fixBase (/*@returned@*/ idDecl t, qtype b)
184 llassert (idDecl_isDefined (t));
186 t->typ = qtype_newQbase (t->typ, b);
191 idDecl_fixParamBase (/*@returned@*/ idDecl t, qtype b)
196 llassert (idDecl_isDefined (t));
198 q = qtype_newQbase (t->typ, b);
199 c = qtype_getType (q);
202 ** For some reason, C adds an implicit pointer to function
203 ** parameters. It is "optional" syntax.
206 if (ctype_isFunction (c) && !ctype_isPointer (c))
208 qtype_setType (q, ctype_makePointer (c));
212 /* Splint thinks t->typ is kept. */
213 /*@-compmempass@*/ return t; /*@=compmempass@*/
217 idDecl_expectFunction (/*@returned@*/ idDecl d)
219 llassert (idDecl_isDefined (d));
221 qtype_setType (d->typ, ctype_expectFunction (qtype_getType (d->typ)));
226 idDecl_addClauses (idDecl d, functionClauseList clauses)
228 llassert (idDecl_isDefined (d));
229 llassert (functionClauseList_isUndefined (d->clauses));
230 d->clauses = clauses;