Skip to content

Commit

Permalink
Merge pull request #9 from ITcarrot/PullRequest
Browse files Browse the repository at this point in the history
修复task3无法在gcc13环境下通过编译的问题,修复task3、task4无法在手动编译安装clang-14的环境下通过编译的问题,修正IRBuilder在代码块间切换的方法
  • Loading branch information
ITcarrot authored Jun 23, 2024
2 parents b1ad287 + 8391992 commit 396d737
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion task/3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
file(GLOB _src *.cpp *.hpp *.c *.h)
add_executable(task3 ${_src})

target_include_directories(task3 SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS})
target_include_directories(task3 PRIVATE ${LLVM_INCLUDE_DIRS})

target_link_libraries(task3 ${LLVM_LIBS})
4 changes: 2 additions & 2 deletions task/3/EmitIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ EmitIR::operator()(ReturnStmt* obj)
mCurIrb->CreateRet(retVal);

auto exitBb = llvm::BasicBlock::Create(mCtx, "return_exit", mCurFunc);
mCurIrb = std::make_unique<llvm::IRBuilder<>>(exitBb);
mCurIrb->SetInsertPoint(exitBb);
}

//==============================================================================
Expand Down Expand Up @@ -152,7 +152,7 @@ EmitIR::operator()(FunctionDecl* obj)
if (obj->body == nullptr)
return;
auto entryBb = llvm::BasicBlock::Create(mCtx, "entry", func);
mCurIrb = std::make_unique<llvm::IRBuilder<>>(entryBb);
mCurIrb->SetInsertPoint(entryBb);
auto& entryIrb = *mCurIrb;

// TODO: 添加对函数参数的处理
Expand Down
1 change: 1 addition & 0 deletions task/3/asg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Obj.hpp"
#include <string>
#include <cstdint>

namespace asg {

Expand Down
2 changes: 1 addition & 1 deletion task/4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ file(GLOB _src *.cpp *.hpp *.c *.h)
add_executable(task4 ${_src})

target_include_directories(task4 PRIVATE . ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(task4 SYSTEM PRIVATE ${LLVM_INCLUDE_DIRS})
target_include_directories(task4 PRIVATE ${LLVM_INCLUDE_DIRS})

target_link_libraries(task4 ${LLVM_LIBS})

0 comments on commit 396d737

Please sign in to comment.