blob: 2b2bd3b21648e66285fb8ceb3ff186915df712db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
|