implement a couple fixme's by implementing __extension__ properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57806 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ExtensionRAIIObject.h b/lib/Parse/ExtensionRAIIObject.h
new file mode 100644
index 0000000..e7d4446
--- /dev/null
+++ b/lib/Parse/ExtensionRAIIObject.h
@@ -0,0 +1,42 @@
+//===--- 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/Basic/Diagnostic.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;
+ bool OldState;
+ public:
+ ExtensionRAIIObject(Diagnostic &diags) : Diags(diags) {
+ OldState = Diags.getWarnOnExtensions();
+ Diags.setWarnOnExtensions(false);
+ }
+
+ ~ExtensionRAIIObject() {
+ Diags.setWarnOnExtensions(OldState);
+ }
+ };
+}
+
+#endif