diff options
author | Reid Kleckner <rnk@google.com> | 2017-08-08 01:33:53 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-08-08 01:33:53 +0000 |
commit | 59d1220cfd79a4fbaad9a47056d51ca1b32a119b (patch) | |
tree | 1ad781fa624b56bb27b482cce0bae1460f9b3674 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 4bc6c466b859c522d9294a303ae0c6bcf9443905 (diff) | |
download | bcm5719-llvm-59d1220cfd79a4fbaad9a47056d51ca1b32a119b.tar.gz bcm5719-llvm-59d1220cfd79a4fbaad9a47056d51ca1b32a119b.zip |
[codeview] Fix class name formatting
In particular, removes spaces between template arguments of class
templates to better match VS type visualizers.
llvm-svn: 310331
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e5955c0b8ba..7b2ae19ecc9 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -218,6 +218,19 @@ llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context, return Default; } +PrintingPolicy CGDebugInfo::getPrintingPolicy() const { + PrintingPolicy PP = CGM.getContext().getPrintingPolicy(); + + // If we're emitting codeview, it's important to try to match MSVC's naming so + // that visualizers written for MSVC will trigger for our class names. In + // particular, we can't have spaces between arguments of standard templates + // like basic_string and vector. + if (CGM.getCodeGenOpts().EmitCodeView) + PP.MSVCFormatting = true; + + return PP; +} + StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) { assert(FD && "Invalid FunctionDecl!"); IdentifierInfo *FII = FD->getIdentifier(); @@ -238,18 +251,16 @@ StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) { SmallString<128> NS; llvm::raw_svector_ostream OS(NS); - PrintingPolicy Policy(CGM.getLangOpts()); - Policy.MSVCFormatting = CGM.getCodeGenOpts().EmitCodeView; if (!UseQualifiedName) FD->printName(OS); else - FD->printQualifiedName(OS, Policy); + FD->printQualifiedName(OS, getPrintingPolicy()); // Add any template specialization args. if (Info) { const TemplateArgumentList *TArgs = Info->TemplateArguments; TemplateSpecializationType::PrintTemplateArgumentList(OS, TArgs->asArray(), - Policy); + getPrintingPolicy()); } // Copy this name on the side and use its reference. @@ -296,7 +307,7 @@ StringRef CGDebugInfo::getClassName(const RecordDecl *RD) { if (isa<ClassTemplateSpecializationDecl>(RD)) { SmallString<128> Name; llvm::raw_svector_ostream OS(Name); - RD->getNameForDiagnostic(OS, CGM.getContext().getPrintingPolicy(), + RD->getNameForDiagnostic(OS, getPrintingPolicy(), /*Qualified*/ false); // Copy this name on the side and use its reference. @@ -908,12 +919,11 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, SmallString<128> NS; llvm::raw_svector_ostream OS(NS); - Ty->getTemplateName().print(OS, CGM.getContext().getPrintingPolicy(), + Ty->getTemplateName().print(OS, getPrintingPolicy(), /*qualified*/ false); TemplateSpecializationType::PrintTemplateArgumentList( - OS, Ty->template_arguments(), - CGM.getContext().getPrintingPolicy()); + OS, Ty->template_arguments(), getPrintingPolicy()); auto *AliasDecl = cast<TypeAliasTemplateDecl>( Ty->getTemplateName().getAsTemplateDecl())->getTemplatedDecl(); |