diff options
| author | Zachary Turner <zturner@google.com> | 2017-05-08 19:46:37 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2017-05-08 19:46:37 +0000 |
| commit | d9c9f084e28550b92463e6a6d04542b44f52cf54 (patch) | |
| tree | f8c59f8cd36c34dce57eb0f60c1e916e276e2e07 /llvm/include | |
| parent | efab02920a2bf472541a7f09b3fc46818c2360c5 (diff) | |
| download | bcm5719-llvm-d9c9f084e28550b92463e6a6d04542b44f52cf54.tar.gz bcm5719-llvm-d9c9f084e28550b92463e6a6d04542b44f52cf54.zip | |
Add some useful helper methods / operators to TypeIndex.
llvm-svn: 302460
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h b/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h index 3c11d248fa7..688b69c4a68 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeIndex.h @@ -106,6 +106,15 @@ public: bool isNoneType() const { return *this == None(); } + uint32_t toArrayIndex() const { + assert(!isSimple()); + return getIndex() - FirstNonSimpleIndex; + } + + static TypeIndex fromArrayIndex(uint32_t Index) { + return TypeIndex(Index + FirstNonSimpleIndex); + } + SimpleTypeKind getSimpleKind() const { assert(isSimple()); return static_cast<SimpleTypeKind>(Index & SimpleKindMask); @@ -159,6 +168,39 @@ public: static TypeIndex Float32() { return TypeIndex(SimpleTypeKind::Float32); } static TypeIndex Float64() { return TypeIndex(SimpleTypeKind::Float64); } + TypeIndex &operator+=(unsigned N) { + Index += N; + return *this; + } + + TypeIndex &operator++() { + Index += 1; + return *this; + } + + TypeIndex operator++(int) { + TypeIndex Copy = *this; + operator++(); + return Copy; + } + + TypeIndex &operator-=(unsigned N) { + assert(Index >= N); + Index -= N; + return *this; + } + + TypeIndex &operator--() { + Index -= 1; + return *this; + } + + TypeIndex operator--(int) { + TypeIndex Copy = *this; + operator--(); + return Copy; + } + friend inline bool operator==(const TypeIndex &A, const TypeIndex &B) { return A.getIndex() == B.getIndex(); } @@ -183,6 +225,19 @@ public: return A.getIndex() >= B.getIndex(); } + friend inline TypeIndex operator+(const TypeIndex &A, uint32_t N) { + TypeIndex Result(A); + Result += N; + return Result; + } + + friend inline TypeIndex operator-(const TypeIndex &A, uint32_t N) { + assert(A.getIndex() >= N); + TypeIndex Result(A); + Result -= N; + return Result; + } + private: support::ulittle32_t Index; }; |

