[PATCH] Add DiagnosticSuppressionScope RAII class

Brad King brad.king at kitware.com
Mon Oct 27 08:14:00 PDT 2014


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.

Thanks,
-Brad

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-DiagnosticSuppressionScope-RAII-class.patch
Type: text/x-diff
Size: 8501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141027/c1b73e91/attachment.patch>


More information about the cfe-commits mailing list