[cfe-commits] r81841 - in /cfe/trunk/lib/Sema: Sema.cpp SemaExprCXX.cpp

Anders Carlsson andersca at mac.com
Mon Sep 14 22:28:24 PDT 2009


Author: andersca
Date: Tue Sep 15 00:28:24 2009
New Revision: 81841

URL: http://llvm.org/viewvc/llvm-project?rev=81841&view=rev
Log:
Only reuse an already existing ImplicitCastExpr if the cast kinds are the same.

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=81841&r1=81840&r2=81841&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Sep 15 00:28:24 2009
@@ -230,10 +230,14 @@
   }
 
   if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr)) {
-    ImpCast->setType(Ty);
-    ImpCast->setLvalueCast(isLvalue);
-  } else
-    Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, isLvalue);
+    if (ImpCast->getCastKind() == Kind) {
+      ImpCast->setType(Ty);
+      ImpCast->setLvalueCast(isLvalue);
+      return;
+    }
+  }
+
+  Expr = new (Context) ImplicitCastExpr(Ty, Kind, Expr, isLvalue);
 }
 
 void Sema::DeleteExpr(ExprTy *E) {

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=81841&r1=81840&r2=81841&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Sep 15 00:28:24 2009
@@ -991,9 +991,15 @@
       if (CastArg.isInvalid())
         return true;
       
-      From = new (Context) ImplicitCastExpr(ToType.getNonReferenceType(),
-                                            CastKind, CastArg.takeAs<Expr>(), 
-                                            ToType->isLValueReferenceType());
+      QualType CastArgType = ((Expr *)CastArg.get())->getType();
+      From = 
+        new (Context) ImplicitCastExpr(CastArgType, CastKind, 
+                                       CastArg.takeAs<Expr>(), 
+                                       CastArgType->isLValueReferenceType());
+      if (PerformImplicitConversion(From, ToType.getNonReferenceType(),
+                                    ICS.UserDefined.After, "converting"))
+        return true;
+      
       return false;
     }
 





More information about the cfe-commits mailing list