[clang] [AST] Add dump() method to TypeLoc (PR #65484)

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 11 13:49:20 PDT 2023


================
@@ -96,6 +96,21 @@ void JSONNodeDumper::Visit(QualType T) {
   JOS.attribute("qualifiers", T.split().Quals.getAsString());
 }
 
+void JSONNodeDumper::Visit(TypeLoc TL) {
+  if (TL.isNull())
+    return;
+  JOS.attribute("kind",
+                (llvm::Twine(TL.getTypeLocClass() == TypeLoc::Qualified
+                                 ? "Qualified"
+                                 : TL.getTypePtr()->getTypeClassName()) +
+                 "TypeLoc")
+                    .str());
+  JOS.attribute("type",
+                createQualType(QualType(TL.getType()), /*Desugar*/ false));
----------------
sam-mccall wrote:

Done (also a few lines above where I copied this from!)

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


More information about the cfe-commits mailing list