diff options
author | David Blaikie <dblaikie@gmail.com> | 2019-06-08 00:01:21 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2019-06-08 00:01:21 +0000 |
commit | 8472fa6c54c9d044adcd147f6826bccebd730f30 (patch) | |
tree | 8c4cfc3fce80800e61baa5c55fd5c473594be77b /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 6f48c076207f49dde437d85dbd5e1bcdd580f973 (diff) | |
download | bcm5719-llvm-8472fa6c54c9d044adcd147f6826bccebd730f30.tar.gz bcm5719-llvm-8472fa6c54c9d044adcd147f6826bccebd730f30.zip |
DebugInfo: Add support for 'nodebug' attribute on typedefs and alias templates
Seems like a logical extension to me - and of interest because it might
help reduce the debug info size of libc++ by applying this attribute to
type traits that have a disproportionate debug info cost compared to the
benefit (& possibly harm/confusion) they cause users.
llvm-svn: 362856
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index a297025547e..549056dad42 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1091,15 +1091,18 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, assert(Ty->isTypeAlias()); llvm::DIType *Src = getOrCreateType(Ty->getAliasedType(), Unit); + auto *AliasDecl = + cast<TypeAliasTemplateDecl>(Ty->getTemplateName().getAsTemplateDecl()) + ->getTemplatedDecl(); + + if (AliasDecl->hasAttr<NoDebugAttr>()) + return Src; + SmallString<128> NS; llvm::raw_svector_ostream OS(NS); Ty->getTemplateName().print(OS, getPrintingPolicy(), /*qualified*/ false); printTemplateArgumentList(OS, Ty->template_arguments(), getPrintingPolicy()); - auto *AliasDecl = - cast<TypeAliasTemplateDecl>(Ty->getTemplateName().getAsTemplateDecl()) - ->getTemplatedDecl(); - SourceLocation Loc = AliasDecl->getLocation(); return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc), getLineNumber(Loc), @@ -1108,15 +1111,20 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIFile *Unit) { + llvm::DIType *Underlying = + getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit); + + if (Ty->getDecl()->hasAttr<NoDebugAttr>()) + return Underlying; + // We don't set size information, but do specify where the typedef was // declared. SourceLocation Loc = Ty->getDecl()->getLocation(); // Typedefs are derived from some other type. - return DBuilder.createTypedef( - getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit), - Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc), - getDeclContextDescriptor(Ty->getDecl())); + return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(), + getOrCreateFile(Loc), getLineNumber(Loc), + getDeclContextDescriptor(Ty->getDecl())); } static unsigned getDwarfCC(CallingConv CC) { |