diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-04-22 06:13:21 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-04-22 06:13:21 +0000 |
commit | 9f88fe865c51efa44d5c35d1afd4c4e313a5e26e (patch) | |
tree | a3139c6c59b51b83bcbb5b7d4f429faa56f0168a | |
parent | f55abeaf4c2489106ccf4defdb1ebbd9a5d8b1ef (diff) | |
download | bcm5719-llvm-9f88fe865c51efa44d5c35d1afd4c4e313a5e26e.tar.gz bcm5719-llvm-9f88fe865c51efa44d5c35d1afd4c4e313a5e26e.zip |
Revert "Revert "PR14606: Debug info for using directives/DW_TAG_imported_module""
This reverts commit 179839 now that the corresponding LLVM patch has been fixed.
llvm-svn: 179997
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 7 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 5 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/debug-info-namespace.cpp | 13 |
4 files changed, 25 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 45692312e0c..6beba66c79a 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2929,6 +2929,13 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, getStaticDataMemberDeclaration(VD)); } +void CGDebugInfo::EmitUsingDirective(const UsingDirectiveDecl &UD) { + DBuilder.createImportedModule( + getContextDescriptor(cast<Decl>(UD.getDeclContext())), + getOrCreateNameSpace(UD.getNominatedNamespace()), + getLineNumber(UD.getLocation())); +} + /// getOrCreateNamesSpace - Return namespace descriptor for the given /// namespace decl. llvm::DINameSpace diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 060b7380580..4080492a1c6 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -262,6 +262,9 @@ public: /// EmitGlobalVariable - Emit global variable's debug info. void EmitGlobalVariable(const ValueDecl *VD, llvm::Constant *Init); + /// \brief - Emit C++ using directive. + void EmitUsingDirective(const UsingDirectiveDecl &UD); + /// getOrCreateRecordType - Emit record type's standalone debug info. llvm::DIType getOrCreateRecordType(QualType Ty, SourceLocation L); diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 9ad9cf022cb..3ce6dec6a53 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -80,7 +80,6 @@ void CodeGenFunction::EmitDecl(const Decl &D) { case Decl::CXXRecord: // struct/union/class X; [C++] case Decl::Using: // using X; [C++] case Decl::UsingShadow: - case Decl::UsingDirective: // using namespace X; [C++] case Decl::NamespaceAlias: case Decl::StaticAssert: // static_assert(X, ""); [C++0x] case Decl::Label: // __label__ x; @@ -90,6 +89,10 @@ void CodeGenFunction::EmitDecl(const Decl &D) { // None of these decls require codegen support. return; + case Decl::UsingDirective: // using namespace X; [C++] + if (CGDebugInfo *DI = getDebugInfo()) + DI->EmitUsingDirective(cast<UsingDirectiveDecl>(D)); + return; case Decl::Var: { const VarDecl &VD = cast<VarDecl>(D); assert(VD.isLocalVarDecl() && diff --git a/clang/test/CodeGenCXX/debug-info-namespace.cpp b/clang/test/CodeGenCXX/debug-info-namespace.cpp index 262e996d44d..89dd6d947f7 100644 --- a/clang/test/CodeGenCXX/debug-info-namespace.cpp +++ b/clang/test/CodeGenCXX/debug-info-namespace.cpp @@ -7,11 +7,20 @@ int i; } } +int func() { + using namespace A::B; + return i; +} + +// CHECK: [[MODULES:![0-9]*]], metadata !""} ; [ DW_TAG_compile_unit ] // CHECK: [[FILE:![0-9]*]] {{.*}}debug-info-namespace.cpp" +// CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 6] [def] [func] +// CHECK: [[FILE2:![0-9]*]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp] // CHECK: [[VAR:![0-9]*]] = {{.*}}, metadata [[NS:![0-9]*]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i] -// CHECK: [[NS]] = {{.*}}, metadata [[FILE2:![0-9]*]], metadata [[CTXT:![0-9]*]], {{.*}} ; [ DW_TAG_namespace ] [B] [line 1] +// 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: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp] +// CHECK: [[MODULES]] = metadata !{metadata [[MODULE:![0-9]*]]} +// CHECK: [[MODULE]] = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], metadata [[NS]], i32 7} ; [ DW_TAG_imported_module ] // FIXME: It is confused on win32 to generate file entry when dosish filename is given. // REQUIRES: shell |