|
20 | 20 |
|
21 | 21 | namespace psr {
|
22 | 22 |
|
| 23 | +static void setOpaquePointersForCtx(llvm::LLVMContext &Ctx, bool Enable) { |
| 24 | +#if LLVM_VERSION_MAJOR >= 15 && LLVM_VERSION_MAJOR < 17 |
| 25 | + if (!Enable) { |
| 26 | + Ctx.setOpaquePointers(false); |
| 27 | + } |
| 28 | +#elif LLVM_VERSION_MAJOR < 15 |
| 29 | + if (Enable) { |
| 30 | + Ctx.enableOpaquePointers(); |
| 31 | + } |
| 32 | +#else // LLVM_VERSION_MAJOR >= 17 |
| 33 | +#error \ |
| 34 | + "Non-opaque pointers are not supported anymore. Refactor PhASAR to remove typed pointer support." |
| 35 | +#endif |
| 36 | +} |
| 37 | + |
23 | 38 | std::unique_ptr<llvm::Module>
|
24 | 39 | LLVMProjectIRDB::getParsedIRModuleOrNull(llvm::MemoryBufferRef IRFileContent,
|
25 | 40 | llvm::LLVMContext &Ctx) noexcept {
|
@@ -63,9 +78,7 @@ LLVMProjectIRDB::getParsedIRModuleOrNull(const llvm::Twine &IRFileName,
|
63 | 78 |
|
64 | 79 | LLVMProjectIRDB::LLVMProjectIRDB(const llvm::Twine &IRFileName,
|
65 | 80 | bool EnableOpaquePointers) {
|
66 |
| - if (EnableOpaquePointers) { |
67 |
| - Ctx.enableOpaquePointers(); |
68 |
| - } |
| 81 | + setOpaquePointersForCtx(Ctx, EnableOpaquePointers); |
69 | 82 | auto M = getParsedIRModuleOrNull(IRFileName, Ctx);
|
70 | 83 |
|
71 | 84 | if (!M) {
|
@@ -160,9 +173,7 @@ LLVMProjectIRDB::LLVMProjectIRDB(std::unique_ptr<llvm::Module> Mod,
|
160 | 173 |
|
161 | 174 | LLVMProjectIRDB::LLVMProjectIRDB(llvm::MemoryBufferRef Buf,
|
162 | 175 | bool EnableOpaquePointers) {
|
163 |
| - if (EnableOpaquePointers) { |
164 |
| - Ctx.enableOpaquePointers(); |
165 |
| - } |
| 176 | + setOpaquePointersForCtx(Ctx, EnableOpaquePointers); |
166 | 177 | auto M = getParsedIRModuleOrNull(Buf, Ctx);
|
167 | 178 | if (!M) {
|
168 | 179 | return;
|
|
0 commit comments