diff options
| author | Reid Kleckner <rnk@google.com> | 2015-12-16 02:04:40 +0000 |
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2015-12-16 02:04:40 +0000 |
| commit | 60103383f097b6580ecb4519eeb87defdb7c05c9 (patch) | |
| tree | 592405e251c513e97e39793318334ce622ee79e4 /clang/lib | |
| parent | 23319014a9a795dd6b19ee4773aca14989dc5f65 (diff) | |
| download | bcm5719-llvm-60103383f097b6580ecb4519eeb87defdb7c05c9.tar.gz bcm5719-llvm-60103383f097b6580ecb4519eeb87defdb7c05c9.zip | |
Print qualified display names when emitting CodeView
This is what debuggers expect. Words towards fixing PR21528.
llvm-svn: 255744
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/AST/TemplateBase.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/AST/TypePrinter.cpp | 19 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 31 |
4 files changed, 36 insertions, 22 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index edbbc6a8c4f..243d4055840 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1434,8 +1434,10 @@ void NamedDecl::printQualifiedName(raw_ostream &OS, if (P.SuppressUnwrittenScope && (ND->isAnonymousNamespace() || ND->isInline())) continue; - if (ND->isAnonymousNamespace()) - OS << "(anonymous namespace)"; + if (ND->isAnonymousNamespace()) { + OS << (P.MSVCFormatting ? "`anonymous namespace\'" + : "(anonymous namespace)"); + } else OS << *ND; } else if (const auto *RD = dyn_cast<RecordDecl>(*I)) { diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp index 8c5a6918360..7103ecb5bb4 100644 --- a/clang/lib/AST/TemplateBase.cpp +++ b/clang/lib/AST/TemplateBase.cpp @@ -53,7 +53,7 @@ static void printIntegral(const TemplateArgument &TemplArg, } } - if (T->isBooleanType()) { + if (T->isBooleanType() && !Policy.MSVCFormatting) { Out << (Val.getBoolValue() ? "true" : "false"); } else if (T->isCharType()) { const char Ch = Val.getZExtValue(); diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index e360512462f..4617e1d3803 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -925,12 +925,13 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) { } else { // Make an unambiguous representation for anonymous types, e.g. // (anonymous enum at /usr/include/string.h:120:9) - + OS << (Policy.MSVCFormatting ? '`' : '('); + if (isa<CXXRecordDecl>(D) && cast<CXXRecordDecl>(D)->isLambda()) { - OS << "(lambda"; + OS << "lambda"; HasKindDecoration = true; } else { - OS << "(anonymous"; + OS << "anonymous"; } if (Policy.AnonymousTagLocations) { @@ -948,8 +949,8 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) { << ':' << PLoc.getColumn(); } } - - OS << ')'; + + OS << (Policy.MSVCFormatting ? '\'' : ')'); } // If this is a class template specialization, print the template @@ -1401,6 +1402,7 @@ TemplateSpecializationType::PrintTemplateArgumentList( unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets) { + const char *Comma = Policy.MSVCFormatting ? "," : ", "; if (!SkipBrackets) OS << '<'; @@ -1411,14 +1413,14 @@ TemplateSpecializationType::PrintTemplateArgumentList( llvm::raw_svector_ostream ArgOS(Buf); if (Args[Arg].getKind() == TemplateArgument::Pack) { if (Args[Arg].pack_size() && Arg > 0) - OS << ", "; + OS << Comma; PrintTemplateArgumentList(ArgOS, Args[Arg].pack_begin(), Args[Arg].pack_size(), Policy, true); } else { if (Arg > 0) - OS << ", "; + OS << Comma; Args[Arg].print(Policy, ArgOS); } StringRef ArgString = ArgOS.str(); @@ -1450,11 +1452,12 @@ PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgumentLoc *Args, unsigned NumArgs, const PrintingPolicy &Policy) { OS << '<'; + const char *Comma = Policy.MSVCFormatting ? "," : ", "; bool needSpace = false; for (unsigned Arg = 0; Arg < NumArgs; ++Arg) { if (Arg > 0) - OS << ", "; + OS << Comma; // Print the argument into a string. SmallString<128> Buf; diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 29ebfc62389..c2ec03f34e4 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -183,22 +183,31 @@ StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) { IdentifierInfo *FII = FD->getIdentifier(); FunctionTemplateSpecializationInfo *Info = FD->getTemplateSpecializationInfo(); - if (!Info && FII) + + if (!Info && FII && !CGM.getCodeGenOpts().EmitCodeView) return FII->getName(); // Otherwise construct human readable name for debug info. SmallString<128> NS; llvm::raw_svector_ostream OS(NS); - FD->printName(OS); - - // Add any template specialization args. - if (Info) { - const TemplateArgumentList *TArgs = Info->TemplateArguments; - const TemplateArgument *Args = TArgs->data(); - unsigned NumArgs = TArgs->size(); - PrintingPolicy Policy(CGM.getLangOpts()); - TemplateSpecializationType::PrintTemplateArgumentList(OS, Args, NumArgs, - Policy); + 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); + } } // Copy this name on the side and use its reference. |

