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

Andy Gibbs andyg1001 at hotmail.co.uk
Tue Jul 10 22:03:17 PDT 2012

On Tuesday, July 10, 2012 11:15 PM, Jordan Rose wrote:
> Is there any particular reason why setForceEmit() is const and IsForceEmit 
> is
> mutable? Diags.Report returns a mutable DiagnosticBuilder.

I kept with the idioms in use for the rest of the class.  Using a const 
function with
a mutable data member, it is possible to use setForceEmit() after using the 
operators as well as before, so for example, the following is also valid:

(Diags.Report(Loc, diag) << arg).setForceEmit() << arg2;

Which means the part in brackets could be generated by a helper function.

As to why the DiagnosticBuilder class is designed const but mutable, I can 
think that this may originally have been so that Emit() could only be called 
the destructor, put Emit() is protected anyway...  Whatever, perhaps 
should actually be returning a const object?

> Other than that, I guess it looks good to me.


More information about the cfe-commits mailing list