[PATCH] Add DiagnosticSuppressionScope RAII class

Richard Smith richard at metafoo.co.uk
Tue Oct 28 10:35:28 PDT 2014


On Mon, Oct 27, 2014 at 8:14 AM, Brad King <brad.king at kitware.com> wrote:

> Hi Folks,
>
> I'm building a tool based on Clang that needs to test whether certain
> constructs can be compiled without error (e.g. implicit class members).
> In order to do this without issuing diagnostics or stopping the Clang
> operation, I need to be able to suppress emission of diagnostics but
> still know whether any would have been issued.
>
> Here is a patch adding a RAII class to achieve this.  See its commit
> message for details.  Basically the class saves the diagnostic state
> members on construction and restores them on destruction.  While in
> scope a new member tells the diagnostic engine not to emit anything
> but to still maintain counts so that error traps can work.
>
> The patch includes a new test case to cover the new functionality.
> I've tested this patch on several SVN revisions of Clang for the last
> few months, and most recently on r220679.


How does this compare to Sema's existing SFINAETrap mechanism? What happens
if you trigger an error in a non-immediate context with one of these
objects active?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141028/2d1acac4/attachment.html>


More information about the cfe-commits mailing list