[cfe-commits] r139144 - in /cfe/trunk: lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriter.cpp test/PCH/cxx-implicit-moves.cpp

Douglas Gregor dgregor at apple.com
Tue Sep 6 09:38:47 PDT 2011


Author: dgregor
Date: Tue Sep  6 11:38:46 2011
New Revision: 139144

URL: http://llvm.org/viewvc/llvm-project?rev=139144&view=rev
Log:
Finish implementing (de-)serialization of the CXXDefinitionData bits
needed for implicit move constructors and move assignment
operators. Fixes PR10847.

Added:
    cfe/trunk/test/PCH/cxx-implicit-moves.cpp
Modified:
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=139144&r1=139143&r2=139144&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Sep  6 11:38:46 2011
@@ -859,7 +859,9 @@
                                    const RecordData &Record, unsigned &Idx) {
   Data.UserDeclaredConstructor = Record[Idx++];
   Data.UserDeclaredCopyConstructor = Record[Idx++];
+  Data.UserDeclaredMoveConstructor = Record[Idx++];
   Data.UserDeclaredCopyAssignment = Record[Idx++];
+  Data.UserDeclaredMoveAssignment = Record[Idx++];
   Data.UserDeclaredDestructor = Record[Idx++];
   Data.Aggregate = Record[Idx++];
   Data.PlainOldData = Record[Idx++];
@@ -884,7 +886,9 @@
   Data.UserProvidedDefaultConstructor = Record[Idx++];
   Data.DeclaredDefaultConstructor = Record[Idx++];
   Data.DeclaredCopyConstructor = Record[Idx++];
+  Data.DeclaredMoveConstructor = Record[Idx++];
   Data.DeclaredCopyAssignment = Record[Idx++];
+  Data.DeclaredMoveAssignment = Record[Idx++];
   Data.DeclaredDestructor = Record[Idx++];
   Data.FailedImplicitMoveConstructor = Record[Idx++];
   Data.FailedImplicitMoveAssignment = Record[Idx++];

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=139144&r1=139143&r2=139144&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Sep  6 11:38:46 2011
@@ -3878,7 +3878,9 @@
   struct CXXRecordDecl::DefinitionData &Data = *D->DefinitionData;
   Record.push_back(Data.UserDeclaredConstructor);
   Record.push_back(Data.UserDeclaredCopyConstructor);
+  Record.push_back(Data.UserDeclaredMoveConstructor);
   Record.push_back(Data.UserDeclaredCopyAssignment);
+  Record.push_back(Data.UserDeclaredMoveAssignment);
   Record.push_back(Data.UserDeclaredDestructor);
   Record.push_back(Data.Aggregate);
   Record.push_back(Data.PlainOldData);
@@ -3903,7 +3905,9 @@
   Record.push_back(Data.UserProvidedDefaultConstructor);
   Record.push_back(Data.DeclaredDefaultConstructor);
   Record.push_back(Data.DeclaredCopyConstructor);
+  Record.push_back(Data.DeclaredMoveConstructor);
   Record.push_back(Data.DeclaredCopyAssignment);
+  Record.push_back(Data.DeclaredMoveAssignment);
   Record.push_back(Data.DeclaredDestructor);
   Record.push_back(Data.FailedImplicitMoveConstructor);
   Record.push_back(Data.FailedImplicitMoveAssignment);

Added: cfe/trunk/test/PCH/cxx-implicit-moves.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-implicit-moves.cpp?rev=139144&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-implicit-moves.cpp (added)
+++ cfe/trunk/test/PCH/cxx-implicit-moves.cpp Tue Sep  6 11:38:46 2011
@@ -0,0 +1,23 @@
+// Test with PCH
+// RUN: %clang_cc1 -std=c++0x -x c++-header -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++0x -include-pch %t -verify %s
+
+// PR10847
+#ifndef HEADER
+#define HEADER
+struct NSSize {
+  double width;
+  double height;
+};
+typedef struct NSSize NSSize;
+
+static inline NSSize NSMakeSize(double w, double h) {
+    NSSize s = { w, h };
+    return s;
+}
+#else
+float test(float v1, float v2) {
+	NSSize s = NSMakeSize(v1, v2);
+	return s.width;
+}
+#endif





More information about the cfe-commits mailing list