]> granicus.if.org Git - clang/commitdiff
Deserialize the direct-initialization range of a "new" expression
authorDouglas Gregor <dgregor@apple.com>
Mon, 20 Feb 2012 16:12:14 +0000 (16:12 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 20 Feb 2012 16:12:14 +0000 (16:12 +0000)
properly. Previously, we deserialized it but failed to set the
corresponding member in CXXNewExpr. Fixes <rdar://problem/10893600>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150963 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReaderStmt.cpp
test/PCH/cxx-exprs.cpp [new file with mode: 0644]

index 8b85976bf42e865b7667fb969147fcf5b6a0167b..77e45416694fed597b0506a3eb2f6c949215df43 100644 (file)
@@ -1174,14 +1174,9 @@ void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
   E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
   E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
   E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
-  SourceRange TypeIdParens;
-  TypeIdParens.setBegin(ReadSourceLocation(Record, Idx));
-  TypeIdParens.setEnd(ReadSourceLocation(Record, Idx));
-  E->TypeIdParens = TypeIdParens;
+  E->TypeIdParens = ReadSourceRange(Record, Idx);
   E->StartLoc = ReadSourceLocation(Record, Idx);
-  SourceRange DirectInitRange;
-  DirectInitRange.setBegin(ReadSourceLocation(Record, Idx));
-  DirectInitRange.setEnd(ReadSourceLocation(Record, Idx));
+  E->DirectInitRange = ReadSourceRange(Record, Idx);
 
   E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
                        E->StoredInitializationStyle != 0);
diff --git a/test/PCH/cxx-exprs.cpp b/test/PCH/cxx-exprs.cpp
new file mode 100644 (file)
index 0000000..9cd3194
--- /dev/null
@@ -0,0 +1,27 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++11 %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++11 %s 
+
+#ifndef HEADER
+#define HEADER
+
+template<typename T>
+class New {
+  New(const New&);
+
+public:
+  New *clone() {
+    return new New(*this);
+  }
+};
+
+#else
+
+New<int> *clone_new(New<int> *n) {
+  return n->clone();
+}
+
+#endif