diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-17 18:03:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-17 18:03:54 +0000 |
commit | 949310140982438bd01ff8f40b499e88914ce01d (patch) | |
tree | b9dd6a35062ee9c322c38114b659209162086ec2 /lib/Transforms/TransformInternals.cpp | |
parent | 8a7ae306b2ea020089f7d4e739590be63e6d9c8b (diff) |
Do not crash on empty structures
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9195 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/TransformInternals.cpp')
-rw-r--r-- | lib/Transforms/TransformInternals.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index f726e829aa..820dd3878e 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -53,6 +53,11 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, uint64_t ThisOffset; const Type *NextType; if (const StructType *STy = dyn_cast<StructType>(Ty)) { + if (STy->getElementTypes().empty()) { + Offset = 0; + return STy; + } + ThisOffset = Offset; NextType = getStructOffsetStep(STy, ThisOffset, Indices, TD); } else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) { |