[cfe-commits] r98083 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h test/CodeGenCXX/2010-03-09-AnonAggregate.cpp
Devang Patel
dpatel at apple.com
Tue Mar 9 13:32:27 PST 2010
Author: dpatel
Date: Tue Mar 9 15:32:27 2010
New Revision: 98083
URL: http://llvm.org/viewvc/llvm-project?rev=98083&view=rev
Log:
More then one anonymous aggregates on one line creates chaos when MDNode uniquness is combined with RAUW operation. Right solution is to avoid using RAUW.
This fixes PR 6554.
Added:
cfe/trunk/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=98083&r1=98082&r2=98083&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Mar 9 15:32:27 2010
@@ -37,7 +37,7 @@
CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
: CGM(CGM), DebugFactory(CGM.getModule()),
- BlockLiteralGenericSet(false) {
+ FwdDeclCount(0), BlockLiteralGenericSet(false) {
CreateCompileUnit();
}
@@ -774,12 +774,12 @@
// A RD->getName() is not unique. However, the debug info descriptors
// are uniqued so use type name to ensure uniquness.
- std::string STy = QualType(Ty, 0).getAsString();
+ char *FwdDeclName = (char *)alloca(65);
+ sprintf(FwdDeclName, "fwd.type.%d", FwdDeclCount++);
llvm::DIDescriptor FDContext =
getContextDescriptor(dyn_cast<Decl>(RD->getDeclContext()), Unit);
llvm::DICompositeType FwdDecl =
- DebugFactory.CreateCompositeType(Tag, FDContext,
- STy.c_str(),
+ DebugFactory.CreateCompositeType(Tag, FDContext, FwdDeclName,
DefUnit, Line, 0, 0, 0, 0,
llvm::DIType(), llvm::DIArray());
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=98083&r1=98082&r2=98083&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Mar 9 15:32:27 2010
@@ -45,11 +45,11 @@
CodeGenModule &CGM;
llvm::DIFactory DebugFactory;
llvm::DICompileUnit TheCU;
-
SourceLocation CurLoc, PrevLoc;
-
llvm::DIType VTablePtrType;
-
+ /// FwdDeclCount - This counter is used to ensure unique names for forward
+ /// record decls.
+ unsigned FwdDeclCount;
/// TypeCache - Cache of previously constructed Types.
// FIXME: Eliminate this map. Be careful of iterator invalidation.
Added: cfe/trunk/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp?rev=98083&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/2010-03-09-AnonAggregate.cpp Tue Mar 9 15:32:27 2010
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -g -S -o %t %s
+// PR: 6554
+// More then one anonymous aggregates on one line creates chaos when MDNode uniquness is
+// combined with RAUW operation.
+// This test case causes crashes if malloc is configured to trip buffer overruns.
+class MO {
+
+ union { struct { union { int BA; } Val; int Offset; } OffsetedInfo; } Contents;
+
+};
+
+class MO m;
More information about the cfe-commits
mailing list