aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/RAIIObjectsForParser.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-10 00:21:05 +0000
committerChris Lattner <sabre@nondot.org>2009-12-10 00:21:05 +0000
commitd167ca0d26e43292b8b9e8d5300d92784ae0e27d (patch)
treeddbeca2d712a278b2905f0746b79586ff757f3a7 /lib/Parse/RAIIObjectsForParser.h
parent5ec2e7ccb08b2a1598f12b2c6f59c6f31d035b5b (diff)
rename ExtensionRAIIObject.h -> RAIIObjectsForParser.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/RAIIObjectsForParser.h')
-rw-r--r--lib/Parse/RAIIObjectsForParser.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Parse/RAIIObjectsForParser.h b/lib/Parse/RAIIObjectsForParser.h
new file mode 100644
index 0000000000..d642da58d5
--- /dev/null
+++ b/lib/Parse/RAIIObjectsForParser.h
@@ -0,0 +1,41 @@
+//===--- RAIIObjectsForParser.h - RAII helpers for the parser ---*- 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 some simple RAII objects that are used
+// by the parser to manage bits in recursion.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_PARSE_RAII_OBJECTS_FOR_PARSER_H
+#define LLVM_CLANG_PARSE_RAII_OBJECTS_FOR_PARSER_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