[cfe-commits] r129358 - in /cfe/trunk: lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/PCH/cxx-reference.cpp test/PCH/cxx-reference.h
Richard Smith
richard-llvm at metafoo.co.uk
Tue Apr 12 03:38:03 PDT 2011
Author: rsmith
Date: Tue Apr 12 05:38:03 2011
New Revision: 129358
URL: http://llvm.org/viewvc/llvm-project?rev=129358&view=rev
Log:
Fix AST serialization of reference-to-reference types. This previously caused
a crash when deserializing the AST for this:
typedef char (&R);
extern R &r;
Added:
cfe/trunk/test/PCH/cxx-reference.cpp
cfe/trunk/test/PCH/cxx-reference.h
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=129358&r1=129357&r2=129358&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Apr 12 05:38:03 2011
@@ -3009,12 +3009,12 @@
}
case TYPE_LVALUE_REFERENCE: {
- if (Record.size() != 1) {
+ if (Record.size() != 2) {
Error("Incorrect encoding of lvalue reference type");
return QualType();
}
QualType PointeeType = GetType(Record[0]);
- return Context->getLValueReferenceType(PointeeType);
+ return Context->getLValueReferenceType(PointeeType, Record[1]);
}
case TYPE_RVALUE_REFERENCE: {
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=129358&r1=129357&r2=129358&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Apr 12 05:38:03 2011
@@ -105,12 +105,13 @@
}
void ASTTypeWriter::VisitLValueReferenceType(const LValueReferenceType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
+ Writer.AddTypeRef(T->getPointeeTypeAsWritten(), Record);
+ Record.push_back(T->isSpelledAsLValue());
Code = TYPE_LVALUE_REFERENCE;
}
void ASTTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
+ Writer.AddTypeRef(T->getPointeeTypeAsWritten(), Record);
Code = TYPE_RVALUE_REFERENCE;
}
Added: cfe/trunk/test/PCH/cxx-reference.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-reference.cpp?rev=129358&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-reference.cpp (added)
+++ cfe/trunk/test/PCH/cxx-reference.cpp Tue Apr 12 05:38:03 2011
@@ -0,0 +1,6 @@
+// Test this without pch.
+// RUN: %clang_cc1 -std=c++0x -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-reference.h
+// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s
Added: cfe/trunk/test/PCH/cxx-reference.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-reference.h?rev=129358&view=auto
==============================================================================
--- cfe/trunk/test/PCH/cxx-reference.h (added)
+++ cfe/trunk/test/PCH/cxx-reference.h Tue Apr 12 05:38:03 2011
@@ -0,0 +1,13 @@
+// Header for PCH test cxx-reference.cpp
+
+typedef char (&LR);
+typedef char (&&RR);
+
+char c;
+
+char &lr = c;
+char &&rr = 'c';
+LR &lrlr = c;
+LR &&rrlr = c;
+RR &lrrr = c;
+RR &&rrrr = 'c';
More information about the cfe-commits
mailing list