Fixed a bug handling void function types.

Requires rebuild of llvm-gcc4 (touch llvm-debug.cpp.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29131 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Laskey 2006-07-13 15:27:42 +00:00
parent 45c04fc676
commit d04c159ac1
2 changed files with 21 additions and 12 deletions

View File

@ -1413,7 +1413,7 @@ DIE *DwarfWriter::NewType(DIE *Context, TypeDesc *TyDesc, CompileUnit *Unit) {
Ty->AddUInt(DW_AT_prototyped, DW_FORM_flag, 1); Ty->AddUInt(DW_AT_prototyped, DW_FORM_flag, 1);
// Add return type. // Add return type.
Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4,
NewType(Context, cast<TypeDesc>(Elements[0]), Unit)); NewType(Context, dyn_cast<TypeDesc>(Elements[0]), Unit));
// Add arguments. // Add arguments.
for(unsigned i = 1, N = Elements.size(); i < N; ++i) { for(unsigned i = 1, N = Elements.size(); i < N; ++i) {

View File

@ -223,16 +223,21 @@ public:
Field = getGlobalVariable(C); Field = getGlobalVariable(C);
} }
virtual void Apply(std::vector<DebugInfoDesc *> &Field) { virtual void Apply(std::vector<DebugInfoDesc *> &Field) {
Field.resize(0);
Constant *C = CI->getOperand(I++); Constant *C = CI->getOperand(I++);
GlobalVariable *GV = getGlobalVariable(C); GlobalVariable *GV = getGlobalVariable(C);
Field.resize(0); if (GV->hasInitializer()) {
// Have to be able to deal with the empty array case (zero initializer) if (ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer())) {
if (!GV->hasInitializer()) return; for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) {
if (ConstantArray *CA = dyn_cast<ConstantArray>(GV->getInitializer())) { GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i));
for (unsigned i = 0, N = CA->getNumOperands(); i < N; ++i) { DebugInfoDesc *DE = DR.Deserialize(GVE);
GlobalVariable *GVE = getGlobalVariable(CA->getOperand(i)); Field.push_back(DE);
DebugInfoDesc *DE = DR.Deserialize(GVE); }
Field.push_back(DE); } else if (GV->getInitializer()->isNullValue()) {
if (const ArrayType *T =
dyn_cast<ArrayType>(GV->getType()->getElementType())) {
Field.resize(T->getNumElements());
}
} }
} }
} }
@ -305,9 +310,13 @@ public:
std::vector<Constant *> ArrayElements; std::vector<Constant *> ArrayElements;
for (unsigned i = 0, N = Field.size(); i < N; ++i) { for (unsigned i = 0, N = Field.size(); i < N; ++i) {
GlobalVariable *GVE = SR.Serialize(Field[i]); if (DebugInfoDesc *Element = Field[i]) {
Constant *CE = ConstantExpr::getCast(GVE, EmptyTy); GlobalVariable *GVE = SR.Serialize(Element);
ArrayElements.push_back(cast<Constant>(CE)); Constant *CE = ConstantExpr::getCast(GVE, EmptyTy);
ArrayElements.push_back(cast<Constant>(CE));
} else {
ArrayElements.push_back(ConstantPointerNull::get(EmptyTy));
}
} }
Constant *CA = ConstantArray::get(AT, ArrayElements); Constant *CA = ConstantArray::get(AT, ArrayElements);