-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AST] Only dump desugared type when visibly different #65214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
Comment on lines
+323
to
+327
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could make the argument that it make sense for json to have both. I think we need to decide to either:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the issue for consumer code? It already needs to handle non-sugar types. And it's not like the type in the JSON is a structured representation of the QualType, it's just a textual dump, so you'd have to go and re-parse it to do anything with it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The aim with the original code was "if the desugared type and the given qual type are the same thing, only print one if we've been asked to print desugared", and this keeps that same aim, so I think this is reasonable. That said, I agree with @cor3ntin that this needs a release note because there is a change in behavior that may break downstream consumers who expect the |
||
if (const auto *TT = QT->getAs<TypedefType>()) | ||
Ret["typeAliasDeclId"] = createPointerRepresentation(TT->getDecl()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1351,7 +1351,6 @@ void testParmVarDecl(int TestParmVarDecl); | |
// CHECK-NEXT: "isUsed": true, | ||
// CHECK-NEXT: "name": "x", | ||
// CHECK-NEXT: "type": { | ||
// CHECK-NEXT: "desugaredQualType": "enum Enum", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, this is an example of why we need the release note; the information didn't change, it flat-out disappeared which could catch some folks by surprise. |
||
// CHECK-NEXT: "qualType": "enum Enum" | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, | ||
|
@@ -1424,7 +1423,6 @@ void testParmVarDecl(int TestParmVarDecl); | |
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "type": { | ||
// CHECK-NEXT: "desugaredQualType": "enum Enum", | ||
// CHECK-NEXT: "qualType": "enum Enum" | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "valueCategory": "prvalue", | ||
|
@@ -1446,7 +1444,6 @@ void testParmVarDecl(int TestParmVarDecl); | |
// CHECK-NEXT: } | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "type": { | ||
// CHECK-NEXT: "desugaredQualType": "enum Enum", | ||
// CHECK-NEXT: "qualType": "enum Enum" | ||
// CHECK-NEXT: }, | ||
// CHECK-NEXT: "valueCategory": "lvalue", | ||
|
@@ -1455,7 +1452,6 @@ void testParmVarDecl(int TestParmVarDecl); | |
// CHECK-NEXT: "kind": "ParmVarDecl", | ||
// CHECK-NEXT: "name": "x", | ||
// CHECK-NEXT: "type": { | ||
// CHECK-NEXT: "desugaredQualType": "enum Enum", | ||
// CHECK-NEXT: "qualType": "enum Enum" | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic release note!!