Skip to content

Commit

Permalink
Add #if checks for LLVM12-specific fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jcd1230 committed Jul 11, 2021
1 parent 4407fed commit 9be141b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
17 changes: 16 additions & 1 deletion src/tcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ extern "C" {

#if LLVM_VERSION < 50
#include "llvm/ExecutionEngine/MCJIT.h"
#else
#if LLVM_VERSION < 120
#include "llvm/ExecutionEngine/OrcMCJITReplacement.h"
#endif
#endif

#include "llvm/Support/Atomic.h"
Expand Down Expand Up @@ -387,6 +391,9 @@ static void InitializeJIT(TerraCompilationUnit *CU) {
.setMCJITMemoryManager(make_unique<TerraSectionMemoryManager>(CU))
#else
.setMCJITMemoryManager(std::make_unique<TerraSectionMemoryManager>(CU))
#endif
#if LLVM_VERSION < 120
.setOrcMCJITReplacement(true)
#endif
;
#endif
Expand Down Expand Up @@ -2486,7 +2493,15 @@ struct FunctionEmitter {
DEBUG_ONLY(T) {
MDNode *scope = debugScopeForFile(customfilename ? customfilename
: obj->string("filename"));
B->SetCurrentDebugLocation(DILocation::get(scope->getContext(), customfilename ? customlinenumber : obj->number("linenumber"), 0, scope));
#if LLVM_VERSION < 120
B->SetCurrentDebugLocation(DebugLoc::get(
customfilename ? customlinenumber : obj->number("linenumber"), 0,
scope));
#else
B->SetCurrentDebugLocation(DILocation::get(scope->getContext(),
customfilename ? customlinenumber : obj->number("linenumber"), 0,
scope));
#endif
}
}

Expand Down
16 changes: 7 additions & 9 deletions src/tcwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,14 @@ class IncludeCVisitor : public RecursiveASTVisitor<IncludeCVisitor> {
}
CStyleCastExpr *CreateCast(QualType Ty, CastKind Kind, Expr *E) {
TypeSourceInfo *TInfo = Context->getTrivialTypeSourceInfo(Ty, SourceLocation());
return CStyleCastExpr::Create(*Context,
Ty,
VK_RValue,
Kind,
E,
0, // CXXCastPath BasePath (?)
#if LLVM_VERSION < 120
return CStyleCastExpr::Create(*Context, Ty, VK_RValue, Kind, E, 0, TInfo,
SourceLocation(), SourceLocation());
#else
return CStyleCastExpr::Create(*Context, Ty, VK_RValue, Kind, E, 0,
FPOptionsOverride::getFromOpaqueInt(0),
TInfo,
SourceLocation(),
SourceLocation());
TInfo, SourceLocation(), SourceLocation());
#endif
}
IntegerLiteral *LiteralZero() {
unsigned IntSize = static_cast<unsigned>(Context->getTypeSize(Context->IntTy));
Expand Down

0 comments on commit 9be141b

Please sign in to comment.