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 splint: splint@cs.virginia.edu
21 ** To report a bug: splint-bug@cs.virginia.edu
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 cstring flagMarker_unparse (flagMarker c)
115 return (message ("%q: %s%s",
116 fileloc_unparse (c->loc), ynm_unparseCode (c->info.set),
117 flagcode_unparse (c->code)));
118 case FMK_IGNORECOUNT:
119 return (message ("%q: ignore count %d",
120 fileloc_unparse (c->loc), c->info.nerrors));
122 return (message ("%q: ignore on",
123 fileloc_unparse (c->loc)));
125 return (message ("%q: ignore off",
126 fileloc_unparse (c->loc)));
128 return (message ("%q: suppress %s",
129 fileloc_unparse (c->loc),
130 flagcode_unparse (c->code)));
133 BADBRANCHRET (cstring_undefined);
136 void flagMarker_free (/*@only@*/ flagMarker c)
138 fileloc_free (c->loc); /* evans 2001-03-24: Splint caught this... */
142 bool flagMarker_sameFile (flagMarker c, fileloc loc)
144 return (fileloc_almostSameFile (c->loc, loc));
148 ** return true if loc is before c->loc
151 bool flagMarker_beforeMarker (flagMarker c, fileloc loc)
153 return (!fileloc_notAfter (c->loc, loc));