This is an archive of the discontinued LLVM Phabricator instance.

[Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy
ClosedPublic

Authored by mikhail.ramalho on Aug 11 2017, 5:55 AM.

Details

Summary

In our user case, we need to generate unique names for every tag, including anonymous structs/unions.

This adds a custom PrintingPolicy option to getFullyQualifiedName and the test case shows that different names are generated for different anonymous unions/structs.

Diff Detail

Event Timeline

arphaman added inline comments.
unittests/Tooling/QualTypeNamesTest.cpp
247

You should probably use multiline string here, i.e. R(" ... ")

saugustine accepted this revision.Aug 11 2017, 9:19 AM

This is a good change as far as functionality, but I defer to others on the style and other details.

This revision is now accepted and ready to land.Aug 11 2017, 9:19 AM

Should I update the other tests in QualTypeNamesTest.cpp to use multiline strings as well?

Updated QualTypeNamesTest.cpp to use multiline string in all tests.

Also ran clang-format -style=LLVM for code style.

mikhail.ramalho marked an inline comment as done.Sep 13 2017, 5:09 AM

ping

klimek added a comment.Nov 7 2017, 1:39 AM

Sorry for jumping in late, but I'm somewhat questioning whether an extra function in the API is worth the cost here:
If you already have a printing policy, getting the type name will be 1 line instead of 2; having an extra function in a large API seems not worth it at a first glance.

Should we keep just the version with the custom printing policy then?

Rebased to current master.

Removed the getFullyQualifiedName overloaded function.

rnk accepted this revision.Apr 16 2018, 2:32 PM

Mostly looks good.

unittests/Tooling/QualTypeNamesTest.cpp
225

Please choose a different variable name that doesn't clash with the PrintingPolicy type.

Renamed variables in the test so it doesn't match the type name

mikhail.ramalho marked an inline comment as done.Apr 24 2018, 7:52 AM

ping.

unittests/Tooling/QualTypeNamesTest.cpp
225

Done.

mikhail.ramalho marked an inline comment as done.May 1 2018, 6:52 AM

Ping.

I believe this was accepted by rnk - are you waiting for specific further feedback?

Last review asked to change the test case, I just want to make sure
everything is fine this time.

Ping.

Given that richard smith is the only non-approver, and that he hasn't responded, and that I contributed this code, I'm going to make an executive decision and say that this is OK to submit.

We will roll back if there are problems.

Thanks.

I just need someone to push it, as I don't have write access to the repo.

I applied this to a clean local copy, which has no other changes, and have
the following test error, which may be pilot error on my part, but
nevertheless, this test needs to be robust to changes in the line number.

llvm-svn/llvm/tools/clang/unittests/Tooling/QualTypeNamesTest.cpp:39:
Failure
Value of: false

Actual: false

Expected: true
Typename::getFullyQualifiedName failed for (anonymous struct)::un_in_st_1

Actual: union (anonymous struct at input.cc:1:1)::(anonymous union at

input.cc:2:27)
Exepcted: union (anonymous struct at input.cc:1:1)::(anonymous union at
input.cc:2:31)

Fixed the test case.

Committed as r331552.