aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-17 19:47:21 +0000
committerChris Lattner <sabre@nondot.org>2003-11-17 19:47:21 +0000
commit48babfa60d3ee1854f33ad93e07abb2b22cf8ab8 (patch)
tree458718a60cbff364df0648407441fcd51f6e3e07
parentcb7a1eba4571f1efb472121f585b1dfcdea90bc7 (diff)
The ConstantPointer class is now gone.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10057 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Constants.h59
-rw-r--r--lib/VMCore/Constants.cpp13
2 files changed, 23 insertions, 49 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 06f1308fdf..2b8ea6ab3f 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -385,41 +385,14 @@ public:
};
//===---------------------------------------------------------------------------
-/// ConstantPointer - Constant Pointer Declarations
-///
-/// The ConstantPointer class represents a null pointer of a specific type. For
-/// a more specific/useful instance, a subclass of ConstantPointer should be
-/// used.
-///
-class ConstantPointer : public Constant {
- ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT
-protected:
- inline ConstantPointer(const PointerType *T)
- : Constant(reinterpret_cast<const Type*>(T)) { }
-public:
- inline const PointerType *getType() const {
- return reinterpret_cast<const PointerType*>(Value::getType());
- }
-
- /// isNullValue - Return true if this is the value that would be returned by
- /// getNullValue.
- virtual bool isNullValue() const { return false; }
-
- /// Methods for support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const ConstantPointer *) { return true; }
- static bool classof(const Constant *CPV); // defined in Constants.cpp
- static inline bool classof(const Value *V) {
- return isa<Constant>(V) && classof(cast<Constant>(V));
- }
-};
-
/// ConstantPointerNull - a constant pointer value that points to null
///
-class ConstantPointerNull : public ConstantPointer {
+class ConstantPointerNull : public Constant {
friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
protected:
- ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
+ ConstantPointerNull(const PointerType *T)
+ : Constant(reinterpret_cast<const Type*>(T)) {}
public:
@@ -434,22 +407,18 @@ public:
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantPointerNull *) { return true; }
- static inline bool classof(const ConstantPointer *P) {
- return (P->getNumOperands() == 0 && P->isNullValue());
- }
- static inline bool classof(const Constant *CPV) {
- return isa<ConstantPointer>(CPV) && classof(cast<ConstantPointer>(CPV));
- }
+ static bool classof(const Constant *CPV);
static inline bool classof(const Value *V) {
- return isa<ConstantPointer>(V) && classof(cast<ConstantPointer>(V));
+ return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
+//===---------------------------------------------------------------------------
/// ConstantPointerRef - a constant pointer value that is initialized to
/// point to a global value, which lies at a constant, fixed address.
///
-class ConstantPointerRef : public ConstantPointer {
+class ConstantPointerRef : public Constant {
friend class Module; // Modules maintain these references
ConstantPointerRef(const ConstantPointerRef &); // DNI!
@@ -467,21 +436,19 @@ public:
return cast<GlobalValue>(Operands[0].get());
}
+ /// isNullValue - Return true if this is the value that would be returned by
+ /// getNullValue.
+ virtual bool isNullValue() const { return false; }
+
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
bool DisableChecking = false);
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantPointerRef *) { return true; }
- static inline bool classof(const ConstantPointer *CPV) {
- // check for a single operand (the target value)
- return (CPV->getNumOperands() == 1);
- }
- static inline bool classof(const Constant *CPV) {
- return isa<ConstantPointer>(CPV) && classof(cast<ConstantPointer>(CPV));
- }
+ static bool classof(const Constant *CPV);
static inline bool classof(const Value *V) {
- return isa<ConstantPointer>(V) && classof(cast<ConstantPointer>(V));
+ return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 527eff5490..05bbef16b3 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -278,7 +278,7 @@ ConstantStruct::ConstantStruct(const StructType *T,
}
ConstantPointerRef::ConstantPointerRef(GlobalValue *GV)
- : ConstantPointer(GV->getType()) {
+ : Constant(GV->getType()) {
Operands.push_back(Use(GV, this));
}
@@ -337,8 +337,15 @@ bool ConstantArray::classof(const Constant *CPV) {
bool ConstantStruct::classof(const Constant *CPV) {
return isa<StructType>(CPV->getType()) && !isa<ConstantExpr>(CPV);
}
-bool ConstantPointer::classof(const Constant *CPV) {
- return (isa<PointerType>(CPV->getType()) && !isa<ConstantExpr>(CPV));
+
+bool ConstantPointerNull::classof(const Constant *CPV) {
+ return isa<PointerType>(CPV->getType()) && !isa<ConstantExpr>(CPV) &&
+ CPV->getNumOperands() == 0;
+}
+
+bool ConstantPointerRef::classof(const Constant *CPV) {
+ return isa<PointerType>(CPV->getType()) && !isa<ConstantExpr>(CPV) &&
+ CPV->getNumOperands() == 1;
}