diff options
author | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
commit | f27e5a09a0d815b8a4814152954ff87dadfdefc0 (patch) | |
tree | ce7d964cbb5e39695b71481698f10cb099c23d4a /lib/Parse/ExtensionRAIIObject.h | |
download | FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.zip FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.tar.gz |
Import Clang, at r72732.
Diffstat (limited to 'lib/Parse/ExtensionRAIIObject.h')
-rw-r--r-- | lib/Parse/ExtensionRAIIObject.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/Parse/ExtensionRAIIObject.h b/lib/Parse/ExtensionRAIIObject.h new file mode 100644 index 0000000..2b2bd3b --- /dev/null +++ b/lib/Parse/ExtensionRAIIObject.h @@ -0,0 +1,40 @@ +//===--- ExtensionRAIIObject.h - Use RAII for __extension__ -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines and implements the ExtensionRAIIObject class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_PARSE_EXTENSION_RAII_OBJECT_H +#define LLVM_CLANG_PARSE_EXTENSION_RAII_OBJECT_H + +#include "clang/Parse/ParseDiagnostic.h" + +namespace clang { + + /// ExtensionRAIIObject - This saves the state of extension warnings when + /// constructed and disables them. When destructed, it restores them back to + /// the way they used to be. This is used to handle __extension__ in the + /// parser. + class ExtensionRAIIObject { + void operator=(const ExtensionRAIIObject &); // DO NOT IMPLEMENT + ExtensionRAIIObject(const ExtensionRAIIObject&); // DO NOT IMPLEMENT + Diagnostic &Diags; + public: + ExtensionRAIIObject(Diagnostic &diags) : Diags(diags) { + Diags.IncrementAllExtensionsSilenced(); + } + + ~ExtensionRAIIObject() { + Diags.DecrementAllExtensionsSilenced(); + } + }; +} + +#endif |