[clang] [clang] Improve ast-dumper text printing of TemplateArgument (PR #93431)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 12:47:18 PDT 2024


================
@@ -947,6 +947,26 @@ void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef Label) {
   });
 }
 
+void TextNodeDumper::dumpTemplateArgument(const TemplateArgument &TA) {
+  llvm::SmallString<128> Str;
+  {
+    llvm::raw_svector_ostream SS(Str);
+    TA.print(PrintPolicy, SS, /*IncludeType=*/true);
+  }
+  OS << " '" << Str << "'";
+
+  if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA);
----------------
mizvekov wrote:

`getCanonicalTemplateArgument` returns a TemplateArgument by value. These are small objects we don't manually allocate, and don't unique tem (but may unique things it references internally). This is similar to how we don't take const references to QualType.

https://github.com/llvm/llvm-project/pull/93431


More information about the cfe-commits mailing list