diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 85dae5847b503ede9086afc891420126403c384e..1ef5e215c69b5cffb05d261a3512b693fcfe5026 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -184,30 +184,24 @@ StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) { FunctionTemplateSpecializationInfo *Info = FD->getTemplateSpecializationInfo(); - if (!Info && FII && !CGM.getCodeGenOpts().EmitCodeView) + if (!Info && FII) return FII->getName(); // Otherwise construct human readable name for debug info. SmallString<128> NS; llvm::raw_svector_ostream OS(NS); PrintingPolicy Policy(CGM.getLangOpts()); - - if (CGM.getCodeGenOpts().EmitCodeView) { - // Print a fully qualified name like MSVC would. - Policy.MSVCFormatting = true; - FD->printQualifiedName(OS, Policy); - } else { - // Print the unqualified name with some template arguments. This is what - // DWARF-based debuggers expect. - FD->printName(OS); - // Add any template specialization args. - if (Info) { - const TemplateArgumentList *TArgs = Info->TemplateArguments; - const TemplateArgument *Args = TArgs->data(); - unsigned NumArgs = TArgs->size(); - TemplateSpecializationType::PrintTemplateArgumentList(OS, Args, NumArgs, - Policy); - } + Policy.MSVCFormatting = CGM.getCodeGenOpts().EmitCodeView; + + // Print the unqualified name with some template arguments. + FD->printName(OS); + // Add any template specialization args. + if (Info) { + const TemplateArgumentList *TArgs = Info->TemplateArguments; + const TemplateArgument *Args = TArgs->data(); + unsigned NumArgs = TArgs->size(); + TemplateSpecializationType::PrintTemplateArgumentList(OS, Args, NumArgs, + Policy); } // Copy this name on the side and use its reference. diff --git a/test/CodeGenCXX/debug-info-codeview-display-name.cpp b/test/CodeGenCXX/debug-info-codeview-display-name.cpp index 1d0300c76c01b0f0da7fd74e374cbd273008c22f..1c3682462ff19127bff8734afed9abbde7707e63 100644 --- a/test/CodeGenCXX/debug-info-codeview-display-name.cpp +++ b/test/CodeGenCXX/debug-info-codeview-display-name.cpp @@ -6,9 +6,9 @@ void freefunc() { } namespace N { int b() { return 0; } -// CHECK-DAG: "N::b" +// CHECK-DAG: "b" namespace { void func() { } } -// CHECK-DAG: "N::`anonymous namespace'::func +// CHECK-DAG: "func" } void _c(void) { @@ -19,19 +19,19 @@ void _c(void) { struct foo { int operator+(int); foo(){} -// CHECK-DAG: "foo::foo" +// CHECK-DAG: "foo" ~foo(){} -// CHECK-DAG: "foo::~foo" +// CHECK-DAG: "~foo" foo(int i){} -// CHECK-DAG: "foo::foo" +// CHECK-DAG: "foo" foo(char *q){} -// CHECK-DAG: "foo::foo" +// CHECK-DAG: "foo" static foo* static_method() { return 0; } -// CHECK-DAG: "foo::static_method" +// CHECK-DAG: "static_method" }; @@ -40,7 +40,7 @@ void use_foo() { foo::static_method(); } -// CHECK-DAG: "foo::operator+" +// CHECK-DAG: "operator+" int foo::operator+(int a) { return a; } // PR17371 @@ -60,14 +60,14 @@ void OverloadedNewDelete::operator delete(void *) { } void OverloadedNewDelete::operator delete[](void *) { } int OverloadedNewDelete::operator+(int x) { return x; }; -// CHECK-DAG: "OverloadedNewDelete::operator new" -// CHECK-DAG: "OverloadedNewDelete::operator new[]" -// CHECK-DAG: "OverloadedNewDelete::operator delete" -// CHECK-DAG: "OverloadedNewDelete::operator delete[]" -// CHECK-DAG: "OverloadedNewDelete::operator+" +// CHECK-DAG: "operator new" +// CHECK-DAG: "operator new[]" +// CHECK-DAG: "operator delete" +// CHECK-DAG: "operator delete[]" +// CHECK-DAG: "operator+" -template <void (*)(void)> +template <typename T, void (*)(void)> void fn_tmpl() {} -template void fn_tmpl<freefunc>(); -// CHECK-DAG: "fn_tmpl" +template void fn_tmpl<int, freefunc>(); +// CHECK-DAG: "fn_tmpl<int,&freefunc>"