summaryrefslogtreecommitdiff
path: root/lib/IR/ConstantsContext.h
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2015-12-15 06:11:36 +0000
committerCraig Topper <craig.topper@gmail.com>2015-12-15 06:11:36 +0000
commit07e8f8869589124603ea6b678e4540cb840f781d (patch)
treed439fea3fdcec01d8e90ac8643f39215ccbf966b /lib/IR/ConstantsContext.h
parent240b0e16f64a14362ec76758cc0699148b42219b (diff)
[IR] Add classof for GetElementPtrConstantExpr, CompareConstantExpr, InsertValueConstantExpr, and ExtractValueConstantExpr. All but CompareConstantExpr were being used in casts that were erroneously using ConstantExpr::classof due to inheritance. While there use cast<CompareConstantExpr> to simplify code slightly.
I believe in one place we were always casting to ExtractValueConstantExpr when we were trying to choose between ExtractValueConstantExpr and InsertValueConstantExpr because of this. But since they have identical layouts this didn't cause any observable problems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255624 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/ConstantsContext.h')
-rw-r--r--lib/IR/ConstantsContext.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/IR/ConstantsContext.h b/lib/IR/ConstantsContext.h
index 33e89515b26..13fcbd2ece1 100644
--- a/lib/IR/ConstantsContext.h
+++ b/lib/IR/ConstantsContext.h
@@ -179,6 +179,13 @@ public:
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::ExtractValue;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// InsertValueConstantExpr - This class is private to
@@ -205,6 +212,13 @@ public:
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::InsertValue;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
/// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
@@ -235,6 +249,13 @@ public:
Type *getSourceElementType() const;
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::GetElementPtr;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
// CompareConstantExpr - This class is private to Constants.cpp, and is used
@@ -257,6 +278,14 @@ public:
}
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
+ static bool classof(const ConstantExpr *CE) {
+ return CE->getOpcode() == Instruction::ICmp ||
+ CE->getOpcode() == Instruction::FCmp;
+ }
+ static bool classof(const Value *V) {
+ return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
+ }
};
template <>