]>
Commit | Line | Data |
---|---|---|
616915dd | 1 | /* |
11db3170 | 2 | ** Splint - annotation-assisted static program checker |
77d37419 | 3 | ** Copyright (C) 1994-2002 University of Virginia, |
616915dd | 4 | ** Massachusetts Institute of Technology |
5 | ** | |
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. | |
10 | ** | |
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. | |
15 | ** | |
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. | |
19 | ** | |
155af98d | 20 | ** For information on splint: info@splint.org |
21 | ** To report a bug: splint-bug@splint.org | |
11db3170 | 22 | ** For more information: http://www.splint.org |
616915dd | 23 | */ |
24 | /* | |
25 | ** flagMarker.c | |
26 | */ | |
27 | ||
1b8ae690 | 28 | # include "splintMacros.nf" |
616915dd | 29 | # include "basic.h" |
30 | ||
31 | flagMarker flagMarker_createLocalSet (flagcode code, ynm set, fileloc loc) | |
32 | { | |
33 | flagMarker c = (flagMarker) dmalloc (sizeof (*c)); | |
34 | ||
35 | c->kind = FMK_LOCALSET; | |
36 | c->code = code; | |
37 | c->info.set = set; | |
38 | c->loc = fileloc_copy (loc); | |
39 | ||
40 | return c; | |
41 | } | |
42 | ||
43 | flagMarker flagMarker_createSuppress (flagcode code, fileloc loc) | |
44 | { | |
45 | flagMarker c = (flagMarker) dmalloc (sizeof (*c)); | |
46 | ||
47 | c->kind = FMK_SUPPRESS; | |
48 | c->code = code; | |
49 | c->loc = fileloc_copy (loc); | |
50 | ||
51 | return c; | |
52 | } | |
53 | ||
54 | flagMarker flagMarker_createIgnoreOn (fileloc loc) | |
55 | { | |
56 | flagMarker c = (flagMarker) dmalloc (sizeof (*c)); | |
57 | ||
58 | c->kind = FMK_IGNOREON; | |
59 | c->code = INVALID_FLAG; | |
60 | c->loc = fileloc_copy (loc); | |
61 | ||
62 | return c; | |
63 | } | |
64 | ||
65 | flagMarker flagMarker_createIgnoreCount (int count, fileloc loc) | |
66 | { | |
67 | flagMarker c = (flagMarker) dmalloc (sizeof (*c)); | |
68 | ||
69 | c->kind = FMK_IGNORECOUNT; | |
70 | c->code = INVALID_FLAG; | |
71 | c->info.nerrors = count; | |
72 | c->loc = fileloc_copy (loc); | |
73 | ||
28bf4b0b | 74 | DPRINTF (("Create ignore count: %s", flagMarker_unparse (c))); |
616915dd | 75 | return c; |
76 | } | |
77 | ||
78 | flagMarker flagMarker_createIgnoreOff (fileloc loc) | |
79 | { | |
80 | flagMarker c = (flagMarker) dmalloc (sizeof (*c)); | |
81 | ||
82 | c->kind = FMK_IGNOREOFF; | |
83 | c->code = INVALID_FLAG; | |
84 | c->loc = fileloc_copy (loc); | |
85 | ||
86 | return c; | |
87 | } | |
88 | ||
89 | ynm flagMarker_getSet (flagMarker f) | |
90 | { | |
91 | llassert (f->kind == FMK_LOCALSET); | |
92 | ||
93 | return f->info.set; | |
94 | } | |
95 | ||
96 | flagcode flagMarker_getCode (flagMarker f) | |
97 | { | |
98 | llassert (f->kind == FMK_LOCALSET|| f->kind == FMK_SUPPRESS); | |
99 | ||
100 | return f->code; | |
101 | } | |
102 | ||
103 | int flagMarker_getCount (flagMarker f) | |
104 | { | |
105 | llassert (f->kind == FMK_IGNORECOUNT); | |
106 | ||
107 | return f->info.nerrors; | |
108 | } | |
109 | ||
110 | cstring flagMarker_unparse (flagMarker c) | |
111 | { | |
112 | switch (c->kind) | |
113 | { | |
114 | case FMK_LOCALSET: | |
115 | return (message ("%q: %s%s", | |
116 | fileloc_unparse (c->loc), ynm_unparseCode (c->info.set), | |
28bf4b0b | 117 | flagcode_unparse (c->code))); |
616915dd | 118 | case FMK_IGNORECOUNT: |
119 | return (message ("%q: ignore count %d", | |
120 | fileloc_unparse (c->loc), c->info.nerrors)); | |
121 | case FMK_IGNOREON: | |
122 | return (message ("%q: ignore on", | |
123 | fileloc_unparse (c->loc))); | |
124 | case FMK_IGNOREOFF: | |
125 | return (message ("%q: ignore off", | |
126 | fileloc_unparse (c->loc))); | |
127 | case FMK_SUPPRESS: | |
128 | return (message ("%q: suppress %s", | |
129 | fileloc_unparse (c->loc), | |
28bf4b0b | 130 | flagcode_unparse (c->code))); |
616915dd | 131 | } |
132 | ||
8250fa4a | 133 | BADBRANCHRET (cstring_undefined); |
616915dd | 134 | } |
135 | ||
136 | void flagMarker_free (/*@only@*/ flagMarker c) | |
137 | { | |
11db3170 | 138 | fileloc_free (c->loc); /* evans 2001-03-24: Splint caught this... */ |
616915dd | 139 | sfree (c); |
140 | } | |
141 | ||
142 | bool flagMarker_sameFile (flagMarker c, fileloc loc) | |
143 | { | |
144 | return (fileloc_almostSameFile (c->loc, loc)); | |
145 | } | |
146 | ||
147 | /* | |
148 | ** return true if loc is before c->loc | |
149 | */ | |
150 | ||
151 | bool flagMarker_beforeMarker (flagMarker c, fileloc loc) | |
152 | { | |
153 | return (!fileloc_notAfter (c->loc, loc)); | |
154 | } | |
155 | ||
156 | ||
157 |