]> granicus.if.org Git - clang/commitdiff
Fix scope of namespaced DISubprograms when the function definition is out-of-line.
authorAdrian Prantl <aprantl@apple.com>
Tue, 16 May 2017 23:46:10 +0000 (23:46 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 16 May 2017 23:46:10 +0000 (23:46 +0000)
This fixes a regression introduced in r302915.

Using the lexical decl context is not necessary here for what r302915
wast trying to achieve. Not canonicalizing the NamespaceDecl in
getOrCreateNamespace is suficient.

rdar://problem/29339538

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@303222 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-namespace.cpp

index 9d77c61bd52cb82984a2d8727355f5222cdfce25..bf178dd7fd80525d1e5c92d258abd935f0fcd701 100644 (file)
@@ -2860,7 +2860,7 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
 
   if (DebugKind >= codegenoptions::LimitedDebugInfo) {
     if (const NamespaceDecl *NSDecl =
-        dyn_cast_or_null<NamespaceDecl>(FD->getLexicalDeclContext()))
+        dyn_cast_or_null<NamespaceDecl>(FD->getDeclContext()))
       FDContext = getOrCreateNamespace(NSDecl);
     else if (const RecordDecl *RDecl =
              dyn_cast_or_null<RecordDecl>(FD->getDeclContext())) {
index 5b81197671e28408f486a97f86818343ca989fea..95857e339085da048e9a0b0cca1c9558395831e6 100644 (file)
@@ -60,6 +60,10 @@ void B::func_fwd() {
   anonymous = 0;
 }
 
+namespace C {
+  void c();
+}
+void C::c() {}
 
 // This should work even if 'i' and 'func' were declarations & not definitions,
 // but it doesn't yet.
@@ -114,6 +118,8 @@ void B::func_fwd() {
 // CHECK: [[M16]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[FUNC]], entity: [[FUNC_FWD:![0-9]+]]
 // CHECK: [[FUNC_FWD]] = distinct !DISubprogram(name: "func_fwd",{{.*}} line: 53,{{.*}} isDefinition: true
 // CHECK: [[M17]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: [[CTXT]], entity: [[I]]
+// CHECK: distinct !DISubprogram(name: "c",{{.*}}, scope: ![[C:[0-9]+]],{{.*}}, line: 60,{{.*}} isDefinition: true
+// CHECK: ![[C]] = !DINamespace(name: "C",
 
 // CHECK-GMLT: [[CU:![0-9]+]] = distinct !DICompileUnit(
 // CHECK-GMLT-SAME:                            emissionKind: LineTablesOnly,