Various minor fixes for compiler/linter (other then splint itself) warnings.
[splint-patched.git] / src / clause.c
blobd167d93804643bc90f59afac132d5602f201c9c2
1 /*
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 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.
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
25 ** clause.c
28 # include "splintMacros.nf"
29 # include "basic.h"
31 cstring
32 clause_unparse (clause cl)
34 switch (cl)
36 case TRUECLAUSE: return (cstring_makeLiteralTemp ("true"));
37 case FALSECLAUSE: return (cstring_makeLiteralTemp ("false"));
38 case ANDCLAUSE: return (cstring_makeLiteralTemp ("and"));
39 case ORCLAUSE: return (cstring_makeLiteralTemp ("or"));
40 case DOWHILECLAUSE: return (cstring_makeLiteralTemp ("do ... while"));
41 case WHILECLAUSE: return (cstring_makeLiteralTemp ("while"));
42 case ITERCLAUSE: return (cstring_makeLiteralTemp ("iter"));
43 case FORCLAUSE: return (cstring_makeLiteralTemp ("for"));
44 case CASECLAUSE: return (cstring_makeLiteralTemp ("case"));
45 case NOCLAUSE: return (cstring_makeLiteralTemp ("none"));
46 case SWITCHCLAUSE: return (cstring_makeLiteralTemp ("switch"));
47 case CONDCLAUSE: return (cstring_makeLiteralTemp ("cond"));
48 case TRUEEXITCLAUSE: return (cstring_makeLiteralTemp ("trueexit"));
49 case FALSEEXITCLAUSE: return (cstring_makeLiteralTemp ("falseexit"));
52 BADBRANCHRET (cstring_undefined);
55 cstring
56 clause_nameTaken (clause cl)
58 switch (cl)
60 case TRUECLAUSE: return (cstring_makeLiteralTemp ("in true branch"));
61 case FALSECLAUSE: return (cstring_makeLiteralTemp ("in true branch"));
62 case ANDCLAUSE: return (cstring_makeLiteralTemp ("in first and clause"));
63 case ORCLAUSE: return (cstring_makeLiteralTemp ("in first or clause"));
64 case DOWHILECLAUSE: return (cstring_makeLiteralTemp ("in do ... while body"));
65 case WHILECLAUSE: return (cstring_makeLiteralTemp ("in while body"));
66 case ITERCLAUSE: return (cstring_makeLiteralTemp ("in iter body"));
67 case FORCLAUSE: return (cstring_makeLiteralTemp ("in for body"));
68 case CASECLAUSE: return (cstring_makeLiteralTemp ("in one case"));
69 case NOCLAUSE: return (cstring_makeLiteralTemp ("in some clause"));
70 case SWITCHCLAUSE: return (cstring_makeLiteralTemp ("in one possible execution"));
71 case CONDCLAUSE: return (cstring_makeLiteralTemp ("in true condition"));
72 case TRUEEXITCLAUSE: return (cstring_makeLiteralTemp ("in trueexit"));
73 case FALSEEXITCLAUSE: return (cstring_makeLiteralTemp ("in falseexit"));
76 BADBRANCHRET (cstring_undefined);
79 cstring
80 clause_nameAlternate (clause cl)
82 switch (cl)
84 case TRUECLAUSE: return (cstring_makeLiteralTemp ("in continuation"));
85 case FALSECLAUSE: return (cstring_makeLiteralTemp ("in false branch"));
86 case ANDCLAUSE: return (cstring_makeLiteralTemp ("in second and clause"));
87 case ORCLAUSE: return (cstring_makeLiteralTemp ("in second or clause"));
88 case DOWHILECLAUSE: return (cstring_makeLiteralTemp ("if loop is not taken"));
89 case WHILECLAUSE: return (cstring_makeLiteralTemp ("if loop is not taken"));
90 case ITERCLAUSE: return (cstring_makeLiteralTemp ("if iter body does not execute"));
91 case FORCLAUSE: return (cstring_makeLiteralTemp ("if for loop body does not execute"));
92 case CASECLAUSE: return (cstring_makeLiteralTemp ("in other case"));
93 case NOCLAUSE:
94 case SWITCHCLAUSE: return (cstring_makeLiteralTemp ("in other possible execution"));
95 case CONDCLAUSE: return (cstring_makeLiteralTemp ("in false condition"));
96 case TRUEEXITCLAUSE: return (cstring_makeLiteralTemp ("in trueexit"));
97 case FALSEEXITCLAUSE: return (cstring_makeLiteralTemp ("in falseexit"));
100 BADBRANCHRET (cstring_undefined);
103 cstring clause_nameFlip (clause cl, bool flip)
105 if (flip)
107 return clause_nameAlternate (cl);
109 else
111 return clause_nameTaken (cl);
115 bool clause_isBreakable (clause cl)
117 return (cl == SWITCHCLAUSE
118 || cl == WHILECLAUSE
119 || cl == DOWHILECLAUSE
120 || cl == FORCLAUSE
121 || cl == ITERCLAUSE);
124 bool clause_isLoop (clause cl)
126 return (cl == WHILECLAUSE
127 || cl == FORCLAUSE
128 || cl == ITERCLAUSE
129 || cl == DOWHILECLAUSE);
132 bool clause_isConditional (clause cl)
134 return ( cl == TRUECLAUSE
135 || cl == FALSECLAUSE
136 || cl == WHILECLAUSE
137 || cl == FORCLAUSE
138 || cl == SWITCHCLAUSE
139 || cl == ITERCLAUSE);
142 bool clause_isSwitch (clause cl)
144 return (cl == SWITCHCLAUSE);
147 bool clause_isCase (clause cl)
149 return (cl == CASECLAUSE);
152 bool clause_isNone (clause cl)
154 return (cl == NOCLAUSE);