From 00586d02b1af56efadc99cb3967ad6caf6f4b849 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 23 Oct 2016 04:53:03 +0000 Subject: [PATCH] Fix mangling numbers for varargs lambdas; varargs and non-varargs lambdas get 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 | 5 +++-- test/CodeGenCXX/mangle-lambdas.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/AST/ItaniumCXXABI.cpp b/lib/AST/ItaniumCXXABI.cpp index 482c3c5d33..091d5f031f 100644 --- a/lib/AST/ItaniumCXXABI.cpp +++ b/lib/AST/ItaniumCXXABI.cpp @@ -63,9 +63,10 @@ public: CallOperator->getType()->getAs(); 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()]; } diff --git a/test/CodeGenCXX/mangle-lambdas.cpp b/test/CodeGenCXX/mangle-lambdas.cpp index 051cfdc3a2..15987ebe46 100644 --- a/test/CodeGenCXX/mangle-lambdas.cpp +++ b/test/CodeGenCXX/mangle-lambdas.cpp @@ -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 -- 2.40.0