From: Kadir Cetinkaya Date: Wed, 20 Mar 2019 09:43:38 +0000 (+0000) Subject: [clangd] Print arguments in template specializations X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f766acf96e300b0963570c2a7f9967bfc313463;p=clang [clangd] Print arguments in template specializations Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59354 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356541 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index ebcc01aa46..9dcffca526 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -1632,6 +1632,21 @@ static const TemplateArgument &getArgument(const TemplateArgumentLoc &A) { return A.getArgument(); } +static void printArgument(const TemplateArgument &A, const PrintingPolicy &PP, + llvm::raw_ostream &OS) { + A.print(PP, OS); +} + +static void printArgument(const TemplateArgumentLoc &A, + const PrintingPolicy &PP, llvm::raw_ostream &OS) { + const auto &Kind = A.getArgument().getKind(); + assert(Kind != TemplateArgument::Null && + "TemplateArgumentKind can not be null!"); + if (Kind == TemplateArgument::ArgKind::Type) + return A.getTypeSourceInfo()->getType().print(OS, PP); + return A.getArgument().print(PP, OS); +} + template static void printTo(raw_ostream &OS, ArrayRef Args, const PrintingPolicy &Policy, bool SkipBrackets) { @@ -1653,7 +1668,7 @@ static void printTo(raw_ostream &OS, ArrayRef Args, } else { if (!FirstArg) OS << Comma; - Argument.print(Policy, ArgOS); + printArgument(Arg, Policy, ArgOS); } StringRef ArgString = ArgOS.str();