diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-04-06 17:14:06 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-04-06 17:14:06 +0000 |
commit | f1b382e87df86b5fee84c9aeb2d7b6fad6862514 (patch) | |
tree | d5a2b07f31b6496008c67ac604906ae423fa62fc /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | d8efd89b20d78726242428714347e98534908c69 (diff) | |
download | bcm5719-llvm-f1b382e87df86b5fee84c9aeb2d7b6fad6862514.tar.gz bcm5719-llvm-f1b382e87df86b5fee84c9aeb2d7b6fad6862514.zip |
DebugInfo: Support type alias templates
We already got the type alias correct (though I've included a test case
here) since Clang represents that like any other typedef - but type
alias templates weren't being handled.
llvm-svn: 205691
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index c8fe9120800..33fbb8d5437 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -719,6 +719,32 @@ llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty, return BlockLiteralGeneric; } +llvm::DIType CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, llvm::DIFile Unit) { + assert(Ty->isTypeAlias()); + llvm::DIType Src = getOrCreateType(Ty->getAliasedType(), Unit); + assert(Src); + + SmallString<128> NS; + llvm::raw_svector_ostream OS(NS); + Ty->getTemplateName().print(OS, CGM.getContext().getPrintingPolicy(), /*qualified*/ false); + + TemplateSpecializationType::PrintTemplateArgumentList( + OS, Ty->getArgs(), Ty->getNumArgs(), + CGM.getContext().getPrintingPolicy()); + + TypeAliasDecl *AliasDecl = + cast<TypeAliasTemplateDecl>(Ty->getTemplateName().getAsTemplateDecl()) + ->getTemplatedDecl(); + + SourceLocation Loc = AliasDecl->getLocation(); + llvm::DIFile File = getOrCreateFile(Loc); + unsigned Line = getLineNumber(Loc); + + llvm::DIDescriptor Ctxt = getContextDescriptor(cast<Decl>(AliasDecl->getDeclContext())); + + return DBuilder.createTypedef(Src, internString(OS.str()), File, Line, Ctxt); +} + llvm::DIType CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIFile Unit) { // Typedefs are derived from some other type. If we have a typedef of a // typedef, make sure to emit the whole chain. @@ -1932,9 +1958,12 @@ static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) { switch (T->getTypeClass()) { default: return C.getQualifiedType(T.getTypePtr(), Quals); - case Type::TemplateSpecialization: - T = cast<TemplateSpecializationType>(T)->desugar(); - break; + case Type::TemplateSpecialization: { + const auto *Spec = cast<TemplateSpecializationType>(T); + if (Spec->isTypeAlias()) + return C.getQualifiedType(T.getTypePtr(), Quals); + T = Spec->desugar(); + break; } case Type::TypeOfExpr: T = cast<TypeOfExprType>(T)->getUnderlyingExpr()->getType(); break; @@ -2191,8 +2220,10 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) { case Type::Atomic: return CreateType(cast<AtomicType>(Ty), Unit); - case Type::Attributed: case Type::TemplateSpecialization: + return CreateType(cast<TemplateSpecializationType>(Ty), Unit); + + case Type::Attributed: case Type::Elaborated: case Type::Paren: case Type::SubstTemplateTypeParm: |