From: Daniel Dunbar Date: Sat, 8 Nov 2008 04:42:29 +0000 (+0000) Subject: "Fix" PR3021, don't crash on generating record types when we can't X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7f6050113598797078f2718bc9f76c3ae35f0df;p=clang "Fix" PR3021, don't crash on generating record types when we can't generate the type of a member. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58889 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 478f862775..08cd129b63 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -363,6 +363,7 @@ CGDebugInfo::getOrCreateFunctionType(QualType type, llvm::CompileUnitDesc *Unit) for (unsigned int i =0; i < FTPro->getNumArgs(); i++) { QualType ParamType = FTPro->getArgType(i); ArgTy = getOrCreateType(ParamType, Unit); + // FIXME: Remove once we support all types. if (ArgTy) Elements.push_back(ArgTy); } } @@ -407,8 +408,11 @@ void CGDebugInfo::getOrCreateRecordType(QualType type, for (int i = 0; i < NumMembers; i++) { FieldDecl *Member = RecDecl->getMember(i); llvm::TypeDesc *MemberTy = getOrCreateType(Member->getType(), Unit); - MemberTy->setOffset(RL.getFieldOffset(i)); - Elements.push_back(MemberTy); + // FIXME: Remove once we support all types. + if (MemberTy) { + MemberTy->setOffset(RL.getFieldOffset(i)); + Elements.push_back(MemberTy); + } } // Fill in the blanks. diff --git a/test/CodeGen/PR3021-debug-info-and-typeof.c b/test/CodeGen/PR3021-debug-info-and-typeof.c new file mode 100644 index 0000000000..607462d5c8 --- /dev/null +++ b/test/CodeGen/PR3021-debug-info-and-typeof.c @@ -0,0 +1,5 @@ +// RUN: clang -o %t --emit-llvm -g %s + +void convert(void) { + struct { typeof(0) f0; } v0; +}