Skip to content

Commit 27d09e6

Browse files
authored
[SandboxIR] Make some instruction constructors private (#119901)
This patch changes the visibility of the constructors of CatchSwitchInst ResumeInst and SwitchInst to private instead of public. This is similar to all other Sandbox IR instructions. The constructor is private to force the user go through the Context create* API. The issue was exposed by: #119824
1 parent da439d3 commit 27d09e6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/include/llvm/SandboxIR/Instruction.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,11 +1744,12 @@ class GetElementPtrInst final
17441744

17451745
class CatchSwitchInst
17461746
: public SingleLLVMInstructionImpl<llvm::CatchSwitchInst> {
1747-
public:
17481747
CatchSwitchInst(llvm::CatchSwitchInst *CSI, Context &Ctx)
17491748
: SingleLLVMInstructionImpl(ClassID::CatchSwitch, Opcode::CatchSwitch,
17501749
CSI, Ctx) {}
1750+
friend class Context; // For accessing the constructor in create*()
17511751

1752+
public:
17521753
static CatchSwitchInst *create(Value *ParentPad, BasicBlock *UnwindBB,
17531754
unsigned NumHandlers, InsertPosition Pos,
17541755
Context &Ctx, const Twine &Name = "");
@@ -1833,10 +1834,11 @@ class CatchSwitchInst
18331834
};
18341835

18351836
class ResumeInst : public SingleLLVMInstructionImpl<llvm::ResumeInst> {
1836-
public:
18371837
ResumeInst(llvm::ResumeInst *CSI, Context &Ctx)
18381838
: SingleLLVMInstructionImpl(ClassID::Resume, Opcode::Resume, CSI, Ctx) {}
1839+
friend class Context; // For accessing the constructor in create*()
18391840

1841+
public:
18401842
static ResumeInst *create(Value *Exn, InsertPosition Pos, Context &Ctx);
18411843
Value *getValue() const;
18421844
unsigned getNumSuccessors() const {
@@ -1848,10 +1850,11 @@ class ResumeInst : public SingleLLVMInstructionImpl<llvm::ResumeInst> {
18481850
};
18491851

18501852
class SwitchInst : public SingleLLVMInstructionImpl<llvm::SwitchInst> {
1851-
public:
18521853
SwitchInst(llvm::SwitchInst *SI, Context &Ctx)
18531854
: SingleLLVMInstructionImpl(ClassID::Switch, Opcode::Switch, SI, Ctx) {}
1855+
friend class Context; // For accessing the constructor in create*()
18541856

1857+
public:
18551858
static constexpr const unsigned DefaultPseudoIndex =
18561859
llvm::SwitchInst::DefaultPseudoIndex;
18571860

0 commit comments

Comments
 (0)