From 7460fd297dc401697f28fd540513331ff22f1345 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 7 Apr 2008 06:52:53 +0000 Subject: [PATCH] simplify reference handling. llvm-svn: 49325 --- clang/lib/AST/ASTContext.cpp | 17 ----------------- clang/lib/Sema/SemaExpr.cpp | 2 +- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 187871b32e00..e781040172c0 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1468,23 +1468,6 @@ bool ASTContext::pointerTypesAreCompatible(QualType lhs, QualType rhs) { return typesAreCompatible(ltype, rtype); } -// C++ 5.17p6: When the left operand of an assignment operator denotes a -// reference to T, the operation assigns to the object of type T denoted by the -// reference. -bool ASTContext::referenceTypesAreCompatible(QualType lhs, QualType rhs) { - QualType ltype = lhs; - - if (lhs->isReferenceType()) - ltype = cast(lhs.getCanonicalType())->getPointeeType(); - - QualType rtype = rhs; - - if (rhs->isReferenceType()) - rtype = cast(rhs.getCanonicalType())->getPointeeType(); - - return typesAreCompatible(ltype, rtype); -} - bool ASTContext::functionTypesAreCompatible(QualType lhs, QualType rhs) { const FunctionType *lbase = cast(lhs.getCanonicalType()); const FunctionType *rbase = cast(rhs.getCanonicalType()); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index f0f05006f373..f4ef2839855b 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1179,7 +1179,7 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) { return Compatible; // Common case: fast path an exact match. if (lhsType->isReferenceType() || rhsType->isReferenceType()) { - if (Context.referenceTypesAreCompatible(lhsType, rhsType)) + if (Context.typesAreCompatible(lhsType, rhsType)) return Compatible; return Incompatible; }