[cfe-commits] r110381 - in /cfe/trunk: lib/CodeGen/Mangle.cpp test/CodeGenCXX/mangle.cpp
John McCall
rjmccall at apple.com
Thu Aug 5 15:02:14 PDT 2010
Author: rjmccall
Date: Thu Aug 5 17:02:13 2010
New Revision: 110381
URL: http://llvm.org/viewvc/llvm-project?rev=110381&view=rev
Log:
Don't crash when mangling empty anonymous unions. We never actually *need*
these, but it's convenient to mangle them when deferring them (in the 99.99%
case where it's not an anonymous union, of course).
Modified:
cfe/trunk/lib/CodeGen/Mangle.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp
Modified: cfe/trunk/lib/CodeGen/Mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=110381&r1=110380&r2=110381&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/Mangle.cpp (original)
+++ cfe/trunk/lib/CodeGen/Mangle.cpp Thu Aug 5 17:02:13 2010
@@ -699,7 +699,11 @@
// a program to refer to the anonymous union, and there is therefore no
// need to mangle its name.
const FieldDecl *FD = FindFirstNamedDataMember(RD);
- assert(FD && "Didn't find a named data member!");
+
+ // It's actually possible for various reasons for us to get here
+ // with an empty anonymous struct / union. Fortunately, it
+ // doesn't really matter what name we generate.
+ if (!FD) break;
assert(FD->getIdentifier() && "Data member name isn't an identifier!");
mangleSourceName(FD->getIdentifier());
Modified: cfe/trunk/test/CodeGenCXX/mangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle.cpp?rev=110381&r1=110380&r2=110381&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle.cpp Thu Aug 5 17:02:13 2010
@@ -529,3 +529,14 @@
// CHECK: define weak_odr void @_ZN6test151fILi7EEEvNS_1SIXplT_LNS_1EE3EEEE(
template void f<7>(S<7 + e>);
}
+
+// rdar://problem/8125400. Don't crash.
+namespace test16 {
+ static union {};
+ static union { union {}; };
+ static union { struct {}; };
+ static union { union { union {}; }; };
+ static union { union { struct {}; }; };
+ static union { struct { union {}; }; };
+ static union { struct { struct {}; }; };
+}
More information about the cfe-commits
mailing list