aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-03-16 23:22:08 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-03-16 23:22:08 +0000
commit7c80bd64032e610c0dbd74fc0ef6ea334447f2fd (patch)
tree063757ae5ba5bc99323c26d4590654ed2f82a1b4 /lib/Sema/SemaType.cpp
parenta393e9eedcc28b25f521a4feceb3b56e3d0d360f (diff)
Almost complete implementation of rvalue references. One bug, and a few unclear areas. Maybe Doug can shed some light on some of the fixmes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index bfbc6c3708..ac0e1e1f73 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -319,8 +319,16 @@ QualType Sema::BuildPointerType(QualType T, unsigned Quals,
///
/// \returns A suitable reference type, if there are no
/// errors. Otherwise, returns a NULL type.
-QualType Sema::BuildReferenceType(QualType T, unsigned Quals,
+QualType Sema::BuildReferenceType(QualType T, bool LValueRef, unsigned Quals,
SourceLocation Loc, DeclarationName Entity) {
+ if (LValueRef) {
+ if (const RValueReferenceType *R = T->getAsRValueReferenceType()) {
+ // FIXME: Find the C++0x reference for reference collapsing.
+ // In reference collapsing, lvalue refs win over rvalue refs.
+ return Context.getLValueReferenceType(R->getPointeeType()).
+ getQualifiedType(Quals);
+ }
+ }
if (T->isReferenceType()) {
// C++ [dcl.ref]p4: There shall be no references to references.
//
@@ -367,7 +375,9 @@ QualType Sema::BuildReferenceType(QualType T, unsigned Quals,
Quals &= ~QualType::Volatile;
// Handle restrict on references.
- return Context.getReferenceType(T).getQualifiedType(Quals);
+ if (LValueRef)
+ return Context.getLValueReferenceType(T).getQualifiedType(Quals);
+ return Context.getRValueReferenceType(T).getQualifiedType(Quals);
}
/// \brief Build an array type.
@@ -603,8 +613,8 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip) {
T = BuildPointerType(T, DeclType.Ptr.TypeQuals, DeclType.Loc, Name);
break;
case DeclaratorChunk::Reference:
- T = BuildReferenceType(T,
- DeclType.Ref.HasRestrict? QualType::Restrict : 0,
+ T = BuildReferenceType(T, DeclType.Ref.LValueRef,
+ DeclType.Ref.HasRestrict ? QualType::Restrict : 0,
DeclType.Loc, Name);
break;
case DeclaratorChunk::Array: {