From 436653be0ca4eb696b31315a83a44390cc8bc0b3 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 5 Jan 2013 05:58:35 +0000 Subject: [PATCH] Emit debug info for unnamed parameters. LLVM ignores this data for now - patch for that to follow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171605 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 32 +++++++++++++-------------- test/CodeGenCXX/debug-info-method.cpp | 9 ++++++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index f14834f03a..1ec9464e8a 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2428,23 +2428,9 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); return; } - - // Create the descriptor for the variable. - llvm::DIVariable D = - DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope), - Name, Unit, Line, Ty, - CGM.getLangOpts().Optimize, Flags, ArgNo); - - // Insert an llvm.dbg.declare into the current block. - llvm::Instruction *Call = - DBuilder.insertDeclare(Storage, D, Builder.GetInsertBlock()); - Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); - return; - } - - // If VD is an anonymous union then Storage represents value for - // all union fields. - if (const RecordType *RT = dyn_cast(VD->getType())) { + } else if (const RecordType *RT = dyn_cast(VD->getType())) { + // If VD is an anonymous union then Storage represents value for + // all union fields. const RecordDecl *RD = cast(RT->getDecl()); if (RD->isUnion()) { for (RecordDecl::field_iterator I = RD->field_begin(), @@ -2471,7 +2457,19 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); } } + return; } + + // Create the descriptor for the variable. + llvm::DIVariable D = + DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope), + Name, Unit, Line, Ty, + CGM.getLangOpts().Optimize, Flags, ArgNo); + + // Insert an llvm.dbg.declare into the current block. + llvm::Instruction *Call = + DBuilder.insertDeclare(Storage, D, Builder.GetInsertBlock()); + Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); } void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, diff --git a/test/CodeGenCXX/debug-info-method.cpp b/test/CodeGenCXX/debug-info-method.cpp index 5221e37210..74e44d1072 100644 --- a/test/CodeGenCXX/debug-info-method.cpp +++ b/test/CodeGenCXX/debug-info-method.cpp @@ -1,7 +1,12 @@ // RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s -// CHECK: metadata !"_ZN1A3fooEv", {{.*}}, i32 258 +// CHECK: metadata !"_ZN1A3fooEi", {{.*}}, i32 258 +// CHECK: ""{{.*}}DW_TAG_arg_variable class A { protected: - int foo(); + void foo(int); }; + +void A::foo(int) { +} + A a; -- 2.40.0