mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-03 03:46:08 +00:00

with other diagnostic mapping. In the new scheme, -Wfoo or -Wno-foo or -Werror=foo all override the -pedantic options, and __extension__ robustly silences all extension diagnostics in their scope. An added bonus of this change is that MAP_DEFAULT goes away, meaning that per-diagnostic mapping information can now be stored in 2 bits, doubling the density of the Diagnostic::DiagMapping array. This also substantially simplifies Diagnostic::getDiagnosticLevel. OTOH, this temporarily introduces some "macro intensive" code in Diagnostic.cpp. This will be addressed in a later patch. llvm-svn: 69154
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
//===--- 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
|