]> granicus.if.org Git - clang/commitdiff
Fix mangling numbers for varargs lambdas; varargs and non-varargs lambdas get
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 23 Oct 2016 04:53:03 +0000 (04:53 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 23 Oct 2016 04:53:03 +0000 (04:53 +0000)
different lambda-sigs, so they should have different counters.

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

lib/AST/ItaniumCXXABI.cpp
test/CodeGenCXX/mangle-lambdas.cpp

index 482c3c5d338f3ce55844472459596cc21d999a8b..091d5f031f8d0cc1351489cc157cfddc4e210aac 100644 (file)
@@ -63,9 +63,10 @@ public:
         CallOperator->getType()->getAs<FunctionProtoType>();
     ASTContext &Context = CallOperator->getASTContext();
 
+    FunctionProtoType::ExtProtoInfo EPI;
+    EPI.Variadic = Proto->isVariadic();
     QualType Key =
-        Context.getFunctionType(Context.VoidTy, Proto->getParamTypes(),
-                                FunctionProtoType::ExtProtoInfo());
+        Context.getFunctionType(Context.VoidTy, Proto->getParamTypes(), EPI);
     Key = Context.getCanonicalType(Key);
     return ++ManglingNumbers[Key->castAs<FunctionProtoType>()];
   }
index 051cfdc3a221ccc96d94ae5e78816976fb0340c4..15987ebe46bd6117f1fd2f22a02217b355ab20d8 100644 (file)
@@ -173,6 +173,16 @@ namespace PR12123 {
 
 // CHECK-LABEL: define linkonce_odr dereferenceable({{[0-9]+}}) %"struct.PR12123::A"* @_ZZN7PR121231B1fERKSt9type_infoEd_NKUlvE_clEv
 
+// CHECK-LABEL: define {{.*}} @_Z{{[0-9]*}}testVarargsLambdaNumberingv(
+inline int testVarargsLambdaNumbering() {
+  // CHECK: testVarargsLambdaNumberingvE{{.*}}UlzE_
+  auto a = [](...) { static int n; return ++n; };
+  // CHECK: testVarargsLambdaNumberingvE{{.*}}UlvE_
+  auto b = []() { static int n; return ++n; };
+  return a() + b();
+}
+int k = testVarargsLambdaNumbering();
+
 // Check linkage of the various lambdas.
 // CHECK-LABEL: define linkonce_odr i32 @_ZZ11inline_funciENKUlvE_clEv
 // CHECK: ret i32 1