This class wraps an 'llvm::BasicBlock*' and provides a const interface to it extended with the possibility of branching to it (either conditionally or not) and creating blocks before it. This is useful for example for the entry blocks of 'CodegenAnyValReadWriteInfo' objects as we do not want these blocks to be writable but we want to be able to branch to them. We cannot use a simple const pointer
| 49 | /// 'LlvmBuilder::Create[Cond]Br()' and 'llvm::BasicBlock::Create()' take a non-const |
| 50 | /// pointer. |
| 51 | class NonWritableBasicBlock { |
| 52 | public: |
| 53 | explicit NonWritableBasicBlock(llvm::BasicBlock* basic_block) |
| 54 | : basic_block_(basic_block) |
| 55 | {} |
| 56 | |
| 57 | const llvm::BasicBlock* get() { return basic_block_; } |
| 58 | |
| 59 | void BranchTo(LlvmBuilder* builder) const; |
| 60 | |
| 61 | /// Branch to this basic block if 'condition' is true, otherwise branch to 'else_block'. |
| 62 | void BranchToIf(LlvmBuilder* builder, llvm::Value* condition, |
| 63 | const NonWritableBasicBlock& else_block) const; |
| 64 | |
| 65 | /// Branch to this basic block if 'condition' if false, otherwise branch to |
| 66 | /// 'then_block'. |
| 67 | void BranchToIfNot(LlvmBuilder* builder, llvm::Value* condition, |
| 68 | const NonWritableBasicBlock& then_block) const; |
| 69 | |
| 70 | /// Create a basic block that is inserted before this basic block. |
| 71 | llvm::BasicBlock* CreateBasicBlockBefore(llvm::LLVMContext& context, |
| 72 | const std::string& name = "", llvm::Function* fn = nullptr) const; |
| 73 | private: |
| 74 | llvm::BasicBlock* basic_block_; |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | /// This class is used in conversions to and from 'CodegenAnyVal', i.e. 'AnyVal' objects |
no outgoing calls
no test coverage detected