dblaikie updated this revision to Diff 370086. dblaikie added a comment. Herald added subscribers: usaxena95, kadircet. Herald added a project: clang-tools-extra.
Fix the clang-tools-extra caller, and update the TemplateName::print doc comment Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D108794/new/ https://reviews.llvm.org/D108794 Files: clang-tools-extra/clangd/DumpAST.cpp clang/include/clang/AST/TemplateName.h clang/lib/AST/NestedNameSpecifier.cpp clang/lib/AST/TemplateBase.cpp clang/lib/AST/TemplateName.cpp clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CXX/drs/dr10xx.cpp clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp clang/test/Index/print-type.cpp clang/test/Misc/diag-template.cpp clang/test/SemaTemplate/temp_arg_template.cpp
Index: clang/test/SemaTemplate/temp_arg_template.cpp =================================================================== --- clang/test/SemaTemplate/temp_arg_template.cpp +++ clang/test/SemaTemplate/temp_arg_template.cpp @@ -59,7 +59,7 @@ 0 << a.const_ref(); // expected-error{{invalid operands to binary expression ('int' and 'X<int>')}} } - void f0( Y<int,1> y){ 1 << y; } // expected-note{{in instantiation of function template specialization 'N::operator<<<Y, int, 1>' requested here}} + void f0( Y<int,1> y){ 1 << y; } // expected-note{{in instantiation of function template specialization 'N::operator<<<N::Y, int, 1>' requested here}} } // PR12179 Index: clang/test/Misc/diag-template.cpp =================================================================== --- clang/test/Misc/diag-template.cpp +++ clang/test/Misc/diag-template.cpp @@ -34,8 +34,8 @@ f(Q<>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<>'}} f(Q<allocator>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<>'}} f(Q<allocator, allocator>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<>'}} - f(Q<char_traits>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<char_traits>'}} - f(Q<char_traits, char_traits>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<char_traits>'}} - f(Q<char_traits, allocator>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<char_traits, allocator>'}} + f(Q<char_traits>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<default_args::char_traits>'}} + f(Q<char_traits, char_traits>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<default_args::char_traits>'}} + f(Q<char_traits, allocator>()).g(); // expected-error {{no member named 'g' in 'default_args::Q<default_args::char_traits, default_args::allocator>'}} } } Index: clang/test/Index/print-type.cpp =================================================================== --- clang/test/Index/print-type.cpp +++ clang/test/Index/print-type.cpp @@ -132,7 +132,7 @@ // CHECK: TypedefDecl=OtherType:26:18 (Definition) [type=outer::inner::Bar::OtherType] [typekind=Typedef] [canonicaltype=double] [canonicaltypekind=Double] [isPOD=1] // CHECK: TypedefDecl=ArrayType:27:15 (Definition) [type=outer::inner::Bar::ArrayType] [typekind=Typedef] [canonicaltype=int [5]] [canonicaltypekind=ConstantArray] [isPOD=1] // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1] -// CHECK: FieldDecl=baz:28:20 (Definition) [type=Baz<int, 1, Foo>] [typekind=Unexposed] [templateargs/3= [type=int] [typekind=Int]] [canonicaltype=outer::Baz<int, 1, Foo>] [canonicaltypekind=Record] [canonicaltemplateargs/3= [type=int] [typekind=Int]] [isPOD=1] +// CHECK: FieldDecl=baz:28:20 (Definition) [type=Baz<int, 1, outer::Foo>] [typekind=Unexposed] [templateargs/3= [type=int] [typekind=Int]] [canonicaltype=outer::Baz<int, 1, outer::Foo>] [canonicaltypekind=Record] [canonicaltemplateargs/3= [type=int] [typekind=Int]] [isPOD=1] // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0] // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1] // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0] Index: clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp =================================================================== --- clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp +++ clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp @@ -93,7 +93,7 @@ } namespace DeduceWithDefaultArgs { - template<template<typename...> class Container> void f(Container<int>); // expected-note {{deduced type 'X<[...], (default) int>' of 1st parameter does not match adjusted type 'X<[...], double>' of argument [with Container = X]}} + template<template<typename...> class Container> void f(Container<int>); // expected-note {{deduced type 'X<[...], (default) int>' of 1st parameter does not match adjusted type 'X<[...], double>' of argument [with Container = DeduceWithDefaultArgs::X]}} template<typename, typename = int> struct X {}; void g() { // OK, use default argument for the second template parameter. Index: clang/test/CXX/drs/dr10xx.cpp =================================================================== --- clang/test/CXX/drs/dr10xx.cpp +++ clang/test/CXX/drs/dr10xx.cpp @@ -17,8 +17,8 @@ template<typename> struct B1 {}; template<template<typename> class> struct B2 {}; template<typename X> void f(); // expected-note {{[with X = dr1004::A<int>]}} - template<template<typename> class X> void f(); // expected-note {{[with X = A]}} - template<template<typename> class X> void g(); // expected-note {{[with X = A]}} + template<template<typename> class X> void f(); // expected-note {{[with X = dr1004::A]}} + template<template<typename> class X> void g(); // expected-note {{[with X = dr1004::A]}} template<typename X> void g(); // expected-note {{[with X = dr1004::A<int>]}} struct C : A<int> { B1<A> b1a; Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -1226,7 +1226,8 @@ SmallString<128> NS; llvm::raw_svector_ostream OS(NS); - Ty->getTemplateName().print(OS, getPrintingPolicy(), /*qualified*/ false); + Ty->getTemplateName().print(OS, getPrintingPolicy(), + TemplateName::Qualified::None); printTemplateArgumentList(OS, Ty->template_arguments(), getPrintingPolicy()); SourceLocation Loc = AliasDecl->getLocation(); Index: clang/lib/AST/TemplateName.cpp =================================================================== --- clang/lib/AST/TemplateName.cpp +++ clang/lib/AST/TemplateName.cpp @@ -220,19 +220,28 @@ return getDependence() & TemplateNameDependence::UnexpandedPack; } -void -TemplateName::print(raw_ostream &OS, const PrintingPolicy &Policy, - bool SuppressNNS) const { +void TemplateName::print(raw_ostream &OS, const PrintingPolicy &Policy, + Qualified Qual) const { if (TemplateDecl *Template = Storage.dyn_cast<TemplateDecl *>()) - OS << *Template; + if (Qual == Qualified::Fully && + getDependence() != TemplateNameDependenceScope::DependentInstantiation) + Template->printQualifiedName(OS, Policy); + else + OS << *Template; else if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName()) { - if (!SuppressNNS) + if (Qual == Qualified::Fully && + getDependence() != + TemplateNameDependenceScope::DependentInstantiation) { + QTN->getTemplateDecl()->printQualifiedName(OS, Policy); + return; + } + if (Qual == Qualified::AsWritten) QTN->getQualifier()->print(OS, Policy); if (QTN->hasTemplateKeyword()) OS << "template "; OS << *QTN->getDecl(); } else if (DependentTemplateName *DTN = getAsDependentTemplateName()) { - if (!SuppressNNS && DTN->getQualifier()) + if (Qual == Qualified::AsWritten && DTN->getQualifier()) DTN->getQualifier()->print(OS, Policy); OS << "template "; @@ -242,7 +251,7 @@ OS << "operator " << getOperatorSpelling(DTN->getOperator()); } else if (SubstTemplateTemplateParmStorage *subst = getAsSubstTemplateTemplateParm()) { - subst->getReplacement().print(OS, Policy, SuppressNNS); + subst->getReplacement().print(OS, Policy, Qual); } else if (SubstTemplateTemplateParmPackStorage *SubstPack = getAsSubstTemplateTemplateParmPack()) OS << *SubstPack->getParameterPack(); Index: clang/lib/AST/TemplateBase.cpp =================================================================== --- clang/lib/AST/TemplateBase.cpp +++ clang/lib/AST/TemplateBase.cpp @@ -452,7 +452,7 @@ break; case Template: - getAsTemplate().print(Out, Policy); + getAsTemplate().print(Out, Policy, TemplateName::Qualified::Fully); break; case TemplateExpansion: Index: clang/lib/AST/NestedNameSpecifier.cpp =================================================================== --- clang/lib/AST/NestedNameSpecifier.cpp +++ clang/lib/AST/NestedNameSpecifier.cpp @@ -311,7 +311,8 @@ = dyn_cast<TemplateSpecializationType>(T)) { // Print the template name without its corresponding // nested-name-specifier. - SpecType->getTemplateName().print(OS, InnerPolicy, true); + SpecType->getTemplateName().print(OS, InnerPolicy, + TemplateName::Qualified::None); // Print the template argument list. printTemplateArgumentList(OS, SpecType->template_arguments(), Index: clang/include/clang/AST/TemplateName.h =================================================================== --- clang/include/clang/AST/TemplateName.h +++ clang/include/clang/AST/TemplateName.h @@ -309,16 +309,17 @@ /// unexpanded parameter pack (for C++0x variadic templates). bool containsUnexpandedParameterPack() const; + enum class Qualified { None, AsWritten, Fully }; /// Print the template name. /// /// \param OS the output stream to which the template name will be /// printed. /// - /// \param SuppressNNS if true, don't print the - /// nested-name-specifier that precedes the template name (if it has - /// one). + /// \param Qual print the (Qualified::None) simple name, + /// (Qualified::AsWritten) any written (possibly partial) qualifier, or + /// (Qualified::Fully) the fully qualified name. void print(raw_ostream &OS, const PrintingPolicy &Policy, - bool SuppressNNS = false) const; + Qualified Qual = Qualified::AsWritten) const; /// Debugging aid that dumps the template name. void dump(raw_ostream &OS) const; Index: clang-tools-extra/clangd/DumpAST.cpp =================================================================== --- clang-tools-extra/clangd/DumpAST.cpp +++ clang-tools-extra/clangd/DumpAST.cpp @@ -295,7 +295,7 @@ } std::string getDetail(const TemplateName &TN) { return toString([&](raw_ostream &OS) { - TN.print(OS, Ctx.getPrintingPolicy(), /*SuppressNNS=*/true); + TN.print(OS, Ctx.getPrintingPolicy(), TemplateName::Qualified::None); }); } std::string getDetail(const Attr *A) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits