Treat qualifiers on elaborated types for qualtypenames appropriately.
Diff Detail
Event Timeline
lib/Tooling/Core/QualTypeNames.cpp | ||
---|---|---|
386–390 | Qualtype -> QualType | |
393–394 | Maybe add an assert that QT is unqualified here? | |
401–402 | I find the way this code ensures that we preserve the qualifiers to be a little subtle. It's not obvious to me that this does the right thing for a case like struct X; void f(const ::X x) {} ... where we have an ElaboratedType with no keyword, and for which we will generate an empty Prefix -- it looks like we would lose the const on line 392 and never add it back. Can you remove and re-add the qualifiers unconditionally? (That is, move this removal of qualifiers from QT to after line 389, and move line 419 outside the if.) I think that'll make the logic clearer. | |
409–411 | With the change suggested above, you should be able to delete the handling of qualifiers here. |
unittests/Tooling/QualTypeNamesTest.cpp | ||
---|---|---|
91 | What does this produce without your change? (what's the change causing to happen?) |
Thanks for the reviews. I believe I have addressed all issues. Take another look when you get the chance.
lib/Tooling/Core/QualTypeNames.cpp | ||
---|---|---|
401–402 | We can remove and put them back unconditionally, but we still need to condition getting a new elaborated type, because an assertion prevents creating an elaborated type without a prefix of an empty keyword. I'm not sure what you expect on the new example, but I have added it as a test case (as a pointer because the struct is incomplete). The result we produce in this case is "const X *", which I think is correct. | |
unittests/Tooling/QualTypeNamesTest.cpp | ||
91 | Without the change, we get "A::B::Class0 *" with no "const". |
LGTM with a couple of minor tweaks, thanks!
lib/Tooling/Core/QualTypeNames.cpp | ||
---|---|---|
401–402 | Please move this up to immediately after line 389, so that we have a single point where we split QT into a type pointer and qualifiers. | |
401–402 | Sure, building the elaborated type should still be conditional on there being one to build :) const X * looks correct to me for your new example (I think with the old code we'd have got just X *). | |
407 | Maybe pont -> point while you're here :) | |
411 | QT = QualType(TypePtr, 0); would be fine here. |
Qualtype -> QualType