aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/TargetData.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-12-04 21:03:02 +0000
committerBill Wendling <isanbard@gmail.com>2009-12-04 21:03:02 +0000
commit1500c4f49a975fd6a800c70d3245f8d6e145c677 (patch)
treed361d24b16b87ad219a3231da14fdd9e8c7d380f /lib/Target/TargetData.cpp
parentff7707e98393255e23a66f3f6689cdcf59197548 (diff)
downloadexternal_llvm-1500c4f49a975fd6a800c70d3245f8d6e145c677.zip
external_llvm-1500c4f49a975fd6a800c70d3245f8d6e145c677.tar.gz
external_llvm-1500c4f49a975fd6a800c70d3245f8d6e145c677.tar.bz2
Some code cleanup. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90588 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r--lib/Target/TargetData.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index e482e20..1f576f5 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -315,11 +315,12 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
: Alignments[BestMatchIdx].PrefAlign;
}
-typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
-
namespace {
class StructLayoutMap : public AbstractTypeUser {
+public:
+ typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
+private:
LayoutInfoTy LayoutInfo;
/// refineAbstractType - The callback method invoked when an abstract type is
@@ -328,9 +329,7 @@ class StructLayoutMap : public AbstractTypeUser {
///
virtual void refineAbstractType(const DerivedType *OldTy,
const Type *) {
- const StructType *STy = dyn_cast<const StructType>(OldTy);
- assert(STy && "This can only track struct types.");
-
+ const StructType *STy = cast<const StructType>(OldTy);
LayoutInfoTy::iterator Iter = LayoutInfo.find(STy);
Iter->second->~StructLayout();
free(Iter->second);
@@ -344,9 +343,7 @@ class StructLayoutMap : public AbstractTypeUser {
/// This method notifies ATU's when this occurs for a type.
///
virtual void typeBecameConcrete(const DerivedType *AbsTy) {
- const StructType *STy = dyn_cast<const StructType>(AbsTy);
- assert(STy && "This can only track struct types.");
-
+ const StructType *STy = cast<const StructType>(AbsTy);
LayoutInfoTy::iterator Iter = LayoutInfo.find(STy);
Iter->second->~StructLayout();
free(Iter->second);
@@ -362,13 +359,11 @@ public:
const Type *Key = I->first;
StructLayout *Value = I->second;
- if (Key && Key->isAbstract())
+ if (Key->isAbstract())
Key->removeAbstractTypeUser(this);
- if (Value) {
- Value->~StructLayout();
- free(Value);
- }
+ Value->~StructLayout();
+ free(Value);
}
}
@@ -392,7 +387,7 @@ public:
virtual void dump() const {}
};
-} // end namespace llvm
+} // end anonymous namespace
TargetData::~TargetData() {
delete static_cast<StructLayoutMap*>(LayoutMap);
@@ -432,7 +427,7 @@ void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const {
if (!LayoutMap) return; // No cache.
StructLayoutMap *STM = static_cast<StructLayoutMap*>(LayoutMap);
- LayoutInfoTy::iterator I = STM->find(Ty);
+ StructLayoutMap::LayoutInfoTy::iterator I = STM->find(Ty);
if (I == STM->end()) return;
I->second->~StructLayout();