gcc源代码分析,grokdeclarator()函数分析
来源:互联网 发布:网络销售产品 编辑:程序博客网 时间:2024/06/06 23:58
grokdeclarator ()函数有2次被调用的情况。
第一种情况在函数push_parm_decl ()函数中。
/* Given a parsed parameter declaration,
decode it into a PARM_DECL and push that on the current binding level. */
void
push_parm_decl (parm)
tree parm;
{
register tree decl = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm),
PARM, 0);
/* Add this decl to the current binding level. */
finish_decl (pushdecl (decl), NULL_TREE, NULL_TREE);
}
grokdeclarator ()函数中的部分代码:
if (initialized)
error ("parameter `%s' is initialized", name);
decl = build_decl (PARM_DECL, declarator, type);
调试结果:
<pointer_type 9117c
type <integer_type 91130 char readonly permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 9117c>
permanent unsigned SI
size <integer_cst 8254c type <integer_type 82848* unsigned int> literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
chain <function_type 912c0>
<parm_decl 941c0
type <pointer_type 9117c
type <integer_type 91130 char readonly permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 9117c>
permanent unsigned SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
chain <function_type 912c0>
unsigned SI file /usr/include/stdio.h line 214 size <integer_cst 8254c 4>
align 32 size_unit 8 offset 0
<parm_decl 941c0
type <pointer_type 9117c
type <integer_type 91130 char readonly permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 9117c>
permanent unsigned SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
chain <function_type 912c0>
unsigned SI file /usr/include/stdio.h line 214 size <integer_cst 8254c 4>
align 32 size_unit 8 offset 0 arguments <pointer_type 9117c>
第二种情况在函数start_decl ()函数中。
tree
start_decl (declarator, declspecs, initialized)
tree declspecs, declarator;
int initialized;
{
register tree decl = grokdeclarator (declarator, declspecs,
NORMAL, initialized);
参数调试结果:
arg 0 <identifier_node 95540 printf permanent
arg 1 <tree_list 956b0 permanent
purpose <parm_decl 941c0 type <pointer_type 9117c>
unsigned SI file /usr/include/stdio.h line 214
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 offset 0 arguments <pointer_type 9117c>
chain <tree_list 95698 permanent value <pointer_type 9117c> chain <tree_list 95698>(nil)
<tree_list 95608 permanent
value <identifier_node 82008 int permanent
global <type_decl 82564 int type <integer_type 824d0* int>
permanent VOID file (null) line 0
align 1 size_unit 1 offset 0
grokdeclarator ()函数返回结果:
<function_decl 95740 printf
type <function_type 956e8
type <integer_type 824d0 int permanent SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
max <integer_cst 82534 literal permanent 2147483647
pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
permanent EP
size <integer_cst 82dd8 literal permanent 8
align 32 size_unit 8 sep_unit 0 symtab 0
arg-types <tree_list 95698 permanent value <pointer_type 9117c>
external public permanent QI file /usr/include/stdio.h line 214
align 1 size_unit 1 offset 0
...
arg_types = grokparms (TREE_OPERAND (declarator, 1),
funcdef_flag
/* Say it's a definition
only for the CALL_EXPR
closest to the identifier. */
&& TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE);
#if 0 /* This seems to be false. We turn off temporary allocation
above in this function if -traditional.
And this code caused inconsistent results with prototypes:
callers would ignore them, and pass arguments wrong. */
/* Omit the arg types if -traditional, since the arg types
and the list links might not be permanent. */
type = build_function_type (type, flag_traditional ? 0 : arg_types);
#endif
type = build_function_type (type, arg_types);
declarator = TREE_OPERAND (declarator, 0);
arg_types = grokparms (之后为
<tree_list 95698 permanent
value <pointer_type 9117c
type <integer_type 91130 char readonly permanent QI
size <integer_cst 82638 literal permanent 1
align 8 size_unit 8 sep_unit 8 symtab 0
sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
max <integer_cst 82620 literal permanent 127
pointer_to_this <pointer_type 9117c>
permanent unsigned SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
chain <function_type 912c0>
type = build_function_type ( 之前type为:
<integer_type 824d0 int permanent SI
size <integer_cst 8254c type <integer_type 82848* unsigned int> literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 8251c type <integer_type 824d0* int> literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
max <integer_cst 82534 type <integer_type 824d0* int> literal permanent 2147483647
pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
type = build_function_type ( 之后type为:
<function_type 956e8
type <integer_type 824d0 int permanent SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
max <integer_cst 82534 literal permanent 2147483647
pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
permanent EP
size <integer_cst 82dd8 type <integer_type 82848* unsigned int> literal permanent 8
align 32 size_unit 8 sep_unit 0 symtab 0
arg-types <tree_list 95698 permanent
value <pointer_type 9117c type <integer_type 91130* char>
permanent unsigned SI size <integer_cst 8254c 4>
align 32 size_unit 8 sep_unit 32 symtab 0
chain <function_type 912c0>
这次调用build_decl ()函数。
else if (TREE_CODE (type) == FUNCTION_TYPE)
{
...
调用build_decl函数之前 declarator为
<identifier_node 95540 printf permanent
调用build_decl函数之前type 为
<function_type 956e8
type <integer_type 824d0 int permanent SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
max <integer_cst 82534 literal permanent 2147483647
pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
permanent EP
size <integer_cst 82dd8 type <integer_type 82848* unsigned int> literal permanent 8
align 32 size_unit 8 sep_unit 0 symtab 0
arg-types <tree_list 95698 permanent
value <pointer_type 9117c type <integer_type 91130* char>
permanent unsigned SI size <integer_cst 8254c 4>
align 32 size_unit 8 sep_unit 32 symtab 0
chain <function_type 912c0>
decl = build_decl (FUNCTION_DECL, declarator, type);
调用build_decl函数之后
<function_decl 95740 printf
type <function_type 956e8
type <integer_type 824d0 int permanent SI
size <integer_cst 8254c literal permanent 4
align 32 size_unit 8 sep_unit 32 symtab 0
sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
max <integer_cst 82534 literal permanent 2147483647
pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
permanent EP
size <integer_cst 82dd8 literal permanent 8
align 32 size_unit 8 sep_unit 0 symtab 0
arg-types <tree_list 95698 permanent value <pointer_type 9117c>
permanent QI file /usr/include/stdio.h line 214
align 1 size_unit 1 offset 0
- gcc源代码分析,grokdeclarator()函数分析
- gcc源代码分析,grokdeclarator()函数分析 ,第二部分
- gcc源代码分析 gen_rtx()函数
- gcc源代码分析emit_call_insn()函数
- GCC源代码分析,recog_memoized()函数
- gcc源代码分析,output_asm_insn()函数
- gcc源代码分析,expand_expr_stmt()函数
- gcc源代码分析,rtx_alloc函数分析
- gcc源代码分析,build_string ()函数分析
- gcc源代码分析,build_function_call ()函数分析
- gcc源代码分析,build_pointer_type ()函数分析
- gcc源代码分析,actualparameterlist ()函数分析
- gcc源代码分析,default_conversion ()函数分析
- gcc源代码分析,get_parm_info ()函数分析
- gcc源代码分析,grokparms ()函数分析
- gcc源代码分析之gen_call_value()函数
- gcc源代码分析,debug_rtx()函数,利器啊
- gcc源代码分析,debug_tree()函数的利用
- hdu 2159 FATE
- JNI中数据类型及签名类型
- 使用multi curl进行http并发访问
- maven org.apache.commons.commons-convert
- 2015-01-15 好东西,记录一下吧
- gcc源代码分析,grokdeclarator()函数分析
- Leetcode_114_Flatten Binary Tree to Linked List
- page-taglib标签结合SSH框架进行java分页
- 龙贝格积分-matlab通用程序
- hdu 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活
- can't link with a main executable file for architecture armv7错误解决办法
- repmat
- 四阶龙格-库塔法求解常微分方程的初值问题-matlab通用程序
- IllegalStateException: Can not perform this action after onSaveInstanceState