[llvm] 5022a5f - Mark llvm::ConstantExpr::getAsInstruction as const
Alex Denisov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 12 05:24:19 PST 2019
Author: Alex Denisov
Date: 2019-11-12T14:24:12+01:00
New Revision: 5022a5fcaef9e8e5a739d5794954d67bc6f291a2
URL: https://github.com/llvm/llvm-project/commit/5022a5fcaef9e8e5a739d5794954d67bc6f291a2
DIFF: https://github.com/llvm/llvm-project/commit/5022a5fcaef9e8e5a739d5794954d67bc6f291a2.diff
LOG: Mark llvm::ConstantExpr::getAsInstruction as const
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
Added:
Modified:
llvm/include/llvm/IR/Constants.h
llvm/lib/IR/Constants.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index ca56e8b9328c..7f0687d382f0 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -1250,7 +1250,7 @@ class ConstantExpr : public Constant {
/// 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) {
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index a6a8eaac2f94..b5df4ea8af6c 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -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);
More information about the llvm-commits
mailing list