r224483 - CGDebugInfo: Use DIBuilder API for self-referencing DICompositeTypes
Duncan P. N. Exon Smith
dexonsmith at apple.com
Wed Dec 17 16:48:56 PST 2014
Author: dexonsmith
Date: Wed Dec 17 18:48:56 2014
New Revision: 224483
URL: http://llvm.org/viewvc/llvm-project?rev=224483&view=rev
Log:
CGDebugInfo: Use DIBuilder API for self-referencing DICompositeTypes
Use new `DIBuilder` API from LLVM r224482 to mutate `DICompositeType`s,
rather than changing them directly. This allows `DIBuilder` to track
otherwise orphaned cycles when `CollectContainingType()` creates a
self-reference.
Fixes PR21941.
Added:
cfe/trunk/test/CodeGenCXX/vtable-holder-self-reference.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=224483&r1=224482&r2=224483&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Dec 17 18:48:56 2014
@@ -422,9 +422,10 @@ llvm::DIType CGDebugInfo::CreateType(con
DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(),
0, 0, 0, 0, llvm::DIType(), llvm::DIArray());
- ObjTy.setArrays(DBuilder.getOrCreateArray(
- &*DBuilder.createMemberType(ObjTy, "isa", getOrCreateMainFile(), 0,
- Size, 0, 0, 0, ISATy)));
+ DBuilder.replaceArrays(
+ ObjTy,
+ DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
+ ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 0, ISATy)));
return ObjTy;
}
case BuiltinType::ObjCSel: {
@@ -1593,7 +1594,7 @@ llvm::DIType CGDebugInfo::CreateTypeDefi
RegionMap.erase(Ty->getDecl());
llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
- FwdDecl.setArrays(Elements);
+ DBuilder.replaceArrays(FwdDecl, Elements);
RegionMap[Ty->getDecl()].reset(FwdDecl);
return FwdDecl;
@@ -1795,7 +1796,7 @@ llvm::DIType CGDebugInfo::CreateTypeDefi
}
llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
- RealDecl.setArrays(Elements);
+ DBuilder.replaceArrays(RealDecl, Elements);
LexicalBlockStack.pop_back();
return RealDecl;
@@ -2204,7 +2205,7 @@ llvm::DIType CGDebugInfo::getOrCreateLim
// Propagate members from the declaration to the definition
// CreateType(const RecordType*) will overwrite this with the members in the
// correct order if the full type is needed.
- Res.setArrays(T.getElements());
+ DBuilder.replaceArrays(Res, T.getElements());
// And update the type cache.
TypeCache[QTy.getAsOpaquePtr()].reset(Res);
@@ -2260,8 +2261,8 @@ llvm::DICompositeType CGDebugInfo::Creat
if (const ClassTemplateSpecializationDecl *TSpecial =
dyn_cast<ClassTemplateSpecializationDecl>(RD))
- RealDecl.setArrays(llvm::DIArray(),
- CollectCXXTemplateParams(TSpecial, DefUnit));
+ DBuilder.replaceArrays(RealDecl, llvm::DIArray(),
+ CollectCXXTemplateParams(TSpecial, DefUnit));
return RealDecl;
}
@@ -2286,7 +2287,7 @@ void CGDebugInfo::CollectContainingType(
} else if (RD->isDynamicClass())
ContainingType = RealDecl;
- RealDecl.setContainingType(ContainingType);
+ DBuilder.replaceVTableHolder(RealDecl, ContainingType);
}
/// CreateMemberType - Create new member and increase Offset by FType's size.
Added: cfe/trunk/test/CodeGenCXX/vtable-holder-self-reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vtable-holder-self-reference.cpp?rev=224483&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/vtable-holder-self-reference.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/vtable-holder-self-reference.cpp Wed Dec 17 18:48:56 2014
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -gdwarf-2 -x c++ -o - %s | FileCheck %s
+//
+// PR21941: crasher for self-referencing DW_TAG_structure_type node. If we get
+// rid of self-referenceing structure_types (PR21902), then it should be safe
+// to just kill this test.
+//
+// CHECK: ![[SELF:[0-9]+]] = !{!"0x13\00B\00{{[^"]*}}", {{[^,]+}}, {{[^,]+}}, {{[^,]+}}, {{[^,]+}}, ![[SELF]], {{[^}]+}}} ; [ DW_TAG_structure_type ] [B]
+
+void foo() {
+ struct V {
+ int vi;
+ };
+ struct B : virtual V {};
+ B b;
+}
More information about the cfe-commits
mailing list