Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
2
2022fall-Compiler_CMinus
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李晓奇
2022fall-Compiler_CMinus
Commits
78e208f5
Commit
78e208f5
authored
Oct 28, 2022
by
李晓奇
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of 202.38.79.174:compiler_staff/2022fall-compiler_cminus
parents
5b1dfa22
49c4e204
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
85 deletions
+109
-85
Documentations/common/cminusf.md
Documentations/common/cminusf.md
+95
-78
Reports/3-ir-gen/report.md
Reports/3-ir-gen/report.md
+6
-0
src/cminusfc/cminusfc.cpp
src/cminusfc/cminusfc.cpp
+8
-7
No files found.
Documentations/common/cminusf.md
View file @
78e208f5
This diff is collapsed.
Click to expand it.
Reports/3-ir-gen/report.md
View file @
78e208f5
...
...
@@ -134,6 +134,12 @@ PB20111654 李晓奇
问题出在:我为if_else语句设置了三个测试块,分别负责if,else,和跳出。但是有一处的块是空的,就会导致生成默认返回。
后来发这里其实并没有问题,如果有返回值,在if或者else内部就返回了,并不会跳出去被默认返回扰乱。
-
最后一个测试文件能够正常执行,但是输出有错,
发现一个好的debug方法:
利用裁剪定位问题,即注释掉一部分,分别利用clang、cminusfc生成可执行文件,查看输出是否一致。
## 实验设计
...
...
src/cminusfc/cminusfc.cpp
View file @
78e208f5
...
...
@@ -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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment