]> andersk Git - splint.git/blame - src/flagMarker.c
Readded files.
[splint.git] / src / flagMarker.c
CommitLineData
616915dd 1/*
2** LCLint - annotation-assisted static program checker
3** Copyright (C) 1994-2000 University of Virginia,
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**
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
23*/
24/*
25** flagMarker.c
26*/
27
28# include "lclintMacros.nf"
29# include "basic.h"
30
31flagMarker 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
43flagMarker 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
54flagMarker 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
65flagMarker 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
74 return c;
75}
76
77flagMarker flagMarker_createIgnoreOff (fileloc loc)
78{
79 flagMarker c = (flagMarker) dmalloc (sizeof (*c));
80
81 c->kind = FMK_IGNOREOFF;
82 c->code = INVALID_FLAG;
83 c->loc = fileloc_copy (loc);
84
85 return c;
86}
87
88ynm flagMarker_getSet (flagMarker f)
89{
90 llassert (f->kind == FMK_LOCALSET);
91
92 return f->info.set;
93}
94
95flagcode flagMarker_getCode (flagMarker f)
96{
97 llassert (f->kind == FMK_LOCALSET|| f->kind == FMK_SUPPRESS);
98
99 return f->code;
100}
101
102int flagMarker_getCount (flagMarker f)
103{
104 llassert (f->kind == FMK_IGNORECOUNT);
105
106 return f->info.nerrors;
107}
108
109cstring flagMarker_unparse (flagMarker c)
110{
111 switch (c->kind)
112 {
113 case FMK_LOCALSET:
114 return (message ("%q: %s%s",
115 fileloc_unparse (c->loc), ynm_unparseCode (c->info.set),
116 flagcode_name (c->code)));
117 case FMK_IGNORECOUNT:
118 return (message ("%q: ignore count %d",
119 fileloc_unparse (c->loc), c->info.nerrors));
120 case FMK_IGNOREON:
121 return (message ("%q: ignore on",
122 fileloc_unparse (c->loc)));
123 case FMK_IGNOREOFF:
124 return (message ("%q: ignore off",
125 fileloc_unparse (c->loc)));
126 case FMK_SUPPRESS:
127 return (message ("%q: suppress %s",
128 fileloc_unparse (c->loc),
129 flagcode_name (c->code)));
130 }
131
132 BADBRANCH;
133}
134
135void flagMarker_free (/*@only@*/ flagMarker c)
136{
137 sfree (c);
138}
139
140bool flagMarker_sameFile (flagMarker c, fileloc loc)
141{
142 return (fileloc_almostSameFile (c->loc, loc));
143}
144
145/*
146** return true if loc is before c->loc
147*/
148
149bool flagMarker_beforeMarker (flagMarker c, fileloc loc)
150{
151 return (!fileloc_notAfter (c->loc, loc));
152}
153
154
155
This page took 0.07423 seconds and 5 git commands to generate.