Factorize code: remove variants of "strip off

pointer bitcasts and GEP's", and centralize the
logic in Value::getUnderlyingObject.  The
difference with stripPointerCasts is that
stripPointerCasts only strips GEPs if all
indices are zero, while getUnderlyingObject
strips GEPs no matter what the indices are.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56922 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2008-10-01 15:25:41 +00:00
parent 38ac062c2f
commit 5d0392c6b3
7 changed files with 57 additions and 136 deletions

View File

@@ -228,11 +228,20 @@ public:
/// stripPointerCasts - This method strips off any unneeded pointer
/// casts from the specified value, returning the original uncasted value.
/// Note that the returned value is guaranteed to have pointer type.
/// Note that the returned value has pointer type if the specified value does.
Value *stripPointerCasts();
const Value *stripPointerCasts() const {
return const_cast<Value*>(this)->stripPointerCasts();
}
/// getUnderlyingObject - This method strips off any GEP address adjustments
/// and pointer casts from the specified value, returning the original object
/// being addressed. Note that the returned value has pointer type if the
/// specified value does.
Value *getUnderlyingObject();
const Value *getUnderlyingObject() const {
return const_cast<Value*>(this)->getUnderlyingObject();
}
};
inline std::ostream &operator<<(std::ostream &OS, const Value &V) {