[cfe-commits] r95249 - /cfe/trunk/lib/AST/ASTContext.cpp

Douglas Gregor dgregor at apple.com
Wed Feb 3 13:02:30 PST 2010


Author: dgregor
Date: Wed Feb  3 15:02:30 2010
New Revision: 95249

URL: http://llvm.org/viewvc/llvm-project?rev=95249&view=rev
Log:
Define two types to be "compatible" in C++ if they are the same, and
remove some age-old FIXMEs and C++ workarounds within the
type-compatibility logic.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=95249&r1=95248&r2=95249&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Feb  3 15:02:30 2010
@@ -4244,6 +4244,9 @@
 /// C99 6.2.7p1: Two types have compatible types if their types are the
 /// same. See 6.7.[2,3,5] for additional rules.
 bool ASTContext::typesAreCompatible(QualType LHS, QualType RHS) {
+  if (getLangOptions().CPlusPlus)
+    return hasSameType(LHS, RHS);
+  
   return !mergeTypes(LHS, RHS).isNull();
 }
 
@@ -4359,15 +4362,9 @@
   // designates the object or function denoted by the reference, and the
   // expression is an lvalue unless the reference is an rvalue reference and
   // the expression is a function call (possibly inside parentheses).
-  // FIXME: C++ shouldn't be going through here!  The rules are different
-  // enough that they should be handled separately.
-  // FIXME: Merging of lvalue and rvalue references is incorrect. C++ *really*
-  // shouldn't be going through here!
-  if (const ReferenceType *RT = LHS->getAs<ReferenceType>())
-    LHS = RT->getPointeeType();
-  if (const ReferenceType *RT = RHS->getAs<ReferenceType>())
-    RHS = RT->getPointeeType();
-
+  assert(!LHS->getAs<ReferenceType>() && "LHS is a reference type?");
+  assert(!RHS->getAs<ReferenceType>() && "RHS is a reference type?");
+  
   QualType LHSCan = getCanonicalType(LHS),
            RHSCan = getCanonicalType(RHS);
 





More information about the cfe-commits mailing list