diff options
author | Chris Lattner <sabre@nondot.org> | 2001-07-23 05:03:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-07-23 05:03:15 +0000 |
commit | 50d89859e203bb0c43d5b636ea7a394cb48848a7 (patch) | |
tree | ebdb2364c5b8411d7e4f80e1c6cd02142c385327 /include/llvm | |
parent | d8fa8e2aa1fe30747bf2860cc9f7f226eda42666 (diff) | |
download | external_llvm-50d89859e203bb0c43d5b636ea7a394cb48848a7.zip external_llvm-50d89859e203bb0c43d5b636ea7a394cb48848a7.tar.gz external_llvm-50d89859e203bb0c43d5b636ea7a394cb48848a7.tar.bz2 |
Fix coding style issues to actually attempt to be somewhat uniform
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/DerivedTypes.h | 76 |
1 files changed, 28 insertions, 48 deletions
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index 405a632..f58d01d 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -48,7 +48,6 @@ public: }; - class ArrayType : public Type { private: const Type *ElementType; @@ -79,6 +78,7 @@ public: } }; + class StructType : public Type { public: typedef vector<const Type*> ElementTypes; @@ -89,8 +89,7 @@ private: int storageSize; // -1 until the value is computd vector<int> memberOffsets; // -1 until values are computed const TargetMachine* targetInfo; - } - *layoutCache; + } *layoutCache; private: StructType(const StructType &); // Do not implement @@ -105,72 +104,53 @@ protected: StructType(const vector<const Type*> &Types, const string &Name); // Reset cached info so it will be computed when first requested - void ResetCachedInfo() const; + void ResetCachedInfo() const { + layoutCache->storageSize = -1; + layoutCache->memberOffsets.insert(layoutCache->memberOffsets.begin(), + ETypes.size(), -1); + layoutCache->targetInfo = 0; + } public: - inline const ElementTypes &getElementTypes() const { return ETypes; } static const StructType *getStructType(const ElementTypes &Params); static const StructType *get(const ElementTypes &Params) { return getStructType(Params); } - unsigned int getStorageSize(const TargetMachine& tmi) const; - unsigned int getElementOffset(int i, const TargetMachine& tmi) const; -}; -inline unsigned int -StructType::getStorageSize(const TargetMachine& tmi) const -{ - if (layoutCache->targetInfo != NULL && ! (* layoutCache->targetInfo == tmi)) - {// target machine has changed (hey it could happen). discard cached info. + unsigned int getStorageSize(const TargetMachine& tmi) const { + if (layoutCache->targetInfo && *layoutCache->targetInfo != tmi) { + // target machine has changed (hey it could happen). discard cached info. ResetCachedInfo(); layoutCache->targetInfo = &tmi; } - if (layoutCache->storageSize < 0) - { + if (layoutCache->storageSize < 0) { layoutCache->storageSize = tmi.findOptimalStorageSize(this); assert(layoutCache->storageSize >= 0); } - - return layoutCache->storageSize; -} - - -inline unsigned int -StructType::getElementOffset(int i, const TargetMachine& tmi) const -{ - if (layoutCache->targetInfo != NULL && ! (* layoutCache->targetInfo == tmi)) - {// target machine has changed (hey it could happen). discard cached info. + return layoutCache->storageSize; + } + unsigned int getElementOffset(int i, const TargetMachine& tmi) const { + // target machine has changed (hey it could happen). discard cached info. + if (layoutCache->targetInfo && *layoutCache->targetInfo != tmi) ResetCachedInfo(); - } - if (layoutCache->memberOffsets[i] < 0) - { - layoutCache->targetInfo = &tmi; // remember which target was used + if (layoutCache->memberOffsets[i] < 0) { + layoutCache->targetInfo = &tmi; // remember which target was used - unsigned int* offsetVec = tmi.findOptimalMemberOffsets(this); - for (unsigned i=0, N=layoutCache->memberOffsets.size(); i < N; i++) - { - layoutCache->memberOffsets[i] = offsetVec[i]; - assert(layoutCache->memberOffsets[i] >= 0); - } + unsigned int *offsetVec = tmi.findOptimalMemberOffsets(this); + for (unsigned i=0, N=layoutCache->memberOffsets.size(); i < N; ++i) { + layoutCache->memberOffsets[i] = offsetVec[i]; + assert(layoutCache->memberOffsets[i] >= 0); + } delete[] offsetVec; } - - return layoutCache->memberOffsets[i]; -} - - -inline void -StructType::ResetCachedInfo() const -{ - layoutCache->storageSize = -1; - layoutCache->memberOffsets.insert(layoutCache->memberOffsets.begin(), - ETypes.size(), -1); - layoutCache->targetInfo = NULL; -} + + return layoutCache->memberOffsets[i]; + } +}; class PointerType : public Type { |