Do not add redundant arguments in a method definition DIE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63527 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index 95990cf..638def2 100644
--- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
@@ -1914,18 +1914,20 @@
// Add Return Type.
if (!IsConstructor)
AddType(DW_Unit, SPDie, DIType(Args.getElement(0).getGV()));
-
- // Add arguments.
- if (!Args.isNull())
- for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
- DIE *Arg = new DIE(DW_TAG_formal_parameter);
- AddType(DW_Unit, Arg, DIType(Args.getElement(i).getGV()));
- AddUInt(Arg, DW_AT_artificial, DW_FORM_flag, 1); // ???
- SPDie->AddChild(Arg);
- }
- if (!SP.isDefinition())
- AddUInt(SPDie, DW_AT_declaration, DW_FORM_flag, 1);
+ if (!SP.isDefinition()) {
+ AddUInt(SPDie, DW_AT_declaration, DW_FORM_flag, 1);
+ // Add arguments.
+ // Do not add arguments for subprogram definition. They will be
+ // handled through RecordVariable.
+ if (!Args.isNull())
+ for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
+ DIE *Arg = new DIE(DW_TAG_formal_parameter);
+ AddType(DW_Unit, Arg, DIType(Args.getElement(i).getGV()));
+ AddUInt(Arg, DW_AT_artificial, DW_FORM_flag, 1); // ???
+ SPDie->AddChild(Arg);
+ }
+ }
if (!SP.isLocalToUnit())
AddUInt(SPDie, DW_AT_external, DW_FORM_flag, 1);
@@ -2856,6 +2858,11 @@
DIE *&Slot = Unit->getDieMapSlotFor(SP.getGV());
if (Slot) continue;
+ if (!SP.isDefinition())
+ // This is a method declaration which will be handled while
+ // constructing class type.
+ continue;
+
DIE *SubprogramDie = CreateSubprogramDIE(Unit, SP);
//Add to map.