[PATCH] D29208: Prevent ICE in dllexport class with _Atomic() data member
Warren Ristow via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 26 18:38:26 PST 2017
wristow created this revision.
Guard against a null pointer dereference that caused Clang to crash
when processing a class containing an _Atomic(<typ>) data member,
and that is tagged with 'dllexport'.
https://reviews.llvm.org/D29208
Files:
lib/CodeGen/CGClass.cpp
test/CodeGenCXX/atomic-dllexport.cpp
Index: test/CodeGenCXX/atomic-dllexport.cpp
===================================================================
--- test/CodeGenCXX/atomic-dllexport.cpp
+++ test/CodeGenCXX/atomic-dllexport.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++11 -fms-extensions -O0 -o - %s | FileCheck --check-prefix=M32 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++11 -fms-extensions -O0 -o - %s | FileCheck --check-prefix=M64 %s
+
+struct __declspec(dllexport) SomeStruct {
+ // Copy assignment operator should be produced, and exported:
+ // M32: define weak_odr dllexport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.SomeStruct* @"\01??4SomeStruct@@QAEAAU0 at ABU0@@Z"
+ // M64: define weak_odr dllexport dereferenceable({{[0-9]+}}) %struct.SomeStruct* @"\01??4SomeStruct@@QEAAAEAU0 at AEBU0@@Z"
+ _Atomic(int) mData;
+};
Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1132,7 +1132,7 @@
if (!RHS)
return nullptr;
MemberExpr *ME2 = dyn_cast<MemberExpr>(RHS);
- if (dyn_cast<FieldDecl>(ME2->getMemberDecl()) != Field)
+ if (!ME2 || dyn_cast<FieldDecl>(ME2->getMemberDecl()) != Field)
return nullptr;
return Field;
} else if (CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(S)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29208.85998.patch
Type: text/x-patch
Size: 1428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170127/ef9c1db2/attachment.bin>
More information about the cfe-commits
mailing list