[cfe-commits] r86207 - in /cfe/trunk/lib/Sema: SemaDeclCXX.cpp SemaExprCXX.cpp SemaOverload.cpp SemaOverload.h

Fariborz Jahanian fjahanian at apple.com
Thu Nov 5 16:23:08 PST 2009


Author: fjahanian
Date: Thu Nov  5 18:23:08 2009
New Revision: 86207

URL: http://llvm.org/viewvc/llvm-project?rev=86207&view=rev
Log:
This patch implements Sema for clause 13.3.3.1p4.
It has to do with vararg constructors used as conversion
functions. Code gen needs work. This is WIP.


Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaOverload.h

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Nov  5 18:23:08 2009
@@ -3827,6 +3827,7 @@
         ICS->UserDefined.Before = Best->Conversions[0].Standard;
         ICS->UserDefined.After = Best->FinalConversion;
         ICS->UserDefined.ConversionFunction = Best->Function;
+        ICS->UserDefined.EllipsisConversion = false;
         assert(ICS->UserDefined.After.ReferenceBinding &&
                ICS->UserDefined.After.DirectBinding &&
                "Expected a direct reference binding!");

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Nov  5 18:23:08 2009
@@ -1086,18 +1086,21 @@
       } else if (const CXXConstructorDecl *Ctor = 
                   dyn_cast<CXXConstructorDecl>(FD)) {
         CastKind = CastExpr::CK_ConstructorConversion;
-
-        // If the user-defined conversion is specified by a constructor, the 
-        // initial standard conversion sequence converts the source type to the
-        // type required by the argument of the constructor
-        BeforeToType = Ctor->getParamDecl(0)->getType();
+        // Do no conversion if dealing with ... for the first conversion.
+        if (!ICS.UserDefined.EllipsisConversion)
+          // If the user-defined conversion is specified by a constructor, the 
+          // initial standard conversion sequence converts the source type to the
+          // type required by the argument of the constructor
+          BeforeToType = Ctor->getParamDecl(0)->getType();
       }    
       else
         assert(0 && "Unknown conversion function kind!");
-
-      if (PerformImplicitConversion(From, BeforeToType, 
-                                    ICS.UserDefined.Before, "converting"))
-        return true;
+      // Whatch out for elipsis conversion.
+      if (!BeforeToType.isNull()) {
+        if (PerformImplicitConversion(From, BeforeToType, 
+                                      ICS.UserDefined.Before, "converting"))
+          return true;
+      }
     
       OwningExprResult CastArg 
         = BuildCXXCastArgument(From->getLocStart(),

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov  5 18:23:08 2009
@@ -1481,9 +1481,14 @@
         //   sequence converts the source type to the type required by
         //   the argument of the constructor.
         //
-        // FIXME: What about ellipsis conversions?
         QualType ThisType = Constructor->getThisType(Context);
-        User.Before = Best->Conversions[0].Standard;
+        if (Best->Conversions[0].ConversionKind == 
+            ImplicitConversionSequence::EllipsisConversion)
+          User.EllipsisConversion = true;
+        else {
+          User.Before = Best->Conversions[0].Standard;
+          User.EllipsisConversion = false;
+        }
         User.ConversionFunction = Constructor;
         User.After.setAsIdentityConversion();
         User.After.FromTypePtr
@@ -1500,6 +1505,7 @@
         //   implicit object parameter of the conversion function.
         User.Before = Best->Conversions[0].Standard;
         User.ConversionFunction = Conversion;
+        User.EllipsisConversion = false;
 
         // C++ [over.ics.user]p2:
         //   The second standard conversion sequence converts the
@@ -2693,6 +2699,7 @@
   Candidate.Conversions[0].ConversionKind
     = ImplicitConversionSequence::UserDefinedConversion;
   Candidate.Conversions[0].UserDefined.Before = ObjectInit.Standard;
+  Candidate.Conversions[0].UserDefined.EllipsisConversion = false;
   Candidate.Conversions[0].UserDefined.ConversionFunction = Conversion;
   Candidate.Conversions[0].UserDefined.After
     = Candidate.Conversions[0].UserDefined.Before;

Modified: cfe/trunk/lib/Sema/SemaOverload.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.h?rev=86207&r1=86206&r2=86207&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.h (original)
+++ cfe/trunk/lib/Sema/SemaOverload.h Thu Nov  5 18:23:08 2009
@@ -156,6 +156,14 @@
     ///   object parameter of the conversion function.
     StandardConversionSequence Before;
 
+    /// EllipsisConversion - When this is true, it means user-defined
+    /// conversion sequence starts with a ... (elipsis) conversion, instead of 
+    /// a standard conversion. In this case, 'Before' field must be ignored.
+    // FIXME. I much rather put this as the first field. But there seems to be
+    // a gcc code gen. bug which causes a crash in a test. Putting it here seems
+    // to work around the crash.
+    bool EllipsisConversion : 1;
+    
     /// After - Represents the standard conversion that occurs after
     /// the actual user-defined conversion.
     StandardConversionSequence After;





More information about the cfe-commits mailing list