]> granicus.if.org Git - clang/commitdiff
Don't invent a '$auto-x-y' name for auto types in generic lambdas. This is no
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 9 Jan 2015 00:59:40 +0000 (00:59 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 9 Jan 2015 00:59:40 +0000 (00:59 +0000)
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, ...).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225489 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/PCH/cxx1y-lambdas.mm

index 6a910c2fc45594315bb1a90fee6dc55dd0e7bfbf..0f96a1cbce35dc7baba2894e346a6651e3d47c23 100644 (file)
@@ -1007,16 +1007,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
       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(TypeProcessingState &state) {
         /*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.
index ee4a2ba3ecc97e3b956d7c2b65b359c1cb101fe7..becf6cb6422248f348fdb1af79ad3acfd4a9f233 100644 (file)
@@ -50,7 +50,7 @@ int add(int x, int y) {
 }\r
 \r
 // CHECK-PRINT: inline int add_int_slowly_twice \r
-// CHECK-PRINT: lambda = [] ($auto-0-0 z\r
+// CHECK-PRINT: lambda = [] (type-parameter-0-0 z\r
 \r
 // CHECK-PRINT: init_capture\r
 // CHECK-PRINT: [&, x( t )]\r