[PATCH] D24312: [CodeGen] Fix an assert in EmitNullConstant
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 13 15:21:34 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281405: [CodeGen] Fix an assert in EmitNullConstant. (authored by ahatanak).
Changed prior to commit:
https://reviews.llvm.org/D24312?vs=70589&id=71248#toc
Repository:
rL LLVM
https://reviews.llvm.org/D24312
Files:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGenCXX/empty-classes.cpp
Index: cfe/trunk/test/CodeGenCXX/empty-classes.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/empty-classes.cpp
+++ cfe/trunk/test/CodeGenCXX/empty-classes.cpp
@@ -96,3 +96,24 @@
// Type checked at the top of the file.
B b;
};
+
+// This test used to crash when CGRecordLayout::getNonVirtualBaseLLVMFieldNo was called.
+namespace record_layout {
+struct X0 {
+ int x[0];
+};
+
+template<typename>
+struct X2 : X0 {
+};
+
+template<typename>
+struct X3 : X2<int> {
+ X3() : X2<int>() {}
+};
+
+
+void test0() {
+ X3<int>();
+}
+}
Index: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp
@@ -1532,7 +1532,8 @@
cast<CXXRecordDecl>(I.getType()->castAs<RecordType>()->getDecl());
// Ignore empty bases.
- if (base->isEmpty())
+ if (base->isEmpty() ||
+ CGM.getContext().getASTRecordLayout(base).getNonVirtualSize().isZero())
continue;
unsigned fieldIndex = layout.getNonVirtualBaseLLVMFieldNo(base);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24312.71248.patch
Type: text/x-patch
Size: 1154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160913/4fcc100d/attachment.bin>
More information about the cfe-commits
mailing list