[cfe-commits] r43142 - /cfe/trunk/Sema/SemaExpr.cpp

Steve Naroff snaroff at apple.com
Thu Oct 18 11:55:53 PDT 2007


Author: snaroff
Date: Thu Oct 18 13:55:53 2007
New Revision: 43142

URL: http://llvm.org/viewvc/llvm-project?rev=43142&view=rev
Log:

Tweak a recent fix to UsualArithmeticConversions (made by Chris - r43113). The benefit of this tweak is it guarantees the entire routine operates on unqualified types (which I believe is a bit clearer).  

Modified:
    cfe/trunk/Sema/SemaExpr.cpp

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43142&r1=43141&r2=43142&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Thu Oct 18 13:55:53 2007
@@ -867,12 +867,14 @@
     UsualUnaryConversions(lhsExpr);
     UsualUnaryConversions(rhsExpr);
   }
-  QualType lhs = lhsExpr->getType();
-  QualType rhs = rhsExpr->getType();
+  // For conversion purposes, we ignore any qualifiers. 
+  // For example, "const float" and "float" are equivalent.
+  QualType lhs = lhsExpr->getType().getUnqualifiedType();
+  QualType rhs = rhsExpr->getType().getUnqualifiedType();
   
   // If both types are identical, no conversion is needed.
-  if (lhs.getTypePtr() == rhs.getTypePtr())
-    return lhs.getQualifiedType(0);
+  if (lhs == rhs)
+    return lhs;
   
   // If either side is a non-arithmetic type (e.g. a pointer), we are done.
   // The caller can deal with this (e.g. pointer + int).





More information about the cfe-commits mailing list