Mark llvm::ConstantExpr::getAsInstruction as const
authorAlex Denisov <alex@lowlevelbits.org>
Tue, 12 Nov 2019 09:57:32 +0000 (10:57 +0100)
committerAlex Denisov <alex@lowlevelbits.org>
Tue, 12 Nov 2019 13:24:12 +0000 (14:24 +0100)
Summary:
getAsInstruction is the only non-const member method.
It is impossible to enforce const-correctness because of it.

Reviewers: jmolloy, majnemer

Reviewed By: jmolloy

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70113

llvm/include/llvm/IR/Constants.h
llvm/lib/IR/Constants.cpp

index ca56e8b..7f0687d 100644 (file)
@@ -1250,7 +1250,7 @@ public:
   /// which would take a ConstantExpr parameter, but that would have spread
   /// implementation details of ConstantExpr outside of Constants.cpp, which
   /// would make it harder to remove ConstantExprs altogether.
-  Instruction *getAsInstruction();
+  Instruction *getAsInstruction() const;
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const Value *V) {
index a6a8eaa..b5df4ea 100644 (file)
@@ -3004,7 +3004,7 @@ Value *ConstantExpr::handleOperandChangeImpl(Value *From, Value *ToV) {
       NewOps, this, From, To, NumUpdated, OperandNo);
 }
 
-Instruction *ConstantExpr::getAsInstruction() {
+Instruction *ConstantExpr::getAsInstruction() const {
   SmallVector<Value *, 4> ValueOperands(op_begin(), op_end());
   ArrayRef<Value*> Ops(ValueOperands);