diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-05-06 23:33:13 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-05-06 23:33:13 +0000 |
commit | c2fc4ab28c13ebc1da5828e12e638514d4d777dc (patch) | |
tree | 49af2f623f054d6fe66587788f92f9ed32dcb91b | |
parent | 481da5554d03271b0d87b695449963f7728c5895 (diff) |
DebugInfo: Support imported modules (using directives) within lexical blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181272 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 7 | ||||
-rw-r--r-- | test/CodeGenCXX/debug-info-namespace.cpp | 16 |
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 6beba66c79..ddcb931e46 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2930,9 +2930,12 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, } void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl &UD) { + llvm::DIScope Scope = + LexicalBlockStack.empty() + ? getContextDescriptor(cast<Decl>(UD.getDeclContext())) + : llvm::DIScope(LexicalBlockStack.back()); DBuilder.createImportedModule( - getContextDescriptor(cast<Decl>(UD.getDeclContext())), - getOrCreateNameSpace(UD.getNominatedNamespace()), + Scope, getOrCreateNameSpace(UD.getNominatedNamespace()), getLineNumber(UD.getLocation())); } diff --git a/test/CodeGenCXX/debug-info-namespace.cpp b/test/CodeGenCXX/debug-info-namespace.cpp index 1033bce943..13a7914b7b 100644 --- a/test/CodeGenCXX/debug-info-namespace.cpp +++ b/test/CodeGenCXX/debug-info-namespace.cpp @@ -10,9 +10,13 @@ using namespace B; using namespace A; -int func() { - using namespace A::B; - return i; +int func(bool b) { + if (b) { + using namespace A::B; + return i; + } + using namespace A; + return B::i; } // CHECK: [[CU:![0-9]*]] = {{.*}}[[MODULES:![0-9]*]], metadata !""} ; [ DW_TAG_compile_unit ] @@ -22,10 +26,12 @@ int func() { // CHECK: [[VAR:![0-9]*]] = {{.*}}, metadata [[NS:![0-9]*]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i] // CHECK: [[NS]] = {{.*}}, metadata [[FILE2]], metadata [[CTXT:![0-9]*]], {{.*}} ; [ DW_TAG_namespace ] [B] [line 1] // CHECK: [[CTXT]] = {{.*}}, metadata [[FILE]], null, {{.*}} ; [ DW_TAG_namespace ] [A] [line 3] -// CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]]} +// CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]]} // CHECK: [[M1]] = metadata !{i32 {{[0-9]*}}, metadata [[CTXT]], metadata [[NS]], i32 4} ; [ DW_TAG_imported_module ] // CHECK: [[M2]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 7} ; [ DW_TAG_imported_module ] -// CHECK: [[M3]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[NS]], i32 10} ; [ DW_TAG_imported_module ] +// CHECK: [[M3]] = metadata !{i32 {{[0-9]*}}, metadata [[LEX:![0-9]*]], metadata [[NS]], i32 11} ; [ DW_TAG_imported_module ] +// CHECK: [[LEX]] = metadata !{i32 {{[0-9]*}}, metadata [[FILE2]], metadata [[FUNC]], i32 10, i32 0, i32 0} ; [ DW_TAG_lexical_block ] +// CHECK: [[M4]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[CTXT]], i32 14} ; [ DW_TAG_imported_module ] // FIXME: It is confused on win32 to generate file entry when dosish filename is given. // REQUIRES: shell |