Closed 69567272 closed 5 years ago
Hello @69567272 ,
Could you run c4go ast prime.c
. Do you see ast dump?
Could you clarify version of clang clang --version
? Allowable version : clang
from 3.4 to 7
Hello, Thank for you reply! 1、[root@localhost c4go]# clang --version clang version 3.4.2 (tags/RELEASE_34/dot2-final) Target: x86_64-redhat-linux-gnu Thread model: posix
2、 c4go ast prime.c //It can be executed,But I don't understand it very well.
[root@localhost examples]# c4go ast prime.c
TranslationUnitDecl 0x1ea6d70 <-FieldDecl 0x1ef16f0 <line:92:5, col:18> __wchb 'char [4]' |
-FieldDecl 0x1ef1790 <line:85:3, line:93:5> value 'union <anonymous union at /usr/include/wchar.h:85:3>':'union mbstate_t::<anonymous at /usr/include/wchar.h:85:3>'
|-TypedefDecl 0x1ef1830 <line:82:1, line:94:3> mbstate_t 'struct __mbstate_t':'mbstate_t'
|-RecordDecl 0x1ef1890 </usr/include/_G_config.h:21:9, line:25:1> struct definition
| |-FieldDecl 0x1ef1960 <line:23:3, col:11> pos 'off_t':'long'
| -FieldDecl 0x1ef19e0 <line:24:3, col:15> __state '__mbstate_t':'__mbstate_t' |-TypedefDecl 0x1ef1a80 <line:21:1, line:25:3> _G_fpos_t 'struct _G_fpos_t':'_G_fpos_t' |-RecordDecl 0x1ef1ae0 <line:26:9, line:30:1> struct definition | |-FieldDecl 0x1ef1b90 <line:28:3, col:13> __pos '__off64_t':'long' |
-FieldDecl 0x1ef1bf0 <line:29:3, col:15> state 'mbstate_t':'mbstate_t'
|-TypedefDecl 0x1ef1c90 <line:26:1, line:30:3> _G_fpos64_t 'struct _G_fpos64_t':'_G_fpos64_t'
|-TypedefDecl 0x1ef1d20 </usr/bin/../lib/clang/3.4.2/include/stdarg.h:30:1, col:27> va_list 'builtin_va_list':'va_list_tag [1]'
|-TypedefDecl 0x1ef1d80 <line:48:1, col:27> gnuc_va_list 'builtin_va_list':'__va_list_tag [1]'
|-RecordDecl 0x1ef1dd0 </usr/include/libio.h:145:1, col:8> struct _IO_jump_t
|-RecordDecl 0x1ef1e70 prev 0x1ef12c0 <col:20, col:27> struct _IO_FILE
|-TypedefDecl 0x1ef1f00 <line:155:1, col:14> _IO_lock_t 'void'
|-RecordDecl 0x1ef2b70 <line:161:1, line:178:1> struct _IO_marker definition
| |-FieldDecl 0x1ef2cc0 <line:162:3, col:22> _next 'struct _IO_marker '
| |-FieldDecl 0x1ef2d90 <line:163:3, col:20> _sbuf 'struct _IO_FILE '
| `-FieldDecl 0x1ef2df0 <line:167:3, col:7> _pos 'int'
|-EnumDecl 0x1ef2e40 <line:181:1, line:187:1> codecvt_result
| |-EnumConstantDecl 0x1ef2ef0 -EnumConstantDecl 0x1ef2fe0 <line:186:3> __codecvt_noconv 'int' |-RecordDecl 0x1ef3030 prev 0x1ef1e70 <line:246:1, line:313:1> struct _IO_FILE definition | |-FieldDecl 0x1ef30c0 <line:247:3, col:7> _flags 'int' | |-FieldDecl 0x1ef3120 <line:252:3, col:9> _IO_read_ptr 'char *' | |-FieldDecl 0x1ef3180 <line:253:3, col:9> _IO_read_end 'char *' | |-FieldDecl 0x1ef31e0 <line:254:3, col:9> _IO_read_base 'char *' | |-FieldDecl 0x1ef3240 <line:255:3, col:9> _IO_write_base 'char *' | |-FieldDecl 0x1ef32a0 <line:256:3, col:9> _IO_write_ptr 'char *' | |-FieldDecl 0x1ef3300 <line:257:3, col:9> _IO_write_end 'char *' | |-FieldDecl 0x1ef3360 <line:258:3, col:9> _IO_buf_base 'char *' | |-FieldDecl 0x1ef33c0 <line:259:3, col:9> _IO_buf_end 'char *' | |-FieldDecl 0x1ef3420 <line:261:3, col:9> _IO_save_base 'char *' | |-FieldDecl 0x1ef3480 <line:262:3, col:9> _IO_backup_base 'char *' | |-FieldDecl 0x1ef34e0 <line:263:3, col:9> _IO_save_end 'char *' | |-FieldDecl 0x1ef3550 <line:265:3, col:22> _markers 'struct _IO_marker *' | |-FieldDecl 0x1ef35c0 <line:267:3, col:20> _chain 'struct _IO_FILE *' | |-FieldDecl 0x1ef3620 <line:269:3, col:7> _fileno 'int' | |-FieldDecl 0x1ef3680 <line:273:3, col:7> _flags2 'int' | |-FieldDecl 0x1ef36e0 <line:275:3, col:11> _old_offset '__off_t':'long' | |-FieldDecl 0x1ef3740 <line:279:3, col:18> _cur_column 'unsigned short' | |-FieldDecl 0x1ef37a0 <line:280:3, col:15> _vtable_offset 'signed char' | |-FieldDecl 0x1ef3870 <line:281:3, col:19> _shortbuf 'char [1]' | |-FieldDecl 0x1ef3920 <line:285:3, col:15> _lock '_IO_lock_t *' | |-FieldDecl 0x1ef3980 <line:294:3, col:13> _offset '__off64_t':'long' | |-FieldDecl 0x1ef39e0 <line:303:3, col:9> __pad1 'void *' | |-FieldDecl 0x1ef3a40 <line:304:3, col:9> __pad2 'void *' | |-FieldDecl 0x1ef3aa0 <line:305:3, col:9> __pad3 'void *' | |-FieldDecl 0x1ef3b00 <line:306:3, col:9> __pad4 'void *' | |-FieldDecl 0x1ef3bb0 <line:307:3, col:10> __pad5 'size_t':'unsigned long' | |-FieldDecl 0x1ef3c10 <line:309:3, col:7> _mode 'int' |
-FieldDecl 0x1ef3e60 <line:311:3, col:74> _unused2 'char [20]'
|-TypedefDecl 0x1ef3ed0 <line:316:1, col:25> _IO_FILE 'struct _IO_FILE':'struct _IO_FILE'
|-RecordDecl 0x1ef3f20 <line:319:1, col:8> struct _IO_FILE_plus
|-VarDecl 0x1ef4010 <line:321:1, col:29> _IO_2_1stdin 'struct _IO_FILE_plus':'struct _IO_FILE_plus' extern
|-VarDecl 0x1ef4090 <line:322:1, col:29> _IO_2_1stdout 'struct _IO_FILE_plus':'struct _IO_FILE_plus' extern
|-VarDecl 0x1ef4110 <line:323:1, col:29> _IO_2_1stderr 'struct _IO_FILE_plus':'struct _IO_FILE_plus' extern
|-TypedefDecl 0x1ef43b0 <line:339:1, col:77> io_read_fn 'ssize_t (void , char , size_t)'
|-TypedefDecl 0x1ef4650 <line:347:1, line:348:16> io_write_fn 'ssize_t (void , const char , size_t)'
|-TypedefDecl 0x1ef48f0 <line:356:1, col:68> io_seek_fn 'int (void *, off64_t , int)'
|-TypedefDecl 0x1ef4a10 <line:359:1, col:42> __io_close_fn 'int (void )'
|-TypedefDecl 0x1ef4a90 <line:364:1, col:22> cookie_read_function_t 'io_read_fn':'ssize_t (void , char , size_t)'
|-TypedefDecl 0x1ef4b10 <line:365:1, col:23> cookie_write_function_t 'io_write_fn':'ssize_t (void , const char , size_t)'
|-TypedefDecl 0x1efbbf0 <line:366:1, col:22> cookie_seek_function_t 'io_seek_fn':'int (void *, off64_t , int)'
|-TypedefDecl 0x1efbc70 <line:367:1, col:23> cookie_close_function_t '__io_close_fn':'int (void )'
|-RecordDecl 0x1efbcc0 <line:370:9, line:376:1> struct definition
| |-FieldDecl 0x1efbdd0 <line:372:3, col:17> read 'io_read_fn *'
| |-FieldDecl 0x1efbe90 <line:373:3, col:18> write 'io_write_fn '
| |-FieldDecl 0x1efbf50 <line:374:3, col:17> seek '__io_seek_fn '
| -FieldDecl 0x1efc010 <line:375:3, col:18> close '__io_close_fn *' |-TypedefDecl 0x1efc0b0 <line:370:1, line:376:3> _IO_cookie_io_functions_t 'struct _IO_cookie_io_functions_t':'_IO_cookie_io_functions_t' |-TypedefDecl 0x1efc140 <line:377:1, col:35> cookie_io_functions_t '_IO_cookie_io_functions_t':'_IO_cookie_io_functions_t' |-RecordDecl 0x1efc190 <line:379:1, col:8> struct _IO_cookie_file |-FunctionDecl 0x1efc570 <line:382:1, line:383:56> _IO_cookie_init 'void (struct _IO_cookie_file *, int, void *, _IO_cookie_io_functions_t)' extern | |-ParmVarDecl 0x1efc2e0 <line:382:30, col:54> __cfile 'struct _IO_cookie_file *' | |-ParmVarDecl 0x1efc350 <col:63, col:67> __read_write 'int' | |-ParmVarDecl 0x1efc3c0 <line:383:9, col:15> __cookie 'void *' |
-ParmVarDecl 0x1efc430 <col:25, col:51> fns '_IO_cookie_io_functions_t':'_IO_cookie_io_functions_t'
|-FunctionDecl 0x1efc790 <line:391:1, col:35> underflow 'int (_IO_FILE )' extern
| `-ParmVarDecl 0x1efc690 <col:25, col:35> '_IO_FILE '
|-FunctionDecl 0x1efc8d0 <line:392:1, col:31> uflow 'int (_IO_FILE )' extern
| `-ParmVarDecl 0x1efc850 <col:21, col:31> '_IO_FILE '
|-FunctionDecl 0x1efcb10 <line:393:1, col:39> overflow 'int (_IO_FILE , int)' extern
| |-ParmVarDecl 0x1efc990 <col:24, col:34> '_IO_FILE '
| -ParmVarDecl 0x1efca00 <col:36, col:39> 'int' |-FunctionDecl 0x1efcc70 <line:435:1, col:36> _IO_getc 'int (_IO_FILE *)' extern |
-ParmVarDecl 0x1efcbf0 <col:22, col:32> fp '_IO_FILE '
|-FunctionDecl 0x1efceb0 <line:436:1, col:45> _IO_putc 'int (int, _IO_FILE )' extern
| |-ParmVarDecl 0x1efcd30 <col:22, col:26> c 'int'
| -ParmVarDecl 0x1efcda0 <col:31, col:41> __fp '_IO_FILE *' |-FunctionDecl 0x1efcff0 <line:437:1, col:66> _IO_feof 'int (_IO_FILE *)' extern | |-ParmVarDecl 0x1efcf70 <col:22, col:32> __fp '_IO_FILE *' |
-NoThrowAttr 0x1efd0a0 -NoThrowAttr 0x1efd220 <col:56> |-FunctionDecl 0x1efd2f0 <line:440:1, col:44> _IO_peekc_locked 'int (_IO_FILE *)' extern |
-ParmVarDecl 0x1efd270 <col:30, col:40> fp '_IO_FILE '
|-FunctionDecl 0x1efd4b0 <line:446:1, col:68> _IO_flockfile 'void (_IO_FILE )' extern
| |-ParmVarDecl 0x1efd3b0 <col:28, col:38> '_IO_FILE '
| `-NoThrowAttr 0x1efd560 -ParmVarDecl 0x1f00010 <col:46, col:52> 'size_t':'unsigned long' |-FunctionDecl 0x1f004a0 <line:472:1, col:62> _IO_seekoff '__off64_t (_IO_FILE *, __off64_t, int, int)' extern | |-ParmVarDecl 0x1f00210 <col:31, col:41> '_IO_FILE *' | |-ParmVarDecl 0x1f00280 <col:43, col:52> '__off64_t':'long' | |-ParmVarDecl 0x1f002f0 <col:54, col:57> 'int' |
-ParmVarDecl 0x1f00360 <col:59, col:62> 'int'
|-FunctionDecl 0x1f01020 <line:473:1, col:57> _IO_seekpos 'off64_t (_IO_FILE , __off64_t, int)' extern
| |-ParmVarDecl 0x1f00570 <col:31, col:41> '_IO_FILE '
| |-ParmVarDecl 0x1f005e0 <col:43, col:52> 'off64_t':'long'
| -ParmVarDecl 0x1f00650 <col:54, col:57> 'int' |-FunctionDecl 0x1f01170 <line:475:1, col:75> _IO_free_backup_area 'void (_IO_FILE *)' extern | |-ParmVarDecl 0x1f010f0 <col:35, col:45> '_IO_FILE *' |
-NoThrowAttr 0x1f01220 -NoThrowAttr 0x1f01a20 <col:74> |-FunctionDecl 0x1f01cb0 <line:185:1, line:186:55> renameat 'int (int, const char *, int, const char *)' extern | |-ParmVarDecl 0x1f01a70 <line:185:22, col:26> __oldfd 'int' | |-ParmVarDecl 0x1f01ae0 <col:35, col:47> __old 'const char *' | |-ParmVarDecl 0x1f01b50 <col:54, col:58> __newfd 'int' | |-ParmVarDecl 0x1f01bc0 <line:186:8, col:20> __new 'const char *' |
-NoThrowAttr 0x1f01d70 -ParmVarDecl 0x1f026a0 <col:20, col:26> __stream 'FILE *' |-FunctionDecl 0x1f028a0 <line:242:1, col:34> fflush 'int (FILE *)' extern |
-ParmVarDecl 0x1f02820 <col:20, col:26> stream 'FILE '
|-FunctionDecl 0x1f029e0 <line:252:1, col:43> fflush_unlocked 'int (FILE )' extern
| -ParmVarDecl 0x1f02960 <col:29, col:35> __stream 'FILE *' |-FunctionDecl 0x1f02b50 <line:262:1, col:27> fcloseall 'int (void)' extern |-FunctionDecl 0x1f02d80 <line:272:1, line:273:37> fopen 'FILE *(const char *restrict, const char *restrict)' extern | |-ParmVarDecl 0x1f02c00 <line:272:21, col:44> __filename 'const char *restrict' |
-ParmVarDecl 0x1f02c70 <line:273:7, col:30> modes 'const char restrict'
|-FunctionDecl 0x1f03080 <line:278:1, line:280:34> freopen 'FILE (const char restrict, const char restrict, FILE *restrict)' extern
| |-ParmVarDecl 0x1f02e40 <line:278:23, col:46> filename 'const char restrict'
| |-ParmVarDecl 0x1f02eb0 <line:279:9, col:32> __modes 'const char restrict'
| -ParmVarDecl 0x1f02f20 <line:280:9, col:26> __stream 'FILE *restrict' |-FunctionDecl 0x1f03250 <line:297:1, line:298:39> fopen64 'FILE *(const char *restrict, const char *restrict)' extern | |-ParmVarDecl 0x1f03150 <line:297:23, col:46> __filename 'const char *restrict' |
-ParmVarDecl 0x1f031c0 <line:298:9, col:32> modes 'const char restrict'
|-FunctionDecl 0x1f03480 <line:299:1, line:301:29> freopen64 'FILE (const char restrict, const char restrict, FILE *restrict)' extern
| |-ParmVarDecl 0x1f03310 <line:299:25, col:48> filename 'const char restrict'
| |-ParmVarDecl 0x1f03380 <line:300:4, col:27> __modes 'const char restrict'
| -ParmVarDecl 0x1f033f0 <line:301:4, col:21> __stream 'FILE *restrict' |-FunctionDecl 0x1f036d0 <line:306:1, col:81> fdopen 'FILE *(int, const char *)' extern | |-ParmVarDecl 0x1f03550 <col:22, col:26> __fd 'int' | |-ParmVarDecl 0x1f035c0 <col:32, col:44> __modes 'const char *' |
-NoThrowAttr 0x1f03780 -NoThrowAttr 0x1f03dc0 <line:320:19> |-FunctionDecl 0x1f06fe0 <line:325:1, col:94> open_memstream 'FILE *(char **, size_t *)' extern | |-ParmVarDecl 0x1f03e40 <col:30, col:37> __bufloc 'char **' | |-ParmVarDecl 0x1f03f10 <col:47, col:55> __sizeloc 'size_t *' |
-NoThrowAttr 0x1f07090 -NoThrowAttr 0x1f079d0 <col:41> |-FunctionDecl 0x1f07ae0 <line:347:1, col:69> setlinebuf 'void (FILE *)' extern | |-ParmVarDecl 0x1f07a20 <col:25, col:31> __stream 'FILE *' |
-NoThrowAttr 0x1f07b90 -FormatAttr 0x1f07f10 <col:12> printf 2 3 |-FunctionDecl 0x1f07ff0 prev 0x1f07da0 <col:1, line:357:43> fprintf 'int (FILE *, const char *, ...)' extern | |-ParmVarDecl 0x1f07be0 <line:356:21, col:38> __stream 'FILE *restrict' | |-ParmVarDecl 0x1f07c50 <line:357:7, col:30> __format 'const char *restrict' |
-FormatAttr 0x1f080d0 -FormatAttr 0x1f08310 <col:12> printf 1 2 |-FunctionDecl 0x1f08360 prev 0x1f08210 <col:1, col:56> printf 'int (const char *, ...)' extern | |-ParmVarDecl 0x1f08110 <col:20, col:43> __format 'const char *restrict' |
-FormatAttr 0x1f08430 -FormatAttr 0x1f08760 <col:12> printf 2 3 |-FunctionDecl 0x1f087b0 prev 0x1f085f0 <col:1, line:365:73> sprintf 'int (char *, const char *, ...)' extern | |-ParmVarDecl 0x1f08470 <line:364:21, col:38> __s 'char *restrict' | |-ParmVarDecl 0x1f084e0 <line:365:7, col:30> __format 'const char *restrict' | |-NoThrowAttr 0x1f08860 <col:61> |
-FormatAttr 0x1f088a0 -FormatAttr 0x1f08b70 <col:12> printf 2 0 |-FunctionDecl 0x1f08bc0 prev 0x1f08ad0 <col:1, line:372:28> vfprintf 'int (FILE *restrict, const char *restrict, __va_list_tag *)' extern | |-ParmVarDecl 0x1f088e0 <line:371:22, col:39> __s 'FILE *restrict' | |-ParmVarDecl 0x1f08950 <col:44, col:67> __format 'const char *restrict' | |-ParmVarDecl 0x1f089c0 <line:372:8, col:23> __arg '__va_list_tag *':'__va_list_tag *' |
-FormatAttr 0x1f08ca0 -FormatAttr 0x1f09070 <col:12> printf 1 0 |-FunctionDecl 0x1f090c0 prev 0x1f08ea0 <col:1, col:74> vprintf 'int (const char *, __va_list_tag *)' extern | |-ParmVarDecl 0x1f08ce0 <col:21, col:44> __format 'const char *restrict' | |-ParmVarDecl 0x1f08d50 <col:54, col:69> __arg '__va_list_tag *':'__va_list_tag *' |
-FormatAttr 0x1f091a0 -NoThrowAttr 0x1f0a490 <col:22> |-FunctionDecl 0x1f0a720 <line:399:1, line:401:82> vasprintf 'int (char **restrict, const char *restrict, __va_list_tag *)' extern | |-ParmVarDecl 0x1f0a4c0 <line:399:23, col:41> __ptr 'char **restrict' | |-ParmVarDecl 0x1f0a530 <col:48, col:71> __f 'const char *restrict' | |-ParmVarDecl 0x1f0a5a0 <line:400:9, col:24> __arg '__va_list_tag *':'__va_list_tag *' | |-FormatAttr 0x1f0a7e0 <line:401:52, col:80> printf 2 0 |
-NoThrowAttr 0x1f0a830 -FormatAttr 0x1f0b160 <line:414:22, col:50> printf 2 0 |-FunctionDecl 0x1f0b390 <line:415:1, line:416:52> dprintf 'int (int, const char *restrict, ...)' extern | |-ParmVarDecl 0x1f0b1c0 <line:415:21, col:25> __fd 'int' | |-ParmVarDecl 0x1f0b230 <col:31, col:54> __fmt 'const char *restrict' |
-FormatAttr 0x1f0b440 <line:416:22, col:50> printf 2 3
|-FunctionDecl 0x1f0b5a0 -FormatAttr 0x1f0b710 <col:12> scanf 2 3 |-FunctionDecl 0x1f0b760 prev 0x1f0b5a0 <col:1, line:426:42> fscanf 'int (FILE *restrict, const char *restrict, ...)' extern | |-ParmVarDecl 0x1f0b4a0 <line:425:20, col:37> __stream 'FILE *restrict' | |-ParmVarDecl 0x1f0b510 <line:426:6, col:29> __format 'const char *restrict' |
-FormatAttr 0x1f0b840 -FormatAttr 0x1f0ba00 <col:12> scanf 1 2 |-FunctionDecl 0x1f0ba50 prev 0x1f0b900 <col:1, col:55> scanf 'int (const char *restrict, ...)' extern | |-ParmVarDecl 0x1f0b880 <col:19, col:42> __format 'const char *restrict' |
-FormatAttr 0x1f0bb20 -FormatAttr 0x1f0be50 <col:12> scanf 2 3 |-FunctionDecl 0x1f0bea0 prev 0x1f0bce0 <col:1, line:434:72> sscanf 'int (const char *restrict, const char *restrict, ...)' extern | |-ParmVarDecl 0x1f0bb60 <line:433:20, col:43> __s 'const char *restrict' | |-ParmVarDecl 0x1f0bbd0 <line:434:6, col:29> __format 'const char *restrict' | |-NoThrowAttr 0x1f0bf50 <col:60> |
-FormatAttr 0x1f0bf90 -FormatAttr 0x1f0c990 <line:480:22, col:49> scanf 1 0 |-FunctionDecl 0x1f0cca0 <line:483:12> vsscanf 'int (const char *restrict, const char *restrict, __va_list_tag *)' extern | |-ParmVarDecl 0x1f0cd40 <<invalid sloc>> 'const char *restrict' | |-ParmVarDecl 0x1f0cda0 <<invalid sloc>> 'const char *restrict' | |-ParmVarDecl 0x1f0ce00 <<invalid sloc>> '__va_list_tag *' |
-FormatAttr 0x1f0ce70 -NoThrowAttr 0x1f0cfd0 <col:22> |-FunctionDecl 0x1f0d8d0 <line:531:1, col:33> fgetc 'int (FILE *)' extern |
-ParmVarDecl 0x1f0d850 <col:19, col:25> stream 'FILE '
|-FunctionDecl 0x1f0da10 <line:532:1, col:32> getc 'int (FILE )' extern
| `-ParmVarDecl 0x1f0d990 <col:18, col:24> stream 'FILE '
|-FunctionDecl 0x1f0db50 <line:538:1, col:25> getchar 'int (void)' extern
|-FunctionDecl 0x1f0dc80 <line:550:1, col:41> getc_unlocked 'int (FILE )' extern
| `-ParmVarDecl 0x1f0dc00 <col:27, col:33> -ParmVarDecl 0x1f0de70 <col:28, col:34> __stream 'FILE *' |-FunctionDecl 0x1f0e0f0 <line:573:1, col:42> fputc 'int (int, FILE *)' extern | |-ParmVarDecl 0x1f0dfb0 <col:19, col:23> __c 'int' |
-ParmVarDecl 0x1f0e020 <col:28, col:34> stream 'FILE '
|-FunctionDecl 0x1f0e2b0 <line:574:1, col:41> putc 'int (int, FILE )' extern
| |-ParmVarDecl 0x1f0e1b0 <col:18, col:22> c 'int'
| -ParmVarDecl 0x1f0e220 <col:27, col:33> __stream 'FILE *' |-FunctionDecl 0x1f0e430 <line:580:1, col:28> putchar 'int (int)' extern |
-ParmVarDecl 0x1f0e370 <col:21, col:25> c 'int'
|-FunctionDecl 0x1f0e5f0 <line:594:1, col:51> fputc_unlocked 'int (int, FILE )' extern
| |-ParmVarDecl 0x1f0e4f0 <col:28, col:32> c 'int'
| `-ParmVarDecl 0x1f0e560 <col:37, col:43> stream 'FILE '
|-FunctionDecl 0x1f0e860 <line:602:1, col:50> putc_unlocked 'int (int, FILE *)' extern
| |-ParmVarDecl 0x1f0e6b0 <col:27, col:31> c 'int'
| -ParmVarDecl 0x1f0e720 <col:36, col:42> __stream 'FILE *' |-FunctionDecl 0x1f0e9a0 <line:603:1, col:37> putchar_unlocked 'int (int)' extern |
-ParmVarDecl 0x1f0e920 <col:30, col:34> c 'int'
|-FunctionDecl 0x1f0eae0 <line:610:1, col:32> getw 'int (FILE *)' extern
| `-ParmVarDecl 0x1f0ea60 <col:18, col:24> stream 'FILE '
|-FunctionDecl 0x1f0eca0 <line:613:1, col:41> putw 'int (int, FILE )' extern
| |-ParmVarDecl 0x1f0eba0 <col:18, col:22> w 'int'
| `-ParmVarDecl 0x1f0ec10 <col:27, col:33> stream 'FILE '
|-FunctionDecl 0x1f0ef70 <line:622:1, col:77> fgets 'char (char restrict, int, FILE restrict)' extern
| |-ParmVarDecl 0x1f0ed60 <col:21, col:38> s 'char *restrict'
| |-ParmVarDecl 0x1f0edd0 <col:43, col:47> n 'int'
| -ParmVarDecl 0x1f0ee40 <col:52, col:69> __stream 'FILE *restrict' |-FunctionDecl 0x1f0f1b0 <line:649:1, line:650:34> fgets_unlocked 'char *(char *restrict, int, FILE *restrict)' extern | |-ParmVarDecl 0x1f0f040 <line:649:30, col:47> __s 'char *restrict' | |-ParmVarDecl 0x1f0f0b0 <col:52, col:56> __n 'int' |
-ParmVarDecl 0x1f0f120 <line:650:9, col:26> stream 'FILE *restrict'
|-FunctionDecl 0x1f0f510 <line:665:1, line:667:36> getdelim 'ssize_t (char *restrict, size_t restrict, int, FILE *restrict)' extern
| |-ParmVarDecl 0x1f0f280 <line:665:30, col:48> lineptr 'char restrict'
| |-ParmVarDecl 0x1f0f2f0 <line:666:11, col:30> __n 'size_t restrict'
| |-ParmVarDecl 0x1f0f360 <col:35, col:39> delimiter 'int'
| `-ParmVarDecl 0x1f0f3d0 <line:667:11, col:28> stream 'FILE restrict'
|-FunctionDecl 0x1f0f870 <line:668:1, line:670:34> getdelim '__ssize_t (char restrict, size_t restrict, int, FILE restrict)' extern
| |-ParmVarDecl 0x1f0f5f0 <line:668:28, col:46> lineptr 'char **restrict'
| |-ParmVarDecl 0x1f0f660 <line:669:9, col:28> n 'size_t restrict'
| |-ParmVarDecl 0x1f0f6d0 <col:33, col:37> delimiter 'int'
| `-ParmVarDecl 0x1f0f740 <line:670:9, col:26> stream 'FILE restrict'
|-FunctionDecl 0x1f0fb60 <line:678:1, line:680:33> getline 'ssize_t (char *restrict, size_t restrict, FILE *restrict)' extern
| |-ParmVarDecl 0x1f0f950 <line:678:27, col:45> lineptr 'char *restrict'
| |-ParmVarDecl 0x1f0f9c0 <line:679:8, col:27> __n 'size_t restrict'
| -ParmVarDecl 0x1f0fa30 <line:680:8, col:25> __stream 'FILE *restrict' |-FunctionDecl 0x1f0fdb0 <line:689:1, col:72> fputs 'int (const char *restrict, FILE *restrict)' extern | |-ParmVarDecl 0x1f0fc30 <col:19, col:42> __s 'const char *restrict' |
-ParmVarDecl 0x1f0fca0 <col:47, col:64> stream 'FILE restrict'
|-FunctionDecl 0x1f0fef0 <line:695:1, col:33> puts 'int (const char )' extern
| `-ParmVarDecl 0x1f0fe70 <col:18, col:30> s 'const char '
|-FunctionDecl 0x1f100b0 <line:702:1, col:43> ungetc 'int (int, FILE )' extern
| |-ParmVarDecl 0x1f0ffb0 <col:20, col:24> c 'int'
| `-ParmVarDecl 0x1f10020 <col:29, col:35> stream 'FILE '
|-FunctionDecl 0x1f10400 <line:709:1, line:710:45> fread 'size_t (void restrict, size_t, size_t, FILE restrict)' extern
| |-ParmVarDecl 0x1f10170 <line:709:22, col:39> __ptr 'void restrict'
| |-ParmVarDecl 0x1f101e0 <col:46, col:53> size 'size_t':'unsigned long'
| |-ParmVarDecl 0x1f10250 <line:710:8, col:15> __n 'size_t':'unsigned long'
| `-ParmVarDecl 0x1f102c0 <col:20, col:37> stream 'FILE restrict'
|-FunctionDecl 0x1f10790 <line:715:1, line:716:41> fwrite 'size_t (const void restrict, size_t, size_t, FILE restrict)' extern
| |-ParmVarDecl 0x1f10500 <line:715:23, col:46> __ptr 'const void restrict'
| |-ParmVarDecl 0x1f10570 <col:53, col:60> size 'size_t':'unsigned long'
| |-ParmVarDecl 0x1f105e0 <line:716:9, col:16> __n 'size_t':'unsigned long'
| `-ParmVarDecl 0x1f10650 <col:21, col:38> s 'FILE restrict'
|-FunctionDecl 0x1f10980 <line:726:1, line:727:32> fputs_unlocked 'int (const char restrict, FILE restrict)' extern
| |-ParmVarDecl 0x1f10880 <line:726:28, col:51> __s 'const char restrict'
| -ParmVarDecl 0x1f108f0 <line:727:7, col:24> __stream 'FILE *restrict' |-FunctionDecl 0x1f10c30 <line:737:1, line:738:47> fread_unlocked 'size_t (void *restrict, size_t, size_t, FILE *restrict)' extern | |-ParmVarDecl 0x1f10a40 <line:737:31, col:48> __ptr 'void *restrict' | |-ParmVarDecl 0x1f10ab0 <col:55, col:62> __size 'size_t':'unsigned long' | |-ParmVarDecl 0x1f10b20 <line:738:10, col:17> __n 'size_t':'unsigned long' |
-ParmVarDecl 0x1f10b90 <col:22, col:39> stream 'FILE restrict'
|-FunctionDecl 0x1f10ef0 <line:739:1, line:740:48> fwrite_unlocked 'size_t (const void restrict, size_t, size_t, FILE *restrict)' extern
| |-ParmVarDecl 0x1f10d00 <line:739:32, col:55> ptr 'const void restrict'
| |-ParmVarDecl 0x1f10d70 <col:62, col:69> size 'size_t':'unsigned long'
| |-ParmVarDecl 0x1f10de0 <line:740:11, col:18> __n 'size_t':'unsigned long'
| `-ParmVarDecl 0x1f10e50 <col:23, col:40> stream 'FILE restrict'
|-FunctionDecl 0x1f111d0 <line:749:1, col:63> fseek 'int (FILE , long, int)' extern
| |-ParmVarDecl 0x1f10fc0 <col:19, col:25> __stream 'FILE '
| |-ParmVarDecl 0x1f11030 <col:35, col:44> off 'long'
| `-ParmVarDecl 0x1f110a0 <col:51, col:55> whence 'int'
|-FunctionDecl 0x1f113a0 <line:754:1, col:38> ftell 'long (FILE )' extern
| `-ParmVarDecl 0x1f112a0 <col:24, col:30> __stream 'FILE '
|-FunctionDecl 0x1f114e0 <line:759:1, col:35> rewind 'void (FILE )' extern
| `-ParmVarDecl 0x1f11460 <col:21, col:27> __stream 'FILE '
|-FunctionDecl 0x1f11760 <line:773:1, col:63> fseeko 'int (FILE , __off_t, int)' extern
| |-ParmVarDecl 0x1f115a0 <col:20, col:26> __stream 'FILE '
| |-ParmVarDecl 0x1f11610 <col:36, col:44> off 'off_t':'long'
| -ParmVarDecl 0x1f11680 <col:51, col:55> __whence 'int' |-FunctionDecl 0x1f11950 <line:778:1, col:38> ftello '__off_t (FILE *)' extern |
-ParmVarDecl 0x1f11890 <col:24, col:30> stream 'FILE '
|-FunctionDecl 0x1f11c10 <line:798:1, col:72> fgetpos 'int (FILE restrict, fpos_t restrict)' extern
| |-ParmVarDecl 0x1f11a10 <col:21, col:38> __stream 'FILE restrict'
| -ParmVarDecl 0x1f11b00 <col:48, col:67> __pos 'fpos_t *restrict' |-FunctionDecl 0x1f11eb0 <line:803:1, col:56> fsetpos 'int (FILE *, const fpos_t *)' extern | |-ParmVarDecl 0x1f11cd0 <col:21, col:27> __stream 'FILE *' |
-ParmVarDecl 0x1f11da0 <col:37, col:51> __pos 'const fpos_t '
|-FunctionDecl 0x1f12130 <line:818:1, col:67> fseeko64 'int (FILE , off64_t, int)' extern
| |-ParmVarDecl 0x1f11f70 <col:22, col:28> stream 'FILE *'
| |-ParmVarDecl 0x1f11fe0 <col:38, col:48> off 'off64_t':'long'
| -ParmVarDecl 0x1f12050 <col:55, col:59> __whence 'int' |-FunctionDecl 0x1f122c0 <line:819:1, col:42> ftello64 '__off64_t (FILE *)' extern |
-ParmVarDecl 0x1f12200 <col:28, col:34> stream 'FILE '
|-FunctionDecl 0x1f12580 <line:820:1, col:76> fgetpos64 'int (FILE restrict, fpos64_t restrict)' extern
| |-ParmVarDecl 0x1f12380 <col:23, col:40> __stream 'FILE restrict'
| -ParmVarDecl 0x1f12470 <col:50, col:71> __pos 'fpos64_t *restrict' |-FunctionDecl 0x1f138b0 <line:821:1, col:60> fsetpos64 'int (FILE *, const fpos64_t *)' extern | |-ParmVarDecl 0x1f12640 <col:23, col:29> __stream 'FILE *' |
-ParmVarDecl 0x1f12710 <col:39, col:55> pos 'const fpos64_t '
|-FunctionDecl 0x1f139f0 <line:826:1, col:67> clearerr 'void (FILE )' extern
| |-ParmVarDecl 0x1f13970 <col:23, col:29> stream 'FILE '
| `-NoThrowAttr 0x1f13aa0 -NoThrowAttr 0x1f17c90 <col:58>
-FunctionDecl 0x1f17cf0 </home/go/src/github.com/Konstantin8105/c4go/examples/prime.c:3:1, line:26:1> main 'int ()'
-CompoundStmt 0x1f18b08 <line:4:1, line:26:1> |-DeclStmt 0x1f17e80 <line:5:5, col:13> | |-VarDecl 0x1f17da0 <col:5, col:9> n 'int' |
-VarDecl 0x1f17e10 <col:5, col:12> c 'int'
|-CallExpr 0x1f17f70 <line:7:5, col:30> 'int'
| |-ImplicitCastExpr 0x1f17f58 -ImplicitCastExpr 0x1f17fa0 <col:12> 'char *' <ArrayToPointerDecay> |
-StringLiteral 0x1f17ef8 -DeclRefExpr 0x1f17fd0 <col:5> 'int (const char *restrict, ...)' Function 0x1f0ba50 'scanf' 'int (const char *restrict, ...)' | |-ImplicitCastExpr 0x1f18140 <col:11> 'const char *' <BitCast> | |
-ImplicitCastExpr 0x1f18128 -StringLiteral 0x1f18038 <col:11> 'char [3]' lvalue "%d" |
-UnaryOperator 0x1f18090 <col:17, col:18> 'int -DeclRefExpr 0x1f18068 <col:18> 'int' lvalue Var 0x1f17da0 'n' 'int' |-CallExpr 0x1f18238 <line:10:5, col:36> 'int' | |-ImplicitCastExpr 0x1f18220 <col:5> 'int (*)(const char *, ...)' <FunctionToPointerDecay> | |
-DeclRefExpr 0x1f18158 -StringLiteral 0x1f181b8 <col:12> 'char [19]' lvalue "The number is: %d\n" |
-ImplicitCastExpr 0x1f182a0 -DeclRefExpr 0x1f181f8 <col:35> 'int' lvalue Var 0x1f17da0 'n' 'int' |-IfStmt 0x1f18a98 <line:13:5, line:24:5> | |-<<<NULL>>> | |-BinaryOperator 0x1f18318 <line:13:9, col:14> 'int' '==' | | |-ImplicitCastExpr 0x1f18300 <col:9> 'int' <LValueToRValue> | | |
-DeclRefExpr 0x1f182b8 -IntegerLiteral 0x1f182e0 <col:14> 'int' 2 | |-CallExpr 0x1f183f8 <line:14:9, col:33> 'int' | | |-ImplicitCastExpr 0x1f183e0 <col:9> 'int (*)(const char *, ...)' <FunctionToPointerDecay> | | |
-DeclRefExpr 0x1f18340 -ImplicitCastExpr 0x1f18440 <col:16> 'const char *' <BitCast> | |
-ImplicitCastExpr 0x1f18428 -StringLiteral 0x1f183a8 <col:16> 'char [15]' lvalue "Prime number.\n" |
-CompoundStmt 0x1f18a70 <line:15:10, line:24:5>
| |-ForStmt 0x1f18750 <line:16:9, line:19:9>
| | |-BinaryOperator 0x1f184a0 <line:16:14, col:18> 'int' '='
| | | |-DeclRefExpr 0x1f18458 -IntegerLiteral 0x1f18480 <col:18> 'int' 2 | | |-<<<NULL>>> | | |-BinaryOperator 0x1f18590 <col:21, col:30> 'int' '<=' | | | |-ImplicitCastExpr 0x1f18578 <col:21> 'int' <LValueToRValue> | | | |
-DeclRefExpr 0x1f184c8 -BinaryOperator 0x1f18550 <col:26, col:30> 'int' '-' | | | |-ImplicitCastExpr 0x1f18538 <col:26> 'int' <LValueToRValue> | | | |
-DeclRefExpr 0x1f184f0 -IntegerLiteral 0x1f18518 <col:30> 'int' 1 | | |-UnaryOperator 0x1f185e0 <col:33, col:34> 'int' postfix '++' | | |
-DeclRefExpr 0x1f185b8 -CompoundStmt 0x1f18730 <col:38, line:19:9> | |
-IfStmt 0x1f18700 <line:17:13, line:18:17>
| | |-<<-DeclRefExpr 0x1f18600 <col:17> 'int' lvalue Var 0x1f17da0 'n' 'int' | | | |
-ImplicitCastExpr 0x1f18668 -DeclRefExpr 0x1f18628 <col:21> 'int' lvalue Var 0x1f17e10 'c' 'int' | | |
-IntegerLiteral 0x1f186a8 -<<<NULL>>> |
-IfStmt 0x1f18a40 <line:20:9, line:23:37>
| |-<<-DeclRefExpr 0x1f18790 <col:13> 'int' lvalue Var 0x1f17e10 'c' 'int' | |
-ImplicitCastExpr 0x1f187f8 -ImplicitCastExpr 0x1f18938 <col:20> 'char *' <ArrayToPointerDecay> | |
-StringLiteral 0x1f18898 -CallExpr 0x1f189e0 <line:23:13, col:37> 'int' | |-ImplicitCastExpr 0x1f189c8 <col:13> 'int (*)(const char *, ...)' <FunctionToPointerDecay> | |
-DeclRefExpr 0x1f18968 -ImplicitCastExpr 0x1f18a28 <col:20> 'const char *' <BitCast> |
-ImplicitCastExpr 0x1f18a10 -StringLiteral 0x1f18990 <col:20> 'char [15]' lvalue "Prime number.\n"
-ReturnStmt 0x1f18ae8 <line:25:5, col:12>
`-IntegerLiteral 0x1f18ac8
Dear @69567272 ,
In my point of view you have to update clang
, because that version of clang create a strange NULL
node.
May be I will fix that later.
OK. Thank you for you help me, Thanks!
Dear @69567272 , Please try again. Please clarify - is it still important for you?
Dear @Konstantin8105 These days are busy, go to the Foxcnn factory every day, Today, the source code installed Clang. package: Cfe-3.5.0.src.tar.xz Compiler-rt-3.5.0.src.tar.xz Llv3-3.5.0.src.tar.xz After upgrading to 3.5.0 (yum is not up to 3.5.0), it's convert OK.
Is it important to me? I am also a programmer. I found the problem and then gave the question back to the author. This is a habit.
Suggestion: Explain the clang version, which is more convenient for everyone to use. This tool is very good and can help more programmers to complete the C code conversion GO code. Thank you so much.
Version 3.4.* will still fail. But it doesn't matter, it's good to convert with the new version.
Thank you for clarification. Good luck.
OS:linux CentOS 7 64 bit It's conversion fail ,why?
Error: [root@localhost examples]# c4go transpile prime.c panic: interface conversion: interface is nil, not ast.Node goroutine 1 [running]: main.generateGoCode(0x0, 0xc420084080, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6b422b, ...) /home/go/src/github.com/Konstantin8105/c4go/main.go:470 +0x61d main.Start(0x0, 0xc420084080, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6b422b, ...) /home/go/src/github.com/Konstantin8105/c4go/main.go:337 +0x282 main.runCommand(0x0) /home/go/src/github.com/Konstantin8105/c4go/main.go:639 +0x904 main.main() /home/go/src/github.com/Konstantin8105/c4go/main.go:510 +0x22