[cfe-dev] Adding -add-override functionality to cpp11-migrate tool

Philip Dunstan phil at philipdunstan.com
Tue Feb 5 09:44:50 PST 2013


Thanks everyone for your feedback,

I've attached a new set of patches with the changes suggested by Dmitri,
Matthieu and Edwin. I implemented many of the suggested changes but there
are a couple of changes that I made or didn't make that I wanted to
highlight.

I've replaced the use of the isCanonicalDecl matcher with
hasParent(recordDecl()) as suggested by Dmitri. I have removed the addition
of the isCanonicalDecl matcher from my patch to ASTMatchers.h and
ASTMatchersTests.cpp.

I haven't modified yet how the insertion point for the override keyword is
calculated. Dmitri suggested FunctionTypeLoc::getRParenLoc() but I don't
think that this will work if there is a trailing const keyword or deferred
return type. It's possible that with a bit of work this could be made to
work, but I am concerned that there might be other situations where this
wouldn't work that I am not aware of.

Following Edwin's suggestion I am passing -std=c++11 to the cpp11-migrate
tool in the unit tests to fix the warnings I was seeing.

Dmitri suggested not using definitions such as
const char *Method = "method";
at TU scope in AddOverrideMatchers.cpp. I have left this as it is for now.
I agree that there are concerns with such definitions but I would prefer
this definition than a string literal in AddOverride.cpp.

I have not implemented Matthieu's suggestion for finding a macro which
matches the override keyword. I think that this would be an excellent thing
to support but haven't done so because of the difficulty accessing the
required Preprocessor object.

Phil
--
Philip Dunstan
phil at philipdunstan.com
www.philipdunstan.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130205/4940f884/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-override.clang_tools_extra.174386.patch
Type: application/octet-stream
Size: 16460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130205/4940f884/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add-override-clang.174386.patch
Type: application/octet-stream
Size: 2369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130205/4940f884/attachment-0001.obj>


More information about the cfe-dev mailing list