forked from OSchip/llvm-project
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; llvm-svn: 129358
This commit is contained in:
parent
8b82f087a0
commit
0f538460d2
|
@ -3009,12 +3009,12 @@ QualType ASTReader::ReadTypeRecord(unsigned Index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_LVALUE_REFERENCE: {
|
case TYPE_LVALUE_REFERENCE: {
|
||||||
if (Record.size() != 1) {
|
if (Record.size() != 2) {
|
||||||
Error("Incorrect encoding of lvalue reference type");
|
Error("Incorrect encoding of lvalue reference type");
|
||||||
return QualType();
|
return QualType();
|
||||||
}
|
}
|
||||||
QualType PointeeType = GetType(Record[0]);
|
QualType PointeeType = GetType(Record[0]);
|
||||||
return Context->getLValueReferenceType(PointeeType);
|
return Context->getLValueReferenceType(PointeeType, Record[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_RVALUE_REFERENCE: {
|
case TYPE_RVALUE_REFERENCE: {
|
||||||
|
|
|
@ -105,12 +105,13 @@ void ASTTypeWriter::VisitBlockPointerType(const BlockPointerType *T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTTypeWriter::VisitLValueReferenceType(const LValueReferenceType *T) {
|
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;
|
Code = TYPE_LVALUE_REFERENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {
|
void ASTTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {
|
||||||
Writer.AddTypeRef(T->getPointeeType(), Record);
|
Writer.AddTypeRef(T->getPointeeTypeAsWritten(), Record);
|
||||||
Code = TYPE_RVALUE_REFERENCE;
|
Code = TYPE_RVALUE_REFERENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -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';
|
Loading…
Reference in New Issue