]> granicus.if.org Git - clang/commitdiff
AST for conversion by conversion functions. WIP.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 26 Aug 2009 20:34:58 +0000 (20:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 26 Aug 2009 20:34:58 +0000 (20:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80135 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/Sema/SemaExprCXX.cpp

index febda6971ba04a9add74f27e4e9489925373a9c8..1f9d6e2e9e52b5060e296e8410a782ae223e0ebc 100644 (file)
@@ -1188,7 +1188,11 @@ public:
     
     /// CK_BaseToDerivedMemberPointer - Member pointer in base class to
     /// member pointer in derived class.
-    CK_BaseToDerivedMemberPointer
+    CK_BaseToDerivedMemberPointer,
+
+    /// CK_Unknown - Conversion using a user defined type conversion
+    /// function.
+    CK_UserDefinedConversion
   };
   
   struct CastInfo {
index 2b0749aec029bea411e66cfe6ebc11ef4c2993c1..ae5010cfac329d1952c3d323718b8c728f2f0583 100644 (file)
@@ -216,9 +216,10 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
       return ExprError();
     exprs.release();
     return Owned(new (Context) CXXFunctionalCastExpr(Ty.getNonReferenceType(),
-                                                     Ty, TyBeginLoc, Kind,
-                                                     Exprs[0], ConversionDecl, 
-                                                     RParenLoc));
+                                          Ty, TyBeginLoc, 
+                                          CastExpr::CK_UserDefinedConversion,
+                                          Exprs[0], ConversionDecl, 
+                                          RParenLoc));
   }
 
   if (const RecordType *RT = Ty->getAs<RecordType>()) {
@@ -906,9 +907,16 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
     break;
 
   case ImplicitConversionSequence::UserDefinedConversion:
-    // FIXME: This is, of course, wrong. We'll need to actually call the
-    // constructor or conversion operator, and then cope with the standard
-    // conversions.
+      // FIXME. Support other kinds of user defined convesions.
+      if (CXXConversionDecl *CV = 
+            dyn_cast<CXXConversionDecl>(ICS.UserDefined.ConversionFunction))
+        // FIXME. Get actual Source Location.
+        From = 
+          new (Context) CXXFunctionalCastExpr(ToType.getNonReferenceType(),
+                                            ToType, SourceLocation(), 
+                                            CastExpr::CK_UserDefinedConversion,
+                                            From, CV,
+                                            SourceLocation());
     ImpCastExprToType(From, ToType.getNonReferenceType(), 
                       CastExpr::CK_Unknown,
                       ToType->isLValueReferenceType());