Skip to content

Commit 5c0cda7

Browse files
stahlbauertautschnig
authored andcommitted
Do not dump anonymous types from system headers
Fixes: diffblue#973
1 parent 60cc2ca commit 5c0cda7

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef _WIN32
2+
3+
#include <signal.h>
4+
#include <stdlib.h>
5+
6+
void sig_block(int sig)
7+
{
8+
sigset_t ss;
9+
sigemptyset(&ss);
10+
sigaddset(&ss, sig);
11+
sigprocmask(SIG_BLOCK, &ss, NULL);
12+
}
13+
14+
int main() {
15+
sig_block(0);
16+
return 0;
17+
}
18+
#else
19+
int main()
20+
{
21+
return 0;
22+
}
23+
#endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
main.c
3+
--dump-c --use-system-headers
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
--
9+
This test should be run via chain.sh, which will try to recompile the dumped C
10+
code. Missing/incomplete typedef output would cause a failure.

src/goto-instrument/dump_c.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ void dump_ct::operator()(std::ostream &os)
144144
symbol.type.set(ID_tag, new_tag);
145145
}
146146

147-
// we don't want to dump in full all definitions
148-
if(!tag_added && ignore(symbol))
147+
// we don't want to dump in full all definitions; in particular
148+
// do not dump anonymous types that are defined in system headers
149+
if((!tag_added || symbol.is_type) && ignore(symbol))
149150
continue;
150151

151152
if(!symbols_sorted.insert(name_str).second)
@@ -1025,7 +1026,7 @@ void dump_ct::gather_global_typedefs()
10251026
{
10261027
const symbolt &symbol=symbol_entry.second;
10271028

1028-
if(symbol.is_macro && symbol.is_type && !ignore(symbol) &&
1029+
if(symbol.is_macro && symbol.is_type &&
10291030
symbol.location.get_function().empty())
10301031
{
10311032
const irep_idt &typedef_str=symbol.type.get(ID_C_typedef);

0 commit comments

Comments
 (0)