[cfe-commits] [Patch 5 of 7] -verify fixes and enhancement

Andy Gibbs andyg1001 at hotmail.co.uk
Tue Jul 10 10:25:43 PDT 2012


On Monday, July 02, 2012 11:15 PM, Jordan Rose wrote:
> On Jun 30, 2012, at 14:12 , Andy Gibbs <andyg1001 at hotmail.co.uk> wrote:
> 
>> Part 5: Renamed Seen and Unseen to FilesWithDirectives and
>> FilesWithDiagnostics as requested; moved changes specific to part 6
>> into part 6 patch; added FIXME on post-process loop.
>> 
>> This patch must be combined with part 7 which includes the test-cases. 
>> <verify-part5.diff>
> 
>   // FIXME: Const hack, we screw up the preprocessor but in practice its ok
>   // because it doesn't get reused. It would be better if we could make a copy
>   // though.
>   CurrentPreprocessor = const_cast<Preprocessor*>(PP);
> +  if (CurrentPreprocessor) CurrentPreprocessor->addCommentHandler(this);
> 
>   PrimaryClient->BeginSourceFile(LangOpts, PP);
> }
> 
> void VerifyDiagnosticConsumer::EndSourceFile() {
> +  if (CurrentPreprocessor) CurrentPreprocessor->removeCommentHandler(this);
> 
> The "const hack" isn't actually being used in current code, but
> would be necessary to add and remove your comment handler. However,
> we'll be able to take this out completely after the tests are updated,
> right?

Not exactly, in the sense that add/removeCommentHandler still requires non-
const access.  But I don't believe we're "screwing up" the preprocessor, so
I've taken out the "FIXME".

Apart from the add/removeCommentHandler interface, no non-const access is
made to CurrentPreprocessor, and once the post-processing loop is removed
then CurrentPreprocessor will only be used for this purpose.

As a side-note, if EndSourceFile could be altered to pass the Preprocessor
as an argument like BeginSourceFile then CurrentPreprocessor becomes utterly
obsolete (and along with it, the unsightly const_cast).

> +  std::string C(SM.getCharacterData(Comment.getBegin()),
> +                SM.getCharacterData(Comment.getEnd()));
> 
> StringRef :-) But I'm wondering now if this can share any code with Dmitri's
> doc-comment-parsing work, at least for \<EOL> folding.

Changed to StringRef as suggested.  I've had a look over the recent changes
regarding comment parsing and I will consider moving over to this code once
it has settled down a little (I note that revisions are still being made to
it...).

Attached is the revised patch.

Cheers
Andy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: verify-part5.diff
Type: application/octet-stream
Size: 8589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120710/1d41d485/attachment.obj>


More information about the cfe-commits mailing list