Commit 78e208f5 authored by 李晓奇's avatar 李晓奇

Merge branch 'master' of 202.38.79.174:compiler_staff/2022fall-compiler_cminus

parents 5b1dfa22 49c4e204
This diff is collapsed.
......@@ -134,6 +134,12 @@ PB20111654 李晓奇
问题出在:我为if_else语句设置了三个测试块,分别负责if,else,和跳出。但是有一处的块是空的,就会导致生成默认返回。
后来发这里其实并没有问题,如果有返回值,在if或者else内部就返回了,并不会跳出去被默认返回扰乱。
- 最后一个测试文件能够正常执行,但是输出有错,
发现一个好的debug方法:
利用裁剪定位问题,即注释掉一部分,分别利用clang、cminusfc生成可执行文件,查看输出是否一致。
## 实验设计
......
......@@ -104,17 +104,18 @@ int main(int argc, char **argv) {
output_stream.close();
if (!emit) {
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());
auto idx = lib_path.rfind('/');
if (idx != std::string::npos)
lib_path.erase(lib_path.rfind('/'));
auto cmd_str = "clang -O0 -w "s + target_path + ".ll -o " + target_path + " -L" + lib_path + " -lcminus_io";
std::cout << cmd_str << std::endl;
int re_code0 = std::system(cmd_str.c_str());
cmd_str = "rm "s + target_path + ".ll";
int re_code1 = std::system(cmd_str.c_str());
if (re_code0 == 0 && re_code1 == 0)
return 0;
else
return 1;
}
return 0;
}
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