1 /* $NetBSD: lint2.h,v 1.2 1995/07/03 21:24:49 cgd Exp $ */
4 * Copyright (c) 1994, 1995 Jochen Pohl
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Jochen Pohl for
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * $DragonFly: src/usr.bin/xlint/lint2/lint2.h,v 1.2 2004/07/07 12:24:01 asmodai Exp $
39 * Types are described by structures of type type_t.
42 tspec_t t_tspec
; /* type specifier */
43 u_int t_const
: 1; /* constant */
44 u_int t_volatile
: 1; /* volatile */
45 u_int t_vararg
: 1; /* function has variable number of arguments */
46 u_int t_isenum
: 1; /* enum type */
47 u_int t_proto
: 1; /* this is a prototype */
48 u_int t_istag
: 1; /* tag with _t_tag valid */
49 u_int t_istynam
: 1; /* tag with _t_tynam valid */
51 int _t_dim
; /* if the type is an ARRAY than this
52 is the dimension of the array. */
53 struct hte
*_t_tag
; /* hash table entry of tag if
54 t_isenum, STRUCT or UNION */
55 struct hte
*_t_tynam
; /* hash table entry of typename if
56 t_isenum, STRUCT or UNION */
57 struct type
**_t_args
; /* list of argument types if this
60 struct type
*t_subt
; /* indirected type (array element, pointed to
61 type, type of return value) */
64 #define t_dim t_u._t_dim
65 #define t_tag t_u._t_tag
66 #define t_tynam t_u._t_tynam
67 #define t_args t_u._t_args
70 * argument information
72 * Such a structure is created for each argument of a function call
73 * which is an integer constant or a constant string.
75 typedef struct arginf
{
76 int a_num
; /* # of argument (1..) */
77 u_int a_zero
: 1; /* argument is 0 */
78 u_int a_pcon
: 1; /* msb of argument is not set */
79 u_int a_ncon
: 1; /* msb of argument is set */
80 u_int a_fmt
: 1; /* a_fstrg points to format string */
81 char *a_fstrg
; /* format string */
82 struct arginf
*a_nxt
; /* information for next const. argument */
86 * Keeps information about position in source file.
89 u_short p_src
; /* index of name of translation unit
90 (the name which was specified at the
92 u_short p_line
; /* line number in p_src */
93 u_short p_isrc
; /* index of (included) file */
94 u_short p_iline
; /* line number in p_iline */
98 * Used for definitions and declarations
100 * To save memory, variable sized structures are used. If
101 * all s_va, s_prfl and s_scfl are not set, the memory allocated
102 * for a symbol is only large enough to keep the first member of
107 pos_t s_pos
; /* pos of def./decl. */
109 u_int s_def
: 3; /* DECL, TDEF or DEF */
113 u_int s_rval
: 1; /* function has return value */
114 u_int s_osdef
: 1; /* old style function definition */
115 u_int s_static
: 1; /* symbol is static */
116 u_int s_va
: 1; /* check only first s_nva arguments */
117 u_int s_prfl
: 1; /* printflike */
118 u_int s_scfl
: 1; /* scanflike */
119 u_short s_type
; /* type */
120 struct sym
*s_nxt
; /* next symbol with same name */
127 #define s_pos s_s.s_pos
128 #define s_rval s_s.s_rval
129 #define s_osdef s_s.s_osdef
130 #define s_static s_s.s_static
131 #define s_def s_s.s_def
132 #define s_va s_s.s_va
133 #define s_prfl s_s.s_prfl
134 #define s_scfl s_s.s_scfl
135 #define s_type s_s.s_type
136 #define s_nxt s_s.s_nxt
139 * Used to store informations about function calls.
141 typedef struct fcall
{
142 pos_t f_pos
; /* position of call */
143 u_int f_rused
: 1; /* return value used */
144 u_int f_rdisc
: 1; /* return value discarded (casted to void) */
145 u_short f_type
; /* types of expected return value and args */
146 arginf_t
*f_args
; /* information about constant arguments */
147 struct fcall
*f_nxt
; /* next call of same function */
151 * Used to store information about usage of symbols other
152 * than for function calls.
154 typedef struct usym
{
155 pos_t u_pos
; /* position */
156 struct usym
*u_nxt
; /* next usage */
163 const char *h_name
; /* name */
164 u_int h_used
: 1; /* symbol is used */
165 u_int h_def
: 1; /* symbol is defined */
166 u_int h_static
: 1; /* static symbol */
167 sym_t
*h_syms
; /* declarations and definitions */
168 sym_t
**h_lsym
; /* points to s_nxt of last decl./def. */
169 fcall_t
*h_calls
; /* function calls */
170 fcall_t
**h_lcall
; /* points to f_nxt of last call */
171 usym_t
*h_usyms
; /* usage info */
172 usym_t
**h_lusym
; /* points to u_nxt of last usage info */
173 struct hte
*h_link
; /* next hte with same hash function */
176 /* maps type indices into pointers to type structs */
177 #define TP(idx) (tlst[idx])
179 #include "externs2.h"