Bug 439685 compiler warning in callgrind/main.c
[valgrind.git] / coregrind / m_debuginfo / priv_tytypes.h
blob787c57870449efd05aa3b9ace6c80f93d300fc07
2 /*--------------------------------------------------------------------*/
3 /*--- Representation of source level types. priv_tytypes.h ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2008-2017 OpenWorks LLP
11 info@open-works.co.uk
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
28 Neither the names of the U.S. Department of Energy nor the
29 University of California nor the names of its contributors may be
30 used to endorse or promote products derived from this software
31 without prior written permission.
34 #ifndef __PRIV_TYTYPES_H
35 #define __PRIV_TYTYPES_H
37 #include "pub_core_basics.h" // UWord
38 #include "pub_core_xarray.h" // XArray
39 #include "priv_misc.h" // MaybeULong
41 typedef
42 enum {
43 Te_EMPTY=10, /* empty (contains no info) */
44 Te_INDIR, /* indirection to some other TyEnt */
45 Te_UNKNOWN, /* denotes a unknown type/field/whatever */
46 Te_Atom, /* name & 64-bit const, iow, enumeration member */
47 Te_Field, /* struct/class field defn */
48 Te_Bound, /* array bounds indication, for one dimension */
49 Te_TyBase, /* base type */
50 Te_TyPtr, /* pointer type */
51 Te_TyRef, /* reference type */
52 Te_TyPtrMbr, /* pointer to member type */
53 Te_TyRvalRef,/* rvalue reference type */
54 Te_TyTyDef, /* a renaming of some other type */
55 Te_TyStOrUn, /* structure or union type */
56 Te_TyEnum, /* an enum type */
57 Te_TyArray, /* an array type */
58 Te_TyFn, /* function type */
59 Te_TyQual, /* qualified type */
60 Te_TyVoid /* void type */
62 TyEntTag;
64 /* Fields ending in "R" are references to other TyEnts. Fields ending
65 in "Rs" are XArray*s of references to other TyEnts. */
66 typedef
67 struct {
68 UWord cuOff;
69 TyEntTag tag;
70 union {
71 struct {
72 } EMPTY;
73 struct {
74 UWord indR;
75 } INDIR;
76 struct {
77 } UNKNOWN;
78 struct {
79 HChar* name; /* in mallocville */
80 Bool valueKnown; /* atoms w/ unknown value are possible */
81 Long value;
82 } Atom;
83 struct {
84 HChar* name; /* in mallocville */
85 UWord typeR; /* should be Te_TyXXXX */
86 union {
87 UChar* loc; /* location expr, in mallocville */
88 Word offset; /* or offset from the beginning of containing
89 entity */
90 } pos;
91 Word nLoc; /* number of bytes in .pos.loc if >= 0, or -1
92 if .pos.offset should be used instead */
93 Bool isStruct;
94 } Field;
95 struct {
96 Bool knownL;
97 Bool knownU;
98 Long boundL;
99 Long boundU;
100 } Bound;
101 struct {
102 HChar* name; /* in mallocville */
103 Int szB;
104 UChar enc; /* S:signed U:unsigned F:floating C:complex float */
105 } TyBase;
106 struct {
107 Int szB;
108 UWord typeR;
109 } TyPorR;
110 struct {
111 HChar* name; /* in mallocville */
112 UWord typeR; /* MAY BE D3_INVALID_CUOFF, denoting unknown */
113 } TyTyDef;
114 struct {
115 HChar* name; /* in mallocville */
116 UWord szB;
117 UWord typeR;
118 XArray* /* of UWord */ fieldRs;
119 Bool complete;
120 Bool isStruct;
121 } TyStOrUn;
122 struct {
123 HChar* name; /* in mallocville */
124 Int szB;
125 XArray* /* of UWord */ atomRs;
126 } TyEnum;
127 struct {
128 UWord typeR;
129 XArray* /* of UWord */ boundRs;
130 } TyArray;
131 struct {
132 } TyFn;
133 struct {
134 UChar qual; /* C:const V:volatile R:restrict */
135 UWord typeR;
136 } TyQual;
137 struct {
138 Bool isFake; /* True == introduced by the reader */
139 } TyVoid;
140 } Te;
142 TyEnt;
144 /* Does this TyEnt denote a type, as opposed to some other kind of
145 thing? */
146 Bool ML_(TyEnt__is_type)( const TyEnt* );
148 /* Print a TyEnt, debug-style. */
149 void ML_(pp_TyEnt)( const TyEnt* );
151 /* Print a whole XArray of TyEnts, debug-style */
152 void ML_(pp_TyEnts)( const XArray* tyents, const HChar* who );
154 /* Print a TyEnt, C style, chasing stuff as necessary. */
155 void ML_(pp_TyEnt_C_ishly)( const XArray* /* of TyEnt */ tyents,
156 UWord cuOff );
158 /* Generates a total ordering on TyEnts based only on their .cuOff
159 fields. */
160 Word ML_(TyEnt__cmp_by_cuOff_only) ( const TyEnt* te1, const TyEnt* te2 );
162 /* Generates a total ordering on TyEnts based on everything except
163 their .cuOff fields. */
164 Word ML_(TyEnt__cmp_by_all_except_cuOff) ( const TyEnt* te1, const TyEnt* te2 );
166 /* Free up all directly or indirectly heap-allocated stuff attached to
167 this TyEnt, and set its tag to Te_EMPTY. The .cuOff field is
168 unchanged. */
169 void ML_(TyEnt__make_EMPTY) ( TyEnt* te );
171 /* How big is this type? If .b in the returned struct is False, the
172 size is unknown. */
174 MaybeULong ML_(sizeOfType)( const XArray* /* of TyEnt */ tyents,
175 UWord cuOff );
177 /* Describe where in the type 'offset' falls. Caller must
178 deallocate the resulting XArray. */
179 XArray* /*UChar*/ ML_(describe_type)( /*OUT*/PtrdiffT* residual_offset,
180 const XArray* /* of TyEnt */ tyents,
181 UWord ty_cuOff,
182 PtrdiffT offset );
185 /* A fast-lookup cache for ML_(TyEnts__index_by_cuOff). Nothing
186 particularly surprising here; it's 2 way set associative, with some
187 number of ways, doesn't particularly have to be a power of 2. In
188 order to have a way to indicate an invalid entry, we set the second
189 value of the pair to NULL, and keep checking for it, since
190 unfortunately there's no obvious cuOff number that we could put in
191 the first word of the pair that could indicate an invalid entry.
193 4096 arrived at as the best value for an E6600 loading Qt-4.4.1
194 Designer and all associated libraries, compiled by gcc-4.3.1,
195 -g -O, 64-bit, which is at least a moderately good stress test,
196 with the largest library being about 150MB.*/
198 #define N_TYENT_INDEX_CACHE 4096
200 typedef
201 struct {
202 struct { UWord cuOff0; TyEnt* ent0;
203 UWord cuOff1; TyEnt* ent1; }
204 ce[N_TYENT_INDEX_CACHE];
206 TyEntIndexCache;
208 void ML_(TyEntIndexCache__invalidate) ( TyEntIndexCache* cache );
210 /* 'ents' is an XArray of TyEnts, sorted by their .cuOff fields. Find
211 the entry which has .cuOff field as specified. Returns NULL if not
212 found. Asserts if more than one entry has the specified .cuOff
213 value. */
214 TyEnt* ML_(TyEnts__index_by_cuOff) ( const XArray* /* of TyEnt */ ents,
215 TyEntIndexCache* cache,
216 UWord cuOff_to_find );
218 #endif /* ndef __PRIV_TYTYPES_H */
220 /*--------------------------------------------------------------------*/
221 /*--- end priv_tytypes.h ---*/
222 /*--------------------------------------------------------------------*/