From: Adrian Prantl Date: Thu, 16 May 2013 00:41:29 +0000 (+0000) Subject: Set the debug location for landing pad code to the canonical EH location. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=59f0a5a5481a6dcfafd092dd944e6cfb7d146d4c;p=clang Set the debug location for landing pad code to the canonical EH location. It used to point to the first call that caused the landing pad to be generated. rdar://problem/13888152 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181958 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 4080492a1c..bad13b96ad 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -206,6 +206,9 @@ public: /// invalid it is ignored. void setLocation(SourceLocation Loc); + /// getLocation - Return the current source location. + SourceLocation getLocation() const { return CurLoc; } + /// EmitLocation - Emit metadata to indicate a change in line/column /// information in the source file. /// \param ForceColumnInfo Assume DebugColumnInfo option is true. diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index a088d78641..4b09e97344 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -766,6 +766,11 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() { // Save the current IR generation state. CGBuilderTy::InsertPoint savedIP = Builder.saveAndClearIP(); + SourceLocation SavedLocation; + if (CGDebugInfo *DI = getDebugInfo()) { + SavedLocation = DI->getLocation(); + DI->EmitLocation(Builder, CurEHLocation); + } const EHPersonality &personality = EHPersonality::get(getLangOpts()); @@ -887,6 +892,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() { // Restore the old IR generation state. Builder.restoreIP(savedIP); + if (CGDebugInfo *DI = getDebugInfo()) + DI->EmitLocation(Builder, SavedLocation); return lpad; } diff --git a/test/CodeGenCXX/lpad-linetable.cpp b/test/CodeGenCXX/lpad-linetable.cpp new file mode 100644 index 0000000000..dba2ad63b2 --- /dev/null +++ b/test/CodeGenCXX/lpad-linetable.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// The landing pad should have the line number of the closing brace of the function. +// rdar://problem/13888152 +// CHECK: ret i32 +// CHECK: landingpad {{.*}} +// CHECK-NEXT: !dbg ![[LPAD:[0-9]+]] +// CHECK: ![[LPAD]] = metadata !{i32 24, i32 0, metadata !{{.*}}, null} + +# 1 "/usr/include/c++/4.2.1/vector" 1 3 +typedef long unsigned int __darwin_size_t; +typedef __darwin_size_t size_t; +namespace std { + template + class allocator + { + public: + template + struct rebind + { typedef allocator<_Tp1> other; }; + ~allocator() throw() { } + }; + template + struct _Vector_base + { + typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; + struct _Vector_impl + { + _Vector_impl(_Tp_alloc_type const& __a) { } + }; + typedef _Alloc allocator_type; + _Vector_base(const allocator_type& __a) + : _M_impl(__a) + { } + ~_Vector_base() { } + _Vector_impl _M_impl; + }; + template > + class vector + : protected _Vector_base<_Tp, _Alloc> + { + typedef _Vector_base<_Tp, _Alloc> _Base; + public: + typedef _Tp value_type; + typedef size_t size_type; + typedef _Alloc allocator_type; + vector(const allocator_type& __a = allocator_type()) + : _Base(__a) + { } + size_type + push_back(const value_type& __x) + {} + }; +} +# 10 "main.cpp" 2 + + + + +int main (int argc, char const *argv[], char const *envp[]) +{ // 15 + std::vector longs; + std::vector shorts; + for (int i=0; i<12; i++) + { + longs.push_back(i); + shorts.push_back(i); + } + return 0; // 23 +} // 24