Commit 54c6f80f authored by 李晓奇's avatar 李晓奇

push to repository

parent 06dd9b3d
......@@ -128,6 +128,12 @@ PB20111654 李晓奇
- 知道了为什么clang生成的中间代码,会把实参声明一遍再拷贝了。
在我看来方便编译器代码的生成,因为重新声明,push给scope的值是指针类型而不是纯值,这在后边访问Var中有用。
- 发现ret会有乱跳转的问题,这个在最后一个测试的abs中发现。
问题出在:我为if_else语句设置了三个测试块,分别负责if,else,和跳出。但是有一处的块是空的,就会导致生成默认返回。
后来发这里其实并没有问题,如果有返回值,在if或者else内部就返回了,并不会跳出去被默认返回扰乱。
## 实验设计
......
......@@ -400,6 +400,7 @@ void CminusfBuilder::visit(ASTReturnStmt &node) {
}
builder->create_ret(cur_value);
LOG_DEBUG << "create ret:\n" << builder->get_module()->print();
}
}
......
......@@ -67,7 +67,8 @@ int main(int argc, char **argv) {
std::cerr << argv[0] << ": input file " << input_path << " has unknown filetype!" << std::endl;
return -1;
} else {
if (input_path.substr(pos) != ".cminus") {
// if (input_path.substr(pos) != ".cminus") {
if (input_path.substr(pos).substr(0, 2) != ".c") {
std::cerr << argv[0] << ": input file " << input_path << " has unknown filetype!" << std::endl;
return -1;
}
......@@ -105,6 +106,7 @@ int main(int argc, char **argv) {
std::string lib_path = argv[0];
lib_path.erase(lib_path.rfind('/')) += "/libcminus_io.a";
auto command_string = "clang -O0 -w "s + target_path + ".ll -o " + target_path + " " + lib_path;
std::cout << command_string << std::endl;
int re_code0 = std::system(command_string.c_str());
command_string = "rm "s + target_path + ".ll";
int re_code1 = std::system(command_string.c_str());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment