From: Eric Christopher Date: Thu, 27 Mar 2014 05:29:34 +0000 (+0000) Subject: Revert "Just call getContextDescriptor to get the context for subprograms" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb0693fd60b846b841d88de9f09dad135e925d40;p=clang Revert "Just call getContextDescriptor to get the context for subprograms" while I investigate as it seems to be causing issues with the gdb bot. This reverts commit r204874. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204896 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 92f5e63296..1a3089a14b 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2541,10 +2541,15 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType, DebugKind <= CodeGenOptions::DebugLineTablesOnly)) LinkageName = StringRef(); - // If we aren't in line table only mode then grab a full context and - // template parameters for the function. if (DebugKind >= CodeGenOptions::LimitedDebugInfo) { - FDContext = getContextDescriptor(cast(FD->getDeclContext())); + if (const NamespaceDecl *NSDecl = + dyn_cast_or_null(FD->getDeclContext())) + FDContext = getOrCreateNameSpace(NSDecl); + else if (const RecordDecl *RDecl = + dyn_cast_or_null(FD->getDeclContext())) + FDContext = getContextDescriptor(cast(RDecl)); + + // Collect template parameters. TParamsArray = CollectFunctionTemplateParams(FD, Unit); } } else if (const ObjCMethodDecl *OMD = dyn_cast(D)) { diff --git a/test/CodeGenCXX/debug-info-function-context.cpp b/test/CodeGenCXX/debug-info-function-context.cpp index 84dabae202..4ca1c8d1ec 100644 --- a/test/CodeGenCXX/debug-info-function-context.cpp +++ b/test/CodeGenCXX/debug-info-function-context.cpp @@ -25,10 +25,12 @@ int global_namespace_variable = 1; // functions that belong to the namespace have it as a context, and the global // function has the file as a context. -// CHECK: [[FILE:![0-9]*]] {{.*}}debug-info-function-context.cpp" // CHECK: metadata !"_ZTS1C", metadata !"member_function"{{.*}} [ DW_TAG_subprogram ] [line 11] [def] [member_function] + // CHECK: metadata !"_ZTS1C", metadata !"static_member_function"{{.*}} [ DW_TAG_subprogram ] [line 13] [def] [static_member_function] -// CHECK: metadata [[FILE]], null, metadata !"global_function"{{.*}} [ DW_TAG_subprogram ] [line 17] [def] [global_function] -// CHECK: metadata [[NS:![0-9]*]], metadata !"global_namespace_function"{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function] -// CHECK: [[NS]] = {{.*}}, metadata [[FILE]], null, metadata !"ns", {{.*}} ; [ DW_TAG_namespace ] [ns] [line 19] +// CHECK: metadata !22, metadata !"global_function"{{.*}} [ DW_TAG_subprogram ] [line 17] [def] [global_function] +// CHECK: !22 = {{.*}} [ DW_TAG_file_type ] + +// CHECK: metadata !24, metadata !"global_namespace_function"{{.*}} [ DW_TAG_subprogram ] [line 20] [def] [global_namespace_function] +// CHECK: !24 = {{.*}} [ DW_TAG_namespace ] [ns] [line 19] diff --git a/test/CodeGenCXX/debug-info-namespace.cpp b/test/CodeGenCXX/debug-info-namespace.cpp index e665e4742a..1c55680c95 100644 --- a/test/CodeGenCXX/debug-info-namespace.cpp +++ b/test/CodeGenCXX/debug-info-namespace.cpp @@ -52,8 +52,8 @@ using B::i; // CHECK: [[BAR:![0-9]*]] {{.*}} ; [ DW_TAG_structure_type ] [bar] [line 6, {{.*}}] [decl] [from ] // CHECK: [[F1:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] [line 4] [def] [f1] // CHECK: [[FUNC:![0-9]*]] {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func] -// CHECK: [[I:![0-9]*]] = {{.*}}, metadata [[NS]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i] // CHECK: [[FILE2]]} ; [ DW_TAG_file_type ] [{{.*}}foo.cpp] +// CHECK: [[I:![0-9]*]] = {{.*}}, metadata [[NS]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i] // CHECK: [[MODULES]] = metadata !{metadata [[M1:![0-9]*]], metadata [[M2:![0-9]*]], metadata [[M3:![0-9]*]], metadata [[M4:![0-9]*]], metadata [[M5:![0-9]*]], metadata [[M6:![0-9]*]], metadata [[M7:![0-9]*]], metadata [[M8:![0-9]*]], metadata [[M9:![0-9]*]], metadata [[M10:![0-9]*]], metadata [[M11:![0-9]*]], metadata [[M12:![0-9]*]], metadata [[M13:![0-9]*]]} // CHECK: [[M1]] = metadata !{i32 {{[0-9]*}}, metadata [[CTXT]], metadata [[NS]], i32 11} ; [ DW_TAG_imported_module ] // CHECK: [[M2]] = metadata !{i32 {{[0-9]*}}, metadata [[CU]], metadata [[CTXT]], i32 {{[0-9]*}}} ; [ DW_TAG_imported_module ]