LLVM 22.0.0git
IOSandbox.h
Go to the documentation of this file.
1//===- IOSandbox.h ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_SUPPORT_IOSANDBOX_H
10#define LLVM_SUPPORT_IOSANDBOX_H
11
12#if defined(LLVM_ENABLE_IO_SANDBOX) && LLVM_ENABLE_IO_SANDBOX
13
17
18namespace llvm::sys::sandbox {
19inline LLVM_THREAD_LOCAL bool Enabled = false;
20struct ScopedSetting {
22};
23inline ScopedSetting scopedEnable() { return {{Enabled, true}}; }
24inline ScopedSetting scopedDisable() { return {{Enabled, false}}; }
25inline void violationIfEnabled() {
26 if (Enabled)
27 reportFatalInternalError("IO sandbox violation");
28}
29} // namespace llvm::sys::sandbox
30
31#else
32
34struct [[maybe_unused]] ScopedSetting {};
35inline ScopedSetting scopedEnable() { return {}; }
36inline ScopedSetting scopedDisable() { return {}; }
37inline void violationIfEnabled() {}
38} // namespace llvm::sys::sandbox
39
40#endif
41
42#endif
#define LLVM_THREAD_LOCAL
\macro LLVM_THREAD_LOCAL A thread-local storage specifier which can be used with globals,...
Definition Compiler.h:679
This file provides utility classes that use RAII to save and restore values.
void violationIfEnabled()
Definition IOSandbox.h:37
ScopedSetting scopedEnable()
Definition IOSandbox.h:35
ScopedSetting scopedDisable()
Definition IOSandbox.h:36
SaveAndRestore(T &) -> SaveAndRestore< T >
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
Definition Error.cpp:177
@ Enabled
Convert any .debug_str_offsets tables to DWARF64 if needed.
Definition DWP.h:27