This repository has been archived by the owner on Dec 11, 2024. It is now read-only.
函数参数的处理 #42
Answered
by
Yorkking
paprika0741
asked this question in
Q&A
函数参数的处理
#42
-
请问对于一个函数的参数列表,除了在llvm::Function::Create的时候将参数类型传入以及设置参数名,还需要做什么处理吗?需要加入BB的符号表中吗?函数主体如何获得参数呢? |
Beta Was this translation helpful? Give feedback.
Answered by
Yorkking
May 17, 2022
Replies: 3 comments 5 replies
-
需要加入到符号表,和局部变量类似。函数主体可以调用 (Function*) F->Args() 获得。比如: for(auto& arg: F->Args()){
} |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
paprika0741
-
最终找到是我创建ArrayRef<Type*> params 作为CreateFunc的参数时,实际上params只被分配了空间,但并没有把值传进去,请问ArrayRef怎么用呢,我有一个函数,其返回值为ArrayRef<Type*>类型。而这个函数内部,无论是
ArrayRef<Type*> arr; arr.vec().push_back(xxx)
还是vector<string> vec; vec.push_back(xxx); ArrayRef<Type*> arr(vec);
这两种赋值方式都不能把值“真正”传给ArrayRef<Type*>类型的变量
…------------------ 原始邮件 ------------------
发件人: "arcsysu/SYsU-lang" ***@***.***>;
发送时间: 2022年5月19日(星期四) 晚上8:29
***@***.***>;
***@***.******@***.***>;
主题: Re: [arcsysu/SYsU-lang] 函数参数的处理 (Discussion #42)
不带参数的函数没问题了,带参数的函数用for(auto &arg: TheFunction->args())仍然段错误怎么办orz
最好贴一下相关的代码看看?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
明白了,vector可以自动转换为ArrayRef类型,不应该返回ArrayRef,不然引用会丢失
…------------------ 原始邮件 ------------------
发件人: "arcsysu/SYsU-lang" ***@***.***>;
发送时间: 2022年5月19日(星期四) 晚上8:29
***@***.***>;
***@***.******@***.***>;
主题: Re: [arcsysu/SYsU-lang] 函数参数的处理 (Discussion #42)
不带参数的函数没问题了,带参数的函数用for(auto &arg: TheFunction->args())仍然段错误怎么办orz
最好贴一下相关的代码看看?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
需要加入到符号表,和局部变量类似。函数主体可以调用 (Function*) F->Args() 获得。比如: