[clang] [AST] Only dump desugared type when visibly different (PR #65214)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 3 02:27:15 PDT 2023


================
@@ -315,12 +315,16 @@ std::string JSONNodeDumper::createPointerRepresentation(const void *Ptr) {
 
 llvm::json::Object JSONNodeDumper::createQualType(QualType QT, bool Desugar) {
   SplitQualType SQT = QT.split();
-  llvm::json::Object Ret{{"qualType", QualType::getAsString(SQT, PrintPolicy)}};
+  std::string SQTS = QualType::getAsString(SQT, PrintPolicy);
+  llvm::json::Object Ret{{"qualType", SQTS}};
 
   if (Desugar && !QT.isNull()) {
     SplitQualType DSQT = QT.getSplitDesugaredType();
-    if (DSQT != SQT)
-      Ret["desugaredQualType"] = QualType::getAsString(DSQT, PrintPolicy);
+    if (DSQT != SQT) {
+      std::string DSQTS = QualType::getAsString(DSQT, PrintPolicy);
+      if (DSQTS != SQTS)
+        Ret["desugaredQualType"] = DSQTS;
+    }
----------------
cor3ntin wrote:

You could make the argument that it make sense for json to have both.
Not having it slightly complicate the logic of consumer code.

I think we need to decide to either:
 - keep it
 - document the change in a ReleaseNotes entry.

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


More information about the cfe-commits mailing list