[llvm-commits] [llvm-gcc-4.2] r66411 - /llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp
Bill Wendling
isanbard at gmail.com
Sun Mar 8 23:58:31 PDT 2009
Author: void
Date: Mon Mar 9 01:58:31 2009
New Revision: 66411
URL: http://llvm.org/viewvc/llvm-project?rev=66411&view=rev
Log:
Merge 66402 into Dib:
Fix PR3744 - Crash on index into zero element struct.
Modified:
llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp?rev=66411&r1=66410&r2=66411&view=diff
==============================================================================
--- llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Dib/gcc/llvm-convert.cpp Mon Mar 9 01:58:31 2009
@@ -6163,9 +6163,15 @@
// If this is a normal field at a fixed offset from the start, handle it.
if (TREE_CODE(field_offset) == INTEGER_CST) {
unsigned int MemberIndex = GetFieldIndex(FieldDecl);
- assert(MemberIndex < StructTy->getNumContainedTypes() &&
- "Field Idx out of range!");
- FieldPtr = Builder.CreateStructGEP(StructAddrLV.Ptr, MemberIndex);
+
+ // If the LLVM struct has zero field, don't try to index into it, just use
+ // the current pointer.
+ FieldPtr = StructAddrLV.Ptr;
+ if (StructTy->getNumContainedTypes() != 0) {
+ assert(MemberIndex < StructTy->getNumContainedTypes() &&
+ "Field Idx out of range!");
+ FieldPtr = Builder.CreateStructGEP(FieldPtr, MemberIndex);
+ }
// Now that we did an offset from the start of the struct, subtract off
// the offset from BitStart.
More information about the llvm-commits
mailing list