[llvm-commits] [llvm-gcc-4-2] r39919 - in /llvm-gcc-4-2/trunk/gcc: llvm-convert.cpp llvm-internal.h llvm-types.cpp
Duncan Sands
baldrick at free.fr
Mon Jul 16 02:32:59 PDT 2007
Author: baldrick
Date: Mon Jul 16 04:32:56 2007
New Revision: 39919
URL: http://llvm.org/viewvc/llvm-project?rev=39919&view=rev
Log:
Abort if someone tries to look up a field index value
that hasn't been set. Note that if a type has been
converted then fields with no index do get an index
value (~0U), so this won't fire for them.
Modified:
llvm-gcc-4-2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4-2/trunk/gcc/llvm-internal.h
llvm-gcc-4-2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4-2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4-2/trunk/gcc/llvm-convert.cpp?rev=39919&r1=39918&r2=39919&view=diff
==============================================================================
--- llvm-gcc-4-2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4-2/trunk/gcc/llvm-convert.cpp Mon Jul 16 04:32:56 2007
@@ -4952,7 +4952,6 @@
// 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 = TheTypeConverter->GetFieldIndex(FieldDecl);
- assert(MemberIndex != ~0U && "Struct not laid out for LLVM?");
assert(MemberIndex < StructTy->getNumContainedTypes() &&
"Field Idx out of range!");
FieldPtr = Builder.CreateGEP(StructAddrLV.Ptr,
@@ -5655,7 +5654,7 @@
// it may be just this field, or it may just be a small part of this field.
unsigned int FieldNo = TheTypeConverter->GetFieldIndex(Field);
assert(FieldNo < ResultElts.size() && "Invalid struct field number!");
-
+
// Get the offset and size of the LLVM field.
uint64_t STyFieldBitOffs = STyLayout->getElementOffset(FieldNo)*8;
@@ -5792,7 +5791,6 @@
} else {
// If not, things are much simpler.
unsigned int FieldNo = TheTypeConverter->GetFieldIndex(Field);
- assert(FieldNo != ~0U && "Struct not laid out for LLVM?");
assert(FieldNo < ResultElts.size() && "Invalid struct field number!");
// Example: struct X { int A; char C[]; } x = { 4, "foo" };
@@ -6026,8 +6024,7 @@
// 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 = TheTypeConverter->GetFieldIndex(FieldDecl);
- assert(MemberIndex != ~0U && "Struct not laid out for LLVM?");
-
+
std::vector<Value*> Idxs;
Idxs.push_back(Constant::getNullValue(Type::Int32Ty));
Idxs.push_back(ConstantInt::get(Type::Int32Ty, MemberIndex));
Modified: llvm-gcc-4-2/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4-2/trunk/gcc/llvm-internal.h?rev=39919&r1=39918&r2=39919&view=diff
==============================================================================
--- llvm-gcc-4-2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4-2/trunk/gcc/llvm-internal.h Mon Jul 16 04:32:56 2007
@@ -134,8 +134,7 @@
const Type *ConvertType(tree_node *type);
/// GetFieldIndex - Returns the index of the LLVM field corresponding to
- /// this FIELD_DECL, or ~0U if the type the field belongs to has not yet
- /// been converted.
+ /// this FIELD_DECL.
unsigned int GetFieldIndex(tree_node *field_decl);
/// GCCTypeOverlapsWithLLVMTypePadding - Return true if the specified GCC type
Modified: llvm-gcc-4-2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4-2/trunk/gcc/llvm-types.cpp?rev=39919&r1=39918&r2=39919&view=diff
==============================================================================
--- llvm-gcc-4-2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4-2/trunk/gcc/llvm-types.cpp Mon Jul 16 04:32:56 2007
@@ -608,10 +608,12 @@
unsigned int TypeConverter::GetFieldIndex(tree_node *field_decl) {
assert(TREE_CODE(field_decl) == FIELD_DECL && "Not a FIELD_DECL!");
std::map<tree, unsigned int>::iterator I = FieldIndexMap.find(field_decl);
- if (I != FieldIndexMap.end())
+ if (I != FieldIndexMap.end()) {
return I->second;
- else
+ } else {
+ assert(false && "Type not laid out for LLVM?");
return ~0U;
+ }
}
/// SetFieldIndex - Set the index of the LLVM field corresponding to
More information about the llvm-commits
mailing list