2 ** LCLint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2000 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
28 # include "lclintMacros.nf"
32 idDecl_create (/*@only@*/ cstring s, /*@only@*/ qtype t)
34 idDecl d = (idDecl) dmalloc (sizeof (*d));
43 idDecl_free (idDecl t)
45 if (idDecl_isDefined (t))
54 idDecl_unparse (idDecl d)
56 if (idDecl_isDefined (d))
58 return (message ("%s : %q", d->id, qtype_unparse (d->typ)));
62 return (cstring_makeLiteral ("<undefined id>"));
66 /*@observer@*/ cstring
67 idDecl_observeId (idDecl d)
69 if (idDecl_isDefined (d))
75 return cstring_undefined;
80 idDecl_getTyp (idDecl d)
82 llassert (idDecl_isDefined (d));
88 idDecl_getCtype (idDecl d)
90 if (idDecl_isDefined (d))
92 return (qtype_getType (d->typ));
101 idDecl_getQuals (idDecl d)
103 if (idDecl_isDefined (d))
105 return (qtype_getQuals (d->typ));
109 return qualList_undefined;
114 idDecl_addQual (idDecl d, qual q)
116 llassert (idDecl_isDefined (d));
118 (void) qtype_addQual (d->typ, q);
122 idDecl_setTyp (idDecl d, qtype c)
124 llassert (idDecl_isDefined (d));
131 idDecl_replaceCtype (/*@returned@*/ idDecl d, ctype c)
133 llassert (idDecl_isDefined (d));
135 qtype_setType (d->typ, c);
140 idDecl_fixBase (/*@returned@*/ idDecl t, qtype b)
142 llassert (idDecl_isDefined (t));
144 t->typ = qtype_newQbase (t->typ, b);
149 idDecl_fixParamBase (/*@returned@*/ idDecl t, qtype b)
154 llassert (idDecl_isDefined (t));
156 q = qtype_newQbase (t->typ, b);
157 c = qtype_getType (q);
160 ** For some reason, C adds an implicit pointer to function
161 ** parameters. It is "optional" syntax.
164 if (ctype_isFunction (c) && !ctype_isPointer (c))
166 qtype_setType (q, ctype_makePointer (c));
170 /* LCLint thinks t->typ is kept. */
171 /*@-compmempass@*/ return t; /*@=compmempass@*/
175 idDecl_expectFunction (/*@returned@*/ idDecl d)
177 llassert (idDecl_isDefined (d));
179 qtype_setType (d->typ, ctype_expectFunction (qtype_getType (d->typ)));