From 1facf89eafb82226278693ca6eee4819d3dfc86f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 17 Oct 2003 18:03:54 +0000 Subject: [PATCH] Do not crash on empty structures llvm-svn: 9195 --- llvm/lib/Transforms/TransformInternals.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/lib/Transforms/TransformInternals.cpp b/llvm/lib/Transforms/TransformInternals.cpp index f726e829aa60..820dd3878e0c 100644 --- a/llvm/lib/Transforms/TransformInternals.cpp +++ b/llvm/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(Ty)) { + if (STy->getElementTypes().empty()) { + Offset = 0; + return STy; + } + ThisOffset = Offset; NextType = getStructOffsetStep(STy, ThisOffset, Indices, TD); } else if (const ArrayType *ATy = dyn_cast(Ty)) {