2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 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 splint: info@splint.org
21 ** To report a bug: splint-bug@splint.org
22 ** For more information: http://www.splint.org
28 # include "splintMacros.nf"
31 flagMarker flagMarker_createLocalSet (flagcode code, ynm set, fileloc loc)
33 flagMarker c = (flagMarker) dmalloc (sizeof (*c));
35 c->kind = FMK_LOCALSET;
38 c->loc = fileloc_copy (loc);
43 flagMarker flagMarker_createSuppress (flagcode code, fileloc loc)
45 flagMarker c = (flagMarker) dmalloc (sizeof (*c));
47 c->kind = FMK_SUPPRESS;
49 c->loc = fileloc_copy (loc);
54 flagMarker flagMarker_createIgnoreOn (fileloc loc)
56 flagMarker c = (flagMarker) dmalloc (sizeof (*c));
58 c->kind = FMK_IGNOREON;
59 c->code = INVALID_FLAG;
60 c->loc = fileloc_copy (loc);
65 flagMarker flagMarker_createIgnoreCount (int count, fileloc loc)
67 flagMarker c = (flagMarker) dmalloc (sizeof (*c));
69 c->kind = FMK_IGNORECOUNT;
70 c->code = INVALID_FLAG;
71 c->info.nerrors = count;
72 c->loc = fileloc_copy (loc);
74 DPRINTF (("Create ignore count: %s", flagMarker_unparse (c)));
78 flagMarker flagMarker_createIgnoreOff (fileloc loc)
80 flagMarker c = (flagMarker) dmalloc (sizeof (*c));
82 c->kind = FMK_IGNOREOFF;
83 c->code = INVALID_FLAG;
84 c->loc = fileloc_copy (loc);
89 ynm flagMarker_getSet (flagMarker f)
91 llassert (f->kind == FMK_LOCALSET);
96 flagcode flagMarker_getCode (flagMarker f)
98 llassert (f->kind == FMK_LOCALSET|| f->kind == FMK_SUPPRESS);
103 int flagMarker_getCount (flagMarker f)
105 llassert (f->kind == FMK_IGNORECOUNT);
107 return f->info.nerrors;
110 bool flagMarker_equal (flagMarker f1, flagMarker f2)
112 if (f1->kind != f2->kind)
117 if (!fileloc_equal (f1->loc, f2->loc))
125 return (f1->info.set == f2->info.set
126 && flagcode_equal (f1->code, f2->code));
127 case FMK_IGNORECOUNT:
128 return (f1->info.nerrors == f2->info.nerrors);
133 return (flagcode_equal (f1->code, f2->code));
136 BADBRANCHRET (FALSE);
139 cstring flagMarker_unparse (flagMarker c)
144 return (message ("%q: %s%s",
145 fileloc_unparse (c->loc), ynm_unparseCode (c->info.set),
146 flagcode_unparse (c->code)));
147 case FMK_IGNORECOUNT:
148 return (message ("%q: ignore count %d",
149 fileloc_unparse (c->loc), c->info.nerrors));
151 return (message ("%q: ignore on",
152 fileloc_unparse (c->loc)));
154 return (message ("%q: ignore off",
155 fileloc_unparse (c->loc)));
157 return (message ("%q: suppress %s",
158 fileloc_unparse (c->loc),
159 flagcode_unparse (c->code)));
162 BADBRANCHRET (cstring_undefined);
165 void flagMarker_free (/*@only@*/ flagMarker c)
167 fileloc_free (c->loc); /* evans 2001-03-24: Splint caught this... */
171 bool flagMarker_sameFile (flagMarker c, fileloc loc)
173 return (fileloc_almostSameFile (c->loc, loc));
177 ** return true if loc is before c->loc
180 bool flagMarker_beforeMarker (flagMarker c, fileloc loc)
182 return (!fileloc_notAfter (c->loc, loc));