From 4aeb30d14a493264600c4f75424fa74d1b1ddad2 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Tue, 12 Aug 2014 04:42:23 +0000 Subject: [PATCH] Debuginfo: Correctly tag variadic ObjC methods with DW_TAG_unspecified_parameter. Fixes rdar://13690847 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215423 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 3 +++ test/CodeGenObjC/debug-info-variadic-method.m | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 test/CodeGenObjC/debug-info-variadic-method.m diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index db545c6430..d621755fba 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2429,6 +2429,9 @@ llvm::DICompositeType CGDebugInfo::getOrCreateFunctionType(const Decl *D, // Get rest of the arguments. for (const auto *PI : OMethod->params()) Elts.push_back(getOrCreateType(PI->getType(), F)); + // Variadic methods need a special marker at the end of the type list. + if (OMethod->isVariadic()) + Elts.push_back(DBuilder.createUnspecifiedParameter()); llvm::DITypeArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts); return DBuilder.createSubroutineType(F, EltTypeArray); diff --git a/test/CodeGenObjC/debug-info-variadic-method.m b/test/CodeGenObjC/debug-info-variadic-method.m new file mode 100644 index 0000000000..8d49ce2b98 --- /dev/null +++ b/test/CodeGenObjC/debug-info-variadic-method.m @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -o - -emit-llvm -g %s | FileCheck %s + +// This test verifies that variadic ObjC methods get the +// DW_TAG_unspecified_parameter marker. + +@interface Foo +- (void) Bar: (int) n, ...; +@end + +@implementation Foo +- (void) Bar: (int) n, ... +{ + // CHECK: metadata ![[NUM:[^,]*]], i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] + // CHECK: ![[NUM]] = {{metadata !{null, metadata ![^,]*, metadata ![^,]*, metadata ![^,]*, null}}} +} +@end -- 2.40.0