Address review comments for r202188.

This is refactoring / simplifying code, updating comments and enabling the
testcase on non-x86 platforms.

No functionality change.

llvm-svn: 202199
This commit is contained in:
Adrian Prantl 2014-02-25 22:27:14 +00:00
parent 248ac13975
commit 69140d2c0f
4 changed files with 30 additions and 37 deletions

View File

@ -403,22 +403,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(DwarfCompileUnit *SPCU,
DIArray Args = SPTy.getTypeArray();
uint16_t SPTag = SPTy.getTag();
if (SPTag == dwarf::DW_TAG_subroutine_type)
// FIXME: Use DwarfUnit::constructSubprogramArguments() here.
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIType ATy(Args.getElement(i));
if (ATy.isUnspecifiedParameter()) {
assert(i == N-1 && "ellipsis must be the last argument");
SPCU->createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, *SPDie);
} else {
DIE *Arg =
SPCU->createAndAddDIE(dwarf::DW_TAG_formal_parameter, *SPDie);
SPCU->addType(Arg, ATy);
if (ATy.isArtificial())
SPCU->addFlag(Arg, dwarf::DW_AT_artificial);
if (ATy.isObjectPointer())
SPCU->addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, Arg);
}
}
SPCU->constructSubprogramArguments(*SPDie, Args);
DIE *SPDeclDie = SPDie;
SPDie = SPCU->createAndAddDIE(dwarf::DW_TAG_subprogram,
*SPCU->getUnitDie());
@ -598,9 +583,8 @@ DIE *DwarfDebug::createScopeChildrenDIE(DwarfCompileUnit *TheCU,
ObjectPointer = Arg;
}
// Create the unspecified parameter that marks a function as variadic.
// If this is a variadic function, add an unspecified parameter.
DISubprogram SP(Scope->getScopeNode());
assert(SP.Verify());
DIArray FnArgs = SP.getType().getTypeArray();
if (FnArgs.getElement(FnArgs.getNumElements()-1).isUnspecifiedParameter()) {
DIE *Ellipsis = new DIE(dwarf::DW_TAG_unspecified_parameters);

View File

@ -1144,7 +1144,7 @@ void DwarfUnit::constructSubprogramArguments(DIE &Buffer, DIArray Args) {
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIDescriptor Ty = Args.getElement(i);
if (Ty.isUnspecifiedParameter()) {
assert(i == N-1 && "ellipsis must be the last argument");
assert(i == N-1 && "Unspecified parameter must be the last argument");
createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
} else {
DIE *Arg = createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);

View File

@ -452,6 +452,9 @@ public:
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
DIE *constructVariableDIE(DbgVariable &DV, bool isScopeAbstract);
/// constructSubprogramArguments - Construct function argument DIEs.
void constructSubprogramArguments(DIE &Buffer, DIArray Args);
/// Create a DIE with the given Tag, add the DIE to its parent, and
/// call insertDIE if MD is not null.
DIE *createAndAddDIE(unsigned Tag, DIE &Parent,
@ -476,9 +479,6 @@ protected:
DIE *getOrCreateStaticMemberDIE(DIDerivedType DT);
private:
/// constructSubprogramArguments - Construct function argument DIEs.
void constructSubprogramArguments(DIE &Buffer, DIArray Args);
/// constructTypeDIE - Construct basic type die from DIBasicType.
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);

View File

@ -1,18 +1,31 @@
; RUN: llc -O0 -filetype=obj -o %t.o %s
; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
; REQUIRES: object-emission
;
; Test debug info for variadic function arguments.
; Created from tools/clang/tests/CodeGenCXX/debug-info-varargs.cpp
;
; The ... parameter of variadic should be emitted as
; DW_TAG_unspecified_parameters.
;
; Normal variadic function.
; void b(int c, ...);
;
; CHECK: DW_TAG_subprogram
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "b"
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_unspecified_parameters
;
; Variadic C++ member function.
; struct A { void a(int c, ...); }
;
; CHECK: DW_TAG_subprogram
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "a"
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_formal_parameter
@ -20,6 +33,7 @@
; CHECK: DW_TAG_unspecified_parameters
;
; Variadic function pointer.
; void (*fptr)(int, ...);
;
; CHECK: DW_TAG_subroutine_type
; CHECK-NOT: DW_TAG
@ -27,12 +41,7 @@
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_unspecified_parameters
;
; Test debug info for variadic function arguments.
; Created from tools/clang/tests/CodeGenCXX/debug-info-varargs.cpp
;
; ModuleID = 'llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.9.0"
%struct.A = type { i8 }