r225489 - Don't invent a '$auto-x-y' name for auto types in generic lambdas. This is no

Richard Smith richard-llvm at metafoo.co.uk
Thu Jan 8 16:59:40 PST 2015


Author: rsmith
Date: Thu Jan  8 18:59:40 2015
New Revision: 225489

URL: http://llvm.org/viewvc/llvm-project?rev=225489&view=rev
Log:
Don't invent a '$auto-x-y' name for auto types in generic lambdas. This is no
better than the 'template-parameter-x-y' name that we'd get in AST printing,
and is worse in several ways (it's harder to distinguish it from a
user-supplied name, it's wrong after substituting some number of outer
levels, it wastes time and space constructing an IdentifierInfo, ...).

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/PCH/cxx1y-lambdas.mm

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=225489&r1=225488&r2=225489&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Jan  8 18:59:40 2015
@@ -1007,16 +1007,7 @@ static QualType ConvertDeclSpecToType(Ty
       const unsigned TemplateParameterDepth = LSI->AutoTemplateParameterDepth;
       const unsigned AutoParameterPosition = LSI->AutoTemplateParams.size();
       const bool IsParameterPack = declarator.hasEllipsis();
-      
-      // Create a name for the invented template parameter type.
-      std::string InventedTemplateParamName = "$auto-";
-      llvm::raw_string_ostream ss(InventedTemplateParamName);
-      ss << TemplateParameterDepth; 
-      ss << "-" << AutoParameterPosition;
-      ss.flush();
 
-      IdentifierInfo& TemplateParamII = Context.Idents.get(
-                                        InventedTemplateParamName.c_str());
       // Turns out we must create the TemplateTypeParmDecl here to 
       // retrieve the corresponding template parameter type. 
       TemplateTypeParmDecl *CorrespondingTemplateParam =
@@ -1031,7 +1022,7 @@ static QualType ConvertDeclSpecToType(Ty
         /*NameLoc*/ declarator.getLocStart(),  
         TemplateParameterDepth, 
         AutoParameterPosition,  // our template param index 
-        /* Identifier*/ &TemplateParamII, false, IsParameterPack);
+        /* Identifier*/ nullptr, false, IsParameterPack);
       LSI->AutoTemplateParams.push_back(CorrespondingTemplateParam);
       // Replace the 'auto' in the function parameter with this invented 
       // template type parameter.

Modified: cfe/trunk/test/PCH/cxx1y-lambdas.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx1y-lambdas.mm?rev=225489&r1=225488&r2=225489&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx1y-lambdas.mm (original)
+++ cfe/trunk/test/PCH/cxx1y-lambdas.mm Thu Jan  8 18:59:40 2015
@@ -50,7 +50,7 @@ int add(int x, int y) {
 }
 
 // CHECK-PRINT: inline int add_int_slowly_twice 
-// CHECK-PRINT: lambda = [] ($auto-0-0 z
+// CHECK-PRINT: lambda = [] (type-parameter-0-0 z
 
 // CHECK-PRINT: init_capture
 // CHECK-PRINT: [&, x( t )]





More information about the cfe-commits mailing list