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

Vane, Edwin edwin.vane at intel.com
Tue Feb 5 05:47:19 PST 2013


I think inserting 'override' is a good place to start. If we want to support macros like LLVM_OVERRIDE maybe we could expose extra command-line arguments so the user can provide the name of 'override' (and possibly which header it belongs to in case the macro isn't already defined).

The preprocessor object for a file is created by things ClangTool does and is kinda buried. I'm not sure what the best way to access that is. I do know that trying to re-pre-process a file results in an a thrown assertion. I think I had to create my own preprocessor to get around it.

From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Philip Dunstan
Sent: Monday, February 04, 2013 6:40 PM
To: Dmitri Gribenko
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] Adding -add-override functionality to cpp11-migrate tool

Thanks Dmitri and Matthieu,

At the moment I am not doing anything like this. I am simply inserting the "override" keyword in AddOverrideActions. Should I be appling a similar technique to find an appropriate macro to apply instead of the raw override keyword?

Looking at how it is done for the fix-it hints for [[clang::fallthrough]] I appear to need to access a Preprocessor object. Is that still available at the time the AST matchers MatchCallback is run and what is the recommended way to access it?

Phil
--
Philip Dunstan
phil at philipdunstan.com<mailto:phil at philipdunstan.com>
www.philipdunstan.com<http://www.philipdunstan.com>

On Mon, Feb 4, 2013 at 8:03 PM, Dmitri Gribenko <gribozavr at gmail.com<mailto:gribozavr at gmail.com>> wrote:
On Mon, Feb 4, 2013 at 8:24 PM, Matthieu Monrocq
<matthieu.monrocq at gmail.com<mailto:matthieu.monrocq at gmail.com>> wrote:
> I seem to remember there was some magic in the [[clang::fallthrough]]
> attribute that allowed one to find the last macro that evaluated to this
> attribute (should one exist), and thus allowed the fix-it hints to use the
> macro spelling instead of the "pure" spelling.
Philip,

You can find an example of that in r164892.

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com<mailto:gribozavr at gmail.com>>*/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130205/883702ad/attachment.html>


More information about the cfe-dev mailing list