[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[creduce-bugs] Segmentation fault clang_delta


I found that clang_delta seems to produce a segmentation fault if the file that should be reduced contains a #define preprocessor directive for a type.
To produce the error this small program is enough:

#define my_type int

my_type my_var;

I ran the following test:
$ clang_delta --transformation=remove-unused-var --counter=1 ./my_prog.c

I figured out that the AST of clang for this program is different from the one generated without the #define statement. I guess the AST representation of my example causes the rewrite to crash.

AST with #define:
$ ./clang+llvm-3.6.0-x86_64-apple-darwin/bin/clang -O0 -Xclang -ast-dump -fsyntax-only my_prog.c
TranslationUnitDecl 0x7ffe39028ec0 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x7ffe390293c0 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
|-TypedefDecl 0x7ffe39029420 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
|-TypedefDecl 0x7ffe39029770 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list '__va_list_tag [1]'
`-VarDecl 0x7ffe390297d0 <my_prog.c:1:17, line:3:9> col:9 my_var ‘int'

AST for the program “int my_var”:
TranslationUnitDecl 0x7f8cf182bcc0 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x7f8cf182c1c0 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
|-TypedefDecl 0x7f8cf182c220 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
|-TypedefDecl 0x7f8cf182c570 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list '__va_list_tag [1]'
`-VarDecl 0x7f8cf182c5d0 <my_other_prog.c:1:1, col:5> col:5 my_var ‘int'

Best regards,