[cfe-dev] Finding auto-transformable types
Stephen Kelly via cfe-dev
cfe-dev at lists.llvm.org
Tue Mar 22 15:54:14 PDT 2016
Hi,
I have pushed a simplified version of the auto-modernizer I linked a few
days ago to github.
https://github.com/steveire/clang-plugin-test
This version doesn't do replacements, but serves to illustrate some problem
I encountered while attempting to adjust certain declarations and leave
others alone.
Unfortunately the Clang API documentation is not very helpful, so I ended up
just copying things from other locations such as clang-tidy. That doesn't
result in the code doing the right thing, so I'm hoping for some help.
In the repo, there is also a test file
std::vector<int> v = {1, 2, 4};
{
int& three = v[2];
three = 3;
}
{
int three = v[2];
three = 3;
}
The 'int& three' should be replaced with 'auto& three' and the 'int three'
should not be touched.
Can someone help adjust the plugin code to achieve that?
Additionally, I would like to be able to transform
std::vector<int> v2;
NotCopyable nc;
into
auto v2 = std::vector<int>();
NotCopyable nc;
but I could not figure out how to do that.
Finally, broadly my goal was 'transform to use auto if the rhs type is the
same as the lhs type'. I am wondering if I am missing some simpler way to do
that than the way I've been attempting so far. If you know an easier way,
please let me know.
Thanks,
Steve.
More information about the cfe-dev
mailing list