[PATCH] D29208: Prevent ICE in dllexport class with _Atomic() data member

Warren Ristow via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 1 21:31:21 PST 2017


wristow updated this revision to Diff 86767.
wristow added a comment.

Code restructured.


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
@@ -1131,10 +1131,11 @@
           RHS = EC->getSubExpr();
         if (!RHS)
           return nullptr;
-        MemberExpr *ME2 = dyn_cast<MemberExpr>(RHS);
-        if (dyn_cast<FieldDecl>(ME2->getMemberDecl()) != Field)
-          return nullptr;
-        return Field;
+        if (MemberExpr *ME2 = dyn_cast<MemberExpr>(RHS)) {
+          if (ME2->getMemberDecl() == Field)
+            return Field;
+        }
+        return nullptr;
       } else if (CXXMemberCallExpr *MCE = dyn_cast<CXXMemberCallExpr>(S)) {
         CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(MCE->getCalleeDecl());
         if (!(MD && isMemcpyEquivalentSpecialMember(MD)))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29208.86767.patch
Type: text/x-patch
Size: 1696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170202/835751e2/attachment.bin>


More information about the cfe-commits mailing list